Return actual data values (rather than calcdata values) for xvals / yvals in hoveranywhere and clickanywhere events - #7964
Return actual data values (rather than calcdata values) for xvals / yvals in hoveranywhere and clickanywhere events#7964emilykl wants to merge 5 commits into
xvals / yvals in hoveranywhere and clickanywhere events#7964Conversation
xvals / yvals in hoveranywhere and clickanywhere events
camdecoster
left a comment
There was a problem hiding this comment.
Looks good and handles the issue well. I made a few comments.
| // the 300px-wide plot area spans exactly one day, so 0px is local midnight | ||
| // and 150px is local noon, in any timezone | ||
| function makeDatePlot(gd, layoutExtras) { | ||
| return makePlot(gd, Lib.extendFlat({ xaxis: { type: 'date', range: [dayStart, dayEnd] } }, layoutExtras), { |
There was a problem hiding this comment.
Should arguments 2 and 3 be swapped? Or should layoutExtras be renamed to traceExtras?
There was a problem hiding this comment.
Good catch, this got messed up. Updated to standardize to (gd, traceExtras, layoutExtras) arguments for both makePlot and makeDatePlot.
| @@ -0,0 +1 @@ | |||
| - Return actual data values (rather than calcdata values) for `xvals` / `yvals` in `hoveranywhere` and `clickanywhere` events [[#7964](https://github.com/plotly/plotly.js/pull/7964)] | |||
There was a problem hiding this comment.
Maybe throw a breaking change notice in here?
| - Return actual data values (rather than calcdata values) for `xvals` / `yvals` in `hoveranywhere` and `clickanywhere` events [[#7964](https://github.com/plotly/plotly.js/pull/7964)] | |
| - **Breaking**: Return actual data values (rather than calcdata values) for `xvals` / `yvals` in `hoveranywhere` and `clickanywhere` events [[#7964](https://github.com/plotly/plotly.js/pull/7964)] |
|
Could you also take look at updating the hand written TS types per this change? |
@camdecoster Just took a look, I don't think any updates are needed for this PR since |
Closes #7816
Modify hoverdata and clickdata such that the
xvals/yvalsproperties always contain data values (in the same form as the input data, i.e. may be strings in some cases) rather thancalcdatavalues (which are always numeric).Result:
linearandlog) this change has (essentially) no effect.c2d, but it's basically just checking that the values are numeric, and returningundefinedif notxvals/yvalsnow contain date strings rather than numbers representing milliseconds. (This addresses the bug reported in [BUG]: hoveranywhere / clickanywhere return incorrect timestamps for date axes with local time zones #7816)xvals/yvalsnow contain strings corresponding to category names rather than numeric values.The attribute descriptions for
hoveranywhere/clickanywhererefer toxvalsandyvalsbeing "in data space", so I believe this was always the intended behavior.Steps for testing
Details
npm ci && npm run buildxvalscontains date strings andyvalscontains a string matching a category (correct behavior)v4.0and runnpm ci && npm run buildxvalsandyvalsare now both numeric (incorrect behavior)