I’d like to contribute a PR that addresses this issue:
opened 04:56PM - 02 Aug 21 UTC
type: feature request 💡
<!--
👋 Hello, and thank you for starting this contribution!
❓ If you are tryin… g to submit a question for general support, please reach out on our discourse forum instead: https://discourse.vtk.org/c/web/9
💡 If you do want to suggest a change or request a feature, please follow the template below to increase the chances of your report being looked at.
🧱 If adequate, assign one of the `Module: XXX` labels to your issue when creating it.
-->
### Need
Customize automated layout of ScalarBarActor
The automated layout function works well but I'm running into this situation:
<img src="https://user-images.githubusercontent.com/34066664/127878548-e3a6cd7d-f0a3-4f20-b278-ca2f76753105.png" width="98" height="350" />
### Feature
<!--
A clear and concise description of a feature/enhancement you'd like to see being added. If applicable, use:
* potential alternatives
* screenshots
-->
Automated ScalarBarActor layout function is here:
https://github.com/Kitware/vtk-js/blob/b617e02a7d09c5044f559b28e0bb4c67dad3b639/Sources/Rendering/Core/ScalarBarActor/index.js#L52
I would like to pass a custom function that would be called instead of this default layout function.
```javascript
const scalarBarActor = vtkScalarBarActor.newInstance({
automated: true,
autoCompute: () => {
// layout the legend here
...
}
```
An alternative proposal would be to parameterize parts of this automated layout function, but allowing a user to override the function entirely would be an extremely flexible approach.
I would be willing to submit a PR to add this small improvement.
Draft PR here:
Kitware:master
← NGimbal:auto_layout_param
opened 12:51AM - 03 Aug 21 UTC
<!--
👋 Hello, and thank you for starting this contribution!
📖 Make sure you've… read our CONTRIBUTING.md guide before submitting your pull request.
❗️ Please follow the template below to help other contributors review your work.
-->
### Context
<!--
Explain why this change is needed. Please include relevant links supporting this change, such as:
- fix #ISSUE_NUMBER (from issue tracker)
- discourse post thread, or any other existing references
-->
fix #2020
Allow user to get / set autoLayout function, previously called computeAndApplyAutomatedSettings
### Changes
<!--
Please describe what is changing. Include:
- APIs added, deleted, deprecated, or changed
- Classes and methods added, deleted, deprecated, or changed
- A summary of usage if this is a new feature or change to an API. Adequate documentation and TS definitions should also be added/updated.
-->
- [ ] Documentation and TypeScript definitions were updated to match those changes
- [ ]
ScalarBarActor doesn't seem to have documentation or TypeScript definitions yet.
https://kitware.github.io/vtk-js/api/Rendering_Core_ScalarBarActor.html
### Results
<!--
Describe or illustrate the effects of your contribution. Please include:
- comparisons of the behavior before vs after
- screenshots of new or changed visualizations if applicable
-->
I haven't been able to test this PR locally, which is why I've made it a draft pull request at the moment. Please refer to discourse thread here:
https://discourse.vtk.org/t/npm-link-for-vtk-js/6283
### Testing
<!--
Please describe how this can be tested by reviewers. Be specific about anything not tested and the reasons why. Tests should be added for new functionality and existing tests should complete without errors. See CONTRIBUTING.md
-->
- [ ] This change adds or fixes unit tests
- [x] All tests complete without errors on the following environment:
- latest master:
- macOS 12.2.1:
- Firefox
_This contribution is funded by [Pollination](https://www.pollination.cloud/)._
Before submitting my PR, I’d like to try out the code I’ve written locally in my project to make sure it works. I’m running into a problem where I can’t figure out how to link to my local, edited version of vtk.js.
I’ve tried following the instructions here:
And here:
This hasn’t been working for me
I’m also a little confused about the different build scripts in the package.json file.
npm build
Which is suggested for the development build serves a webpack-dev-server (at localhost:8080 for me) but I’m not able to connect to the server? Also not sure how I would link to the module that way.
It seems like others have had this problem before?
opened 02:54PM - 04 Dec 19 UTC
For some reason, it looks like webpack is having some big issues compiling parav… iew glance if there is a soft link to a local vtk.js. You end up getting compile errors such as:
```
Error resolving webpackConfig Error: Cannot find module '/home/patrick/src/vtk-js/build/webpack.dev.config.js'`
```
And lots of module not found errors such as:
```
ERROR in ../vtk-js/Sources/Proxy/Representations/GlyphRepresentationProxy/index.js
Module not found: Error: Can't resolve 'vtk.js/Sources/vtk' in '/home/patrick/src/vtk-js/Sources/Proxy/Representations/GlyphRepresentationProxy'
```
Strangely enough, if you recursively copy the local `vtk.js` directory into `node_modules` instead of creating a soft link, there are no issues. So it seems to be an issue only with soft linking...
Any guidance on how to link to my edited module locally so I can test contributions before submitting would be greatly appreciated.
Ok so I worked around this issue by running
npm run build:release
npm run release:create-packages
Then copying the contents of pkg/esm to my @kitware /vtk.js folder in my project’s node_modules folder. Seems like a good enough solution for now.
2 Likes
Forrest
(Forrest)
August 3, 2021, 9:45pm
3
npm link unfortunately doesn’t quite work with vtk.js packages, since we publish @kitware/vtk.js
and vtk.js
which are two different builds of the same release. Thus, we output our distribution files to the pkg/
folder. Your approach is the most straightforward at the moment.
1 Like