-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Template strings in hover data #3007
Comments
I believe this ties in to the parcoords PR, in customizing the different types of computed data to display (cc @jonmmease) |
Very related to #1919 (more precisely https://github.com/plotly/plotly.js/pull/1919/files#r130172295), where Ricky added The syntax uses
|
Note that we'll likely need to bake in some kind of |
Here's how Highcharts does it:
|
Ha poor Highcharts. Using |
;) I was mostly pointing at the way they encode separators and precision |
Right, that's essentially the same plotly.js/src/plots/cartesian/layout_attributes.js Lines 510 to 517 in 2a3dc26
|
Should I go ahead and do as Highcharts does: if a variable name is followed by a semicolon, use the remainder as the d3 format string? ${variable_name:d3_format_string} |
Please don't! We should use the same syntax as in #1919 |
i.e. |
... but the idea of |
Re the syntax of the variable names, the original issue description contains both |
I'd vote staying "in-trace" e.g. using |
Oh i meant for stuff that plotly computes... like binleft/binright/total (for stacked bars) etc |
That would imply exposing some our internal API (mostly from Other example of "computed" values, box |
right, but right now those make their way into hovertext, so it would be nice to be able to replicate the current hovertext using the new language... i.e. if you like the 'median' but you want to change the way that number is displayed? |
Lets just insert these values - per trace type - into the same namespace as the regular trace attributes, and deal with combining the two in the respective hover routines. We don't want to use the same clipped names as in Box and violin have an extra challenge though: this syntax assumes there's only one kind of hover label for a trace. When you have separate labels for each level of the box, each one could in principle get its own formatting. What if you think min and max are obvious so you want only the numbers there, and for quartiles you want And one more question: currently the hover label formatting can depend on hover mode and occasionally on other traces that also generate hover data. So in "compare" mode normally you only get y data in each trace hover label, and x data sits in the "common label" on the x axis. But in "closest" mode both x and y are in the trace hover label and there is no common label. Occasionally other traces influence this, like if in compare mode if you make two hover labels but they don't quite share the same x, you may get a common label, and only y data in labels for traces that match the common label, but traces that don't match (but are still close enough to generate a hover label) will get both x and y in their labels. So do we just ignore this distinction when there's an explicit |
This could include both attributes that exist in the
trace
But also data that is computed on-the-fly by plotly.js, like the bin widths:
This means you could express the existing box and violin text with some type of
hovertemplate
This could span across traces, like the hover data on stacked bars
Or one day, perhaps even trace level computations, like the sum of the area
The text was updated successfully, but these errors were encountered: