Skip to content

Commit b9cffc1

Browse files
committed
add hovertemplate to heatmap, contour, histogram2d, histogram2dcontour
1 parent 0ab5b6f commit b9cffc1

File tree

11 files changed

+79
-4
lines changed

11 files changed

+79
-4
lines changed

src/traces/contour/attributes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module.exports = extendFlat({
3535
xtype: heatmapAttrs.xtype,
3636
ytype: heatmapAttrs.ytype,
3737
zhoverformat: heatmapAttrs.zhoverformat,
38+
hovertemplate: heatmapAttrs.hovertemplate,
3839

3940
connectgaps: heatmapAttrs.connectgaps,
4041

@@ -247,7 +248,7 @@ module.exports = extendFlat({
247248
].join(' ')
248249
}),
249250
editType: 'plot'
250-
}
251+
},
251252
},
252253
colorscaleAttrs('', {
253254
cLetter: 'z',

src/traces/contour/defaults.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var Lib = require('../../lib');
@@ -34,6 +33,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3433
}
3534

3635
coerce('text');
36+
coerce('hovertemplate');
37+
3738
var isConstraint = (coerce('contours.type') === 'constraint');
3839
coerce('connectgaps', Lib.isArray1D(traceOut.z));
3940

src/traces/heatmap/attributes.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'use strict';
1010

1111
var scatterAttrs = require('../scatter/attributes');
12+
var hovertemplateAttrs = require('../../components/fx/hovertemplate_attributes');
1213
var colorscaleAttrs = require('../../components/colorscale/attributes');
1314
var colorbarAttrs = require('../../components/colorbar/attributes');
1415

@@ -111,6 +112,8 @@ module.exports = extendFlat({
111112
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
112113
].join(' ')
113114
},
115+
hovertemplate: hovertemplateAttrs()
116+
}, {
114117
transforms: undefined
115118
},
116119
colorscaleAttrs('', {

src/traces/heatmap/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
2929
}
3030

3131
coerce('text');
32+
coerce('hovertemplate');
3233

3334
handleStyleDefaults(traceIn, traceOut, coerce, layout);
3435

src/traces/histogram/event_data.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) {
1313
out.x = 'xVal' in pt ? pt.xVal : pt.x;
1414
out.y = 'yVal' in pt ? pt.yVal : pt.y;
1515

16+
// for 2d histograms
17+
if('zLabelVal' in pt) out.z = pt.zLabelVal;
18+
1619
if(pt.xa) out.xaxis = pt.xa;
1720
if(pt.ya) out.yaxis = pt.ya;
1821

src/traces/histogram2d/attributes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var histogramAttrs = require('../histogram/attributes');
1212
var makeBinAttrs = require('../histogram/bin_attributes');
1313
var heatmapAttrs = require('../heatmap/attributes');
14+
var hovertemplateAttrs = require('../../components/fx/hovertemplate_attributes');
1415
var colorscaleAttrs = require('../../components/colorscale/attributes');
1516
var colorbarAttrs = require('../../components/colorbar/attributes');
1617

@@ -47,7 +48,8 @@ module.exports = extendFlat(
4748
xgap: heatmapAttrs.xgap,
4849
ygap: heatmapAttrs.ygap,
4950
zsmooth: heatmapAttrs.zsmooth,
50-
zhoverformat: heatmapAttrs.zhoverformat
51+
zhoverformat: heatmapAttrs.zhoverformat,
52+
hovertemplate: hovertemplateAttrs({}, {keys: 'z'})
5153
},
5254
colorscaleAttrs('', {
5355
cLetter: 'z',

src/traces/histogram2d/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
2929
colorscaleDefaults(
3030
traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}
3131
);
32+
coerce('hovertemplate');
3233
};

src/traces/histogram2dcontour/attributes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ module.exports = extendFlat({
3434
ncontours: contourAttrs.ncontours,
3535
contours: contourAttrs.contours,
3636
line: contourAttrs.line,
37-
zhoverformat: histogram2dAttrs.zhoverformat
37+
zhoverformat: histogram2dAttrs.zhoverformat,
38+
hovertemplate: histogram2dAttrs.hovertemplate
3839
},
3940
colorscaleAttrs('', {
4041
cLetter: 'z',

src/traces/histogram2dcontour/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3131

3232
handleContoursDefaults(traceIn, traceOut, coerce, coerce2);
3333
handleStyleDefaults(traceIn, traceOut, coerce, layout);
34+
coerce('hovertemplate');
3435
};

src/traces/scattercarpet/attributes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
var scatterAttrs = require('../scatter/attributes');
1212
var plotAttrs = require('../../plots/attributes');
13+
var hovertemplateAttrs = require('../../components/fx/hovertemplate_attributes');
1314
var colorAttributes = require('../../components/colorscale/attributes');
1415
var colorbarAttrs = require('../../components/colorbar/attributes');
1516

@@ -118,4 +119,5 @@ module.exports = {
118119
flags: ['a', 'b', 'text', 'name']
119120
}),
120121
hoveron: scatterAttrs.hoveron,
122+
hovertemplate: hovertemplateAttrs()
121123
};

0 commit comments

Comments
 (0)