Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A scale for the strokeWidth channel? #2017

Open
jimjam-slam opened this issue Mar 12, 2024 · 2 comments
Open

A scale for the strokeWidth channel? #2017

jimjam-slam opened this issue Mar 12, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@jimjam-slam
Copy link

The finite state machine example shows the use of strokeWidth as a channel to vary widths. But getting this going on a map is proving tricky:

https://observablehq.com/@jimjamslam/vary-stroke-width-on-map

Without varying stroke widths I see the expected links. But once I add strokeWidth as a channel, the values appear to be interpreted literally, making them too large enough to overwhelm the plot. (I can see them vary if I manually scale the values with something like strokeWidth: d => d.count / 100.

I've tried adding a strokeWidth object with a range and type: "log", but that doesn't seem to get me the result I'm looking for, unfortunately!

@jimjam-slam jimjam-slam changed the title Can't vary strokeWidth of links/arrows on a map Can't use strokeWidth as a channel for links/arrows on a map Mar 12, 2024
@mbostock
Copy link
Member

The strokeWidth channel is not bound to a scale, so you can only it express it as literal values (currently). As you discerned, you’ll need to say something like strokeWidth: (d) => d.count / 100, replacing 100 with whatever value is appropriate to your data.

strokeWidth: {value: vstrokeWidth, optional: true},

@mbostock mbostock changed the title Can't use strokeWidth as a channel for links/arrows on a map A scale for the strokeWidth channel? Mar 12, 2024
@mbostock mbostock added the enhancement New feature or request label Mar 12, 2024
@jimjam-slam
Copy link
Author

Thanks v much for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants