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

Allow setting 'hoverformat' for z-values in heatmap #1383

Closed
jdugge opened this issue Feb 15, 2017 · 8 comments
Closed

Allow setting 'hoverformat' for z-values in heatmap #1383

jdugge opened this issue Feb 15, 2017 · 8 comments
Labels
feature something new

Comments

@jdugge
Copy link
Contributor

jdugge commented Feb 15, 2017

I would like to round the z-values shown when hovering over a heatmap. I tried setting zaxis: { hoverformat: '.2f'}, but unfortunately this has no effect in a heatmap plot.

chrome_2017-02-15_16-21-47

Would it be possible to add a way for setting the hoverformat for z-values in heatmap plots? Maybe such an option already exists, and I just haven't found it?

Fiddle: https://jsfiddle.net/7rdcm0rg/3/

@etpinard
Copy link
Contributor

That would be nice. Thanks for posting!

@etpinard etpinard added the feature something new label Feb 15, 2017
@geocosmite
Copy link

Analogous capabilities to what @jdugge suggests for heatmap plots would be terrific for the 'intensity' attribute used in mesh3d plots and the 'surfacecolor' attribute in 'surface' plots.

@jdugge
Copy link
Contributor Author

jdugge commented Sep 13, 2017

I'd be happy to take a shot at implementing this, but I'm not quite sure what the best place for the format option would be.

I see three possible places:

  1. Use zaxis.hoverformat. This doesn't seem ideal, because heatmaps don't actually have an associated z-axis object, and creating one just for formatting the labels seems like overkill.
  2. Add a hoverformat config to the colorbar. This is pretty close in terms of plot semantics, because the colors take the place of the z-dimension in heatmaps, but it might be confusing because the hovering doesn't actually happen on the colorbar.
  3. Add a zhoverformat config to the heatmap trace. This would break with the pattern of assigning hoverformats to axes instead of traces, but that pattern isn't strictly adhered to in heatmaps anyway (cf. the existing zauto, zmin and zmax configs in heatmaps).

Any thoughts?

@geocosmite
Copy link

Any of the the three methods would be great but it seems to me that the easiest to understand place for most people would probably be option 3 given that this indeed is where other configuration options are defined for the display of the associated data.

@etpinard
Copy link
Contributor

Thanks for looking into this @jdugge !

I'd vote for 3). I'm not a fan of the zhoverformat name, but yeah I believe this feature should be set in the trace object. We can't allow 2) as heatmap trace can exist without colorbars.

Perhaps we should add a hoverlabel.zformat (or hoverlable.format.z ??) as part of the trace hoverlabel attribute container (added in #1582) . Down the road, we could add hoverlabel.xformat and hoverlabel.yformat (and even e.g. hoverlabel.lonformat for geo/mapbox traces) that way coordinate hover formatting could be set per-trace as well as per-axis (as currently with xaxis.hoverformat) where the trace setting takes precedence over the axis-wide setting.

@jdugge
Copy link
Contributor Author

jdugge commented Oct 15, 2017

@etpinard I've started on this and created a pull request to my forked master, as described in the instructions to contributors. Would you (or someone else) like to take a look at jdugge#1 and let me know whether this is the right approach, and how to proceed from here?

@etpinard
Copy link
Contributor

Review of @jdugge prelim PR: jdugge#1 (review)

@etpinard
Copy link
Contributor

closed by #2106

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

No branches or pull requests

3 participants