-
-
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
support template string on hover #3126
Merged
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
4c197e8
rough first implementation for hovertemplate
antoinerg 613c8f5
supply hover's eventData inot hovertemplate
antoinerg edf4795
delete unrelated file from branch
antoinerg dd62855
update description for hovertemplate
antoinerg a86327a
fix hovertemplate test not being run
antoinerg 1fde3aa
for now, only offer hoverdata and trace objects to hovertemplate
antoinerg d263cce
templateString evaluates attributes with a dot in their name
antoinerg 040208f
do not coerce hoverinfo if hovertemplate is defined
antoinerg 3eaa3b9
replace templateString with the more specific hovertemplateString
antoinerg 0084efb
hovertemplate: add warning if variable can't be found
antoinerg 046d367
coerce hovertemplate at trace-level, starting with scatter(gl)
antoinerg 59083ad
add <extra></extra> tag to hovertemplate for secondary labels
antoinerg 266d43a
add URL to d3-format documentation
antoinerg 108b68a
initial hovertemplate support for pie
antoinerg eb1a94a
pie hovertemplate test %{label}
antoinerg 8214d36
bar support with limited test
antoinerg bb97abe
add hovertemplate support in histogram
antoinerg 22e3a9d
pie returns default formatted value
antoinerg 377ecba
pass hovertemplate data around in `hoverData` instead of opts
antoinerg bc6cbab
update Fx.multiHovers to properly massage hoverItem
antoinerg 8c9ba5b
fix lint
antoinerg c767482
pass `trace` object in Fx.loneHover and Fx.multiHovers for hovertemplate
antoinerg 6d4c03a
extra regex still matches in the presence of newlines
antoinerg 8f440b0
fix jsDocs syntax
antoinerg 0659d20
move regex to outer scope
antoinerg 41ab464
remove old unused commented lines
antoinerg 37e40f9
move regex to outside scope
antoinerg 8e8b75b
move hovertemplate out of global-level plots attributes
antoinerg 2015c57
scatter: do not coerce hovertemplate if hoveron: 'fills'
antoinerg aef48c0
fix lint
antoinerg a3058f4
test hovertemplate support for <extra> and pseudo-html
antoinerg 3068d7d
hovertemplate warns user about missing variables up to 10 times
antoinerg a808883
hovertemplate attribute supports array
antoinerg 522f744
scattergl support for hovertemplate array
antoinerg c501b44
pie support for hovertemplate array
antoinerg f89baca
make axes available in eventData to give access to its title
antoinerg 369c9d6
add axis information to eventData only if hovertemplate
antoinerg 8d95f05
axis information is already included in hovertemplate
antoinerg 1e4bd33
pie: test that hovertemplate supports array
antoinerg 61a2da7
list available variables in pie's hovertemplate description
antoinerg 43a4cd9
hovertemplate: do not look into trace object, use fullData instead
antoinerg 70befe3
describe hovertemplate variables for scatter(gl)
antoinerg b6822e8
describe hovertemplate variables for histogram
antoinerg 59bc981
fix lint
antoinerg f75f2e0
scatter: test hover event data
antoinerg 0654245
test that event data has correct fields in bar, scatter, histogram
antoinerg 0ecd1c1
bar test: fix hover position to trigger hover events
antoinerg 6f86522
scatter: add `marker.color` to `hovertemplate` available variables
antoinerg 7be804e
one source of truth for event data keys used for doc and test
antoinerg 583eb97
fix lint
antoinerg 14ac99f
scatter: list additionnal variables available in eventData
antoinerg 1caf321
hovertemplate: update desc, do no list attributes that are `arrayOK`
antoinerg a78600a
fix syntax
antoinerg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is
marker.color
gone? In fact, allarrayOk
attributes should be part of this list. They get added to the event data viaplotly.js/src/components/fx/helpers.js
Lines 161 to 186 in 2ceb5c3
Now, maybe we don't need to hardcode all the
arrayOk
attributes intokeys
here, maybe we could just mention that all "per-point" values are available forhovertemplate
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
marker.color
is gone because it is not emitted in the event data. It used to work becausehovertemplateString
would be called with the fulltrace
object as one of its argument but I removed this in 43a4cd9 to make sure everything is on par with event data. Therefore, if we wantmarker.color
, I need to add it to the event data forscatter
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works if it's an array but not if it isn't? 🤔
That's why the test was failing: the mock I was using doesn't specify
marker.color
as an array.I think it should be available in both cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's the expected behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so I added it and now run the test with a mock that specifies marker size and color as arrays. And it now passes.
Now for extra points, I just need to add those extra event data keys in
constants.js
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 7be804e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized I didn't read your comment properly. I am sorry about that @etpinard.
Commit 14ac99f should be more satisfactory. I now list the different marker attributes that are
arrayOk
except for the nestedline
andgradient
. Should I add those as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From that same #3126 (comment)
I think it might be best to NOT hardcoded all
arrayOk
attributes into thatkeys
list, as it will be hard to remember to append it everytime we add anotherarrayOk
attribute. We should keep thatkeys
list only for keys that have no corresponding schema attributes e.gbinNumber
in histogram traces, and we should mention that allarrayOk
(aka per-point) attribute are available tohovertemplate
in thecomponents/fx/hovertemplate_attributes'
description.Sorry for not been clearer.