Skip to content

Commit ce90ced

Browse files
committed
add options to display text on histogram2d, histogram2dcontour and contour
1 parent 7aa3e04 commit ce90ced

18 files changed

+204
-3
lines changed

draftlogs/6028_add.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- Add `texttemplate` and `textfont` to `heatmap` trace [[#6028](https://github.com/plotly/plotly.js/pull/6028)]
1+
- Add `texttemplate` and `textfont` to `heatmap`, `histogram2d`, `histogram2dcontour` and `contour` traces [[#6028](https://github.com/plotly/plotly.js/pull/6028)]

src/traces/contour/attributes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ module.exports = extendFlat({
4242
yhoverformat: axisHoverFormat('y'),
4343
zhoverformat: axisHoverFormat('z', 1),
4444
hovertemplate: heatmapAttrs.hovertemplate,
45+
texttemplate: heatmapAttrs.texttemplate,
46+
textfont: heatmapAttrs.textfont,
4547
hoverongaps: heatmapAttrs.hoverongaps,
4648
connectgaps: extendFlat({}, heatmapAttrs.connectgaps, {
4749
description: [

src/traces/contour/defaults.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3131

3232
coerce('text');
3333
coerce('hovertext');
34-
coerce('hovertemplate');
3534
coerce('hoverongaps');
35+
coerce('hovertemplate');
36+
coerce('texttemplate');
37+
38+
var fontDflt = Lib.extendFlat({}, layout.font);
39+
fontDflt.color = undefined; // color contrast by default
40+
Lib.coerceFont(coerce, 'textfont', fontDflt);
3641

3742
var isConstraint = (coerce('contours.type') === 'constraint');
3843
coerce('connectgaps', Lib.isArray1D(traceOut.z));

src/traces/histogram2d/attributes.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var heatmapAttrs = require('../heatmap/attributes');
66
var baseAttrs = require('../../plots/attributes');
77
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
88
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
9+
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
910
var colorScaleAttrs = require('../../components/colorscale/attributes');
1011

1112
var extendFlat = require('../../lib/extend').extendFlat;
@@ -69,6 +70,8 @@ module.exports = extendFlat(
6970
yhoverformat: axisHoverFormat('y'),
7071
zhoverformat: axisHoverFormat('z', 1),
7172
hovertemplate: hovertemplateAttrs({}, {keys: 'z'}),
73+
texttemplate: texttemplateAttrs({editType: 'plot'}, {keys: 'z'}),
74+
textfont: heatmapAttrs.textfont,
7275
showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false})
7376
},
7477
colorScaleAttrs('', {cLetter: 'z', autoColorDflt: false})

src/traces/histogram2d/defaults.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
1919
handleStyleDefaults(traceIn, traceOut, coerce, layout);
2020
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'});
2121
coerce('hovertemplate');
22+
coerce('texttemplate');
23+
24+
var fontDflt = Lib.extendFlat({}, layout.font);
25+
fontDflt.color = undefined; // color contrast by default
26+
Lib.coerceFont(coerce, 'textfont', fontDflt);
27+
2228
coerce('xhoverformat');
2329
coerce('yhoverformat');
2430
};

src/traces/histogram2dcontour/attributes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ module.exports = extendFlat({
4242
xhoverformat: axisHoverFormat('x'),
4343
yhoverformat: axisHoverFormat('y'),
4444
zhoverformat: axisHoverFormat('z', 1),
45-
hovertemplate: histogram2dAttrs.hovertemplate
45+
hovertemplate: histogram2dAttrs.hovertemplate,
46+
texttemplate: histogram2dAttrs.texttemplate,
47+
textfont: histogram2dAttrs.textfont
4648
},
4749
colorScaleAttrs('', {
4850
cLetter: 'z',

src/traces/histogram2dcontour/defaults.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
2323
handleContoursDefaults(traceIn, traceOut, coerce, coerce2);
2424
handleStyleDefaults(traceIn, traceOut, coerce, layout);
2525
coerce('hovertemplate');
26+
coerce('texttemplate');
27+
28+
var fontDflt = Lib.extendFlat({}, layout.font);
29+
fontDflt.color = undefined; // color contrast by default
30+
Lib.coerceFont(coerce, 'textfont', fontDflt);
31+
2632
coerce('xhoverformat');
2733
coerce('yhoverformat');
2834
};
15.6 KB
Loading
8.34 KB
Loading
26.9 KB
Loading

0 commit comments

Comments
 (0)