-
Notifications
You must be signed in to change notification settings - Fork 186
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
Custom format for the tip mark? #1612
Comments
Isn't custom formatting supported? { channels: { height: d => `${d.height} in` } } |
It's a (hacky) way to address the task for now, but we'd prefer a way to format the display of values in the tip, rather than having to derive extra channels of formatted strings. |
And to add to what @Fil said, the channels option is overriding the channel, so overriding the x channel for example would interfere with the placement of the tip. |
@aborruso That should probably be a separate issue to allow the title channel (or similar) to contain rich text or markup. Since the tooltip is rendered in SVG that won’t be easy. |
I'll do it. Thank you again |
@mbostock @Fil it is super impressive how active you both are in supporting and enhancing d3/plot. Plot has progressed very nicely since you first released it. I am building a solution using plot and just ran into this tooltip issue. I'm going to post what I would like to be able to create via the tooltip rendering (even if it won't be possible to do for some time): |
@jonhelfman You could try a y scale transform to multiply by 1e6 and change the units. |
Thank you for your comment. |
Oh, snap, there's a smiley face on every comment. . . |
If you weren't joking, Could you please show me how your idea would fix the chart without making it seem like the data value are different? thanks |
@jonhelfman If you want to share your code I can show you how to use the transform option. You would use it with the label option to make clear that the units are micro-whatevers. |
Thank you very much! I put it here: https://observablehq.com/@jonhelfman/plot-tooltip-formatting-for-small-values |
Nice. It is actually now consistent with the X axis labeling. Also, because these are current values, I can add the units, A for amps, like this: label: "value (µA)". Thank you! |
Unfortunately, I can't tell in advance is 1e6 is going to be the correct multiplier. It works for this dataset, but I would like the same code to work for other data as well. I was relying on the "~s" formatting to make the tick labels as brief as possible. I like how I can specify tickFormat: "~s" on the color legend. For these reasons I would still like to upvote custom tip formatting. Thanks. |
@jonhelfman Yes, you’d have to look at the values ( |
Thank you. I'm confused by #1816 -- don't we already have code for this for the "~s" formatting of the tick labels of the chart and color legend? I had imagined that we just wanted to reuse that same code for the tip, no? |
@jonhelfman The “~s” format adds the units every time a value is formatted, and in some contexts, the units can change depending on the value. The #1816 idea is to apply the units as a transform to all values, and then show the units in the label rather than the formatted value, as we did by hand above. The only difference is that the e.g. 1e6 (micros) is determined automatically. |
k. thanks again. I updated the example to be slightly more complex, but closer to what I am actually trying to do: https://observablehq.com/@jonhelfman/plot-tooltip-formatting-for-small-values |
Another suggestion would be an option to censor some of the channels, adding to (or overriding) the ignoreChannels set. Line 21 in ec4e8f0
|
Like #1596, but for the tip mark.
The text was updated successfully, but these errors were encountered: