Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e79f4a

Browse files
committed
image: show color in hoverlabel if hoverinfo is 'all'
1 parent b223222 commit 9e79f4a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/traces/image/hover.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,21 @@ module.exports = function hoverPoints(pointData, xval, yval) {
3030
var nx = Math.floor((xval - cd0.x0) / trace.dx);
3131
var ny = Math.floor(Math.abs(yval - cd0.y0) / trace.dy);
3232

33+
var hoverinfo = cd0.hi || trace.hoverinfo;
34+
var fmtColor;
35+
if(hoverinfo) {
36+
var parts = hoverinfo.split('+');
37+
if(parts.indexOf('all') !== -1) parts = ['color'];
38+
if(parts.indexOf('color') !== -1) fmtColor = true;
39+
}
40+
3341
var colormodel = trace.colormodel;
3442
var dims = colormodel.length;
35-
var hoverinfo = cd0.hi || trace.hoverinfo;
3643
var c = trace._scaler(cd0.z[ny][nx]);
3744
var s = constants.colormodel[colormodel].suffix;
3845

3946
var colorstring = [];
40-
if(trace.hovertemplate || hoverinfo && hoverinfo.split('+').indexOf('color') !== -1) {
47+
if(trace.hovertemplate || fmtColor) {
4148
colorstring.push('[' + [c[0] + s[0], c[1] + s[1], c[2] + s[2]].join(', '));
4249
if(dims === 4) colorstring.push(', ' + c[3] + s[3]);
4350
colorstring.push(']');

0 commit comments

Comments
 (0)