plotly.js 2.6.4 → 2.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +3 -3
- package/dist/README.md +26 -26
- package/dist/plot-schema.json +1015 -407
- package/dist/plotly-basic.js +534 -195
- package/dist/plotly-basic.min.js +4 -4
- package/dist/plotly-cartesian.js +1000 -343
- package/dist/plotly-cartesian.min.js +3 -3
- package/dist/plotly-finance.js +587 -199
- package/dist/plotly-finance.min.js +4 -4
- package/dist/plotly-geo-assets.js +2 -2
- package/dist/plotly-geo.js +523 -192
- package/dist/plotly-geo.min.js +4 -4
- package/dist/plotly-gl2d.js +542 -195
- package/dist/plotly-gl2d.min.js +2 -2
- package/dist/plotly-gl3d.js +523 -192
- package/dist/plotly-gl3d.min.js +8 -8
- package/dist/plotly-mapbox.js +529 -195
- package/dist/plotly-mapbox.min.js +2 -2
- package/dist/plotly-strict.js +1224 -564
- package/dist/plotly-strict.min.js +3 -3
- package/dist/plotly-with-meta.js +1316 -626
- package/dist/plotly.js +1278 -618
- package/dist/plotly.min.js +10 -10
- package/package.json +5 -5
- package/src/components/colorbar/attributes.js +29 -20
- package/src/components/colorbar/defaults.js +30 -8
- package/src/components/colorbar/draw.js +374 -128
- package/src/components/fx/hover.js +5 -2
- package/src/components/fx/hoverlabel_defaults.js +4 -2
- package/src/components/fx/layout_attributes.js +14 -4
- package/src/components/fx/layout_defaults.js +2 -0
- package/src/components/legend/attributes.js +7 -0
- package/src/components/legend/defaults.js +24 -7
- package/src/components/titles/index.js +8 -2
- package/src/plot_api/plot_api.js +38 -9
- package/src/plots/font_attributes.js +3 -0
- package/src/plots/layout_attributes.js +1 -0
- package/src/plots/mapbox/mapbox.js +6 -3
- package/src/plots/plots.js +7 -15
- package/src/traces/bar/plot.js +8 -2
- package/src/traces/contour/attributes.js +12 -0
- package/src/traces/contour/defaults.js +9 -1
- package/src/traces/heatmap/attributes.js +16 -0
- package/src/traces/heatmap/defaults.js +2 -0
- package/src/traces/heatmap/label_defaults.js +13 -0
- package/src/traces/heatmap/plot.js +205 -4
- package/src/traces/histogram/attributes.js +40 -0
- package/src/traces/histogram/calc.js +3 -2
- package/src/traces/histogram/defaults.js +11 -0
- package/src/traces/histogram2d/attributes.js +8 -0
- package/src/traces/histogram2d/defaults.js +4 -0
- package/src/traces/histogram2dcontour/attributes.js +3 -1
- package/src/traces/histogram2dcontour/defaults.js +8 -1
- package/src/traces/pie/calc.js +3 -1
- package/src/version.js +1 -1
- package/tasks/test_mock.js +1 -0
|
@@ -1103,7 +1103,9 @@ function createHoverText(hoverData, opts) {
|
|
|
1103
1103
|
orientation: 'v'
|
|
1104
1104
|
}
|
|
1105
1105
|
};
|
|
1106
|
-
var mockLayoutOut = {
|
|
1106
|
+
var mockLayoutOut = {
|
|
1107
|
+
font: font
|
|
1108
|
+
};
|
|
1107
1109
|
legendSupplyDefaults(mockLayoutIn, mockLayoutOut, gd._fullData);
|
|
1108
1110
|
var mockLegend = mockLayoutOut.legend;
|
|
1109
1111
|
|
|
@@ -1144,7 +1146,8 @@ function createHoverText(hoverData, opts) {
|
|
|
1144
1146
|
|
|
1145
1147
|
// Draw unified hover label
|
|
1146
1148
|
mockLegend._inHover = true;
|
|
1147
|
-
mockLegend._groupTitleFont =
|
|
1149
|
+
mockLegend._groupTitleFont = hoverlabel.grouptitlefont;
|
|
1150
|
+
|
|
1148
1151
|
legendDraw(gd, mockLegend);
|
|
1149
1152
|
|
|
1150
1153
|
// Position the hover
|
|
@@ -7,9 +7,11 @@ var isUnifiedHover = require('./helpers').isUnifiedHover;
|
|
|
7
7
|
module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts) {
|
|
8
8
|
opts = opts || {};
|
|
9
9
|
|
|
10
|
+
var hasLegend = contOut.legend;
|
|
11
|
+
|
|
10
12
|
function inheritFontAttr(attr) {
|
|
11
13
|
if(!opts.font[attr]) {
|
|
12
|
-
opts.font[attr] =
|
|
14
|
+
opts.font[attr] = hasLegend ? contOut.legend.font[attr] : contOut.font[attr];
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -20,7 +22,7 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts
|
|
|
20
22
|
inheritFontAttr('family');
|
|
21
23
|
inheritFontAttr('color');
|
|
22
24
|
|
|
23
|
-
if(
|
|
25
|
+
if(hasLegend) {
|
|
24
26
|
if(!opts.bgcolor) opts.bgcolor = Color.combine(contOut.legend.bgcolor, contOut.paper_bgcolor);
|
|
25
27
|
if(!opts.bordercolor) opts.bordercolor = contOut.legend.bordercolor;
|
|
26
28
|
} else {
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var constants = require('./constants');
|
|
4
4
|
|
|
5
|
-
var fontAttrs = require('../../plots/font_attributes')
|
|
5
|
+
var fontAttrs = require('../../plots/font_attributes');
|
|
6
|
+
|
|
7
|
+
var font = fontAttrs({
|
|
6
8
|
editType: 'none',
|
|
7
9
|
description: 'Sets the default hover label font used by all traces on the graph.'
|
|
8
10
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
font.family.dflt = constants.HOVERFONT;
|
|
12
|
+
font.size.dflt = constants.HOVERFONTSIZE;
|
|
11
13
|
|
|
12
14
|
module.exports = {
|
|
13
15
|
clickmode: {
|
|
@@ -118,7 +120,14 @@ module.exports = {
|
|
|
118
120
|
'Sets the border color of all hover labels on graph.'
|
|
119
121
|
].join(' ')
|
|
120
122
|
},
|
|
121
|
-
font:
|
|
123
|
+
font: font,
|
|
124
|
+
grouptitlefont: fontAttrs({
|
|
125
|
+
editType: 'none',
|
|
126
|
+
description: [
|
|
127
|
+
'Sets the font for group titles in hover (unified modes).',
|
|
128
|
+
'Defaults to `hoverlabel.font`.'
|
|
129
|
+
].join(' ')
|
|
130
|
+
}),
|
|
122
131
|
align: {
|
|
123
132
|
valType: 'enumerated',
|
|
124
133
|
values: ['left', 'right', 'auto'],
|
|
@@ -143,6 +152,7 @@ module.exports = {
|
|
|
143
152
|
'`namelength - 3` characters and add an ellipsis.'
|
|
144
153
|
].join(' ')
|
|
145
154
|
},
|
|
155
|
+
|
|
146
156
|
editType: 'none'
|
|
147
157
|
},
|
|
148
158
|
selectdirection: {
|
|
@@ -30,6 +30,13 @@ module.exports = {
|
|
|
30
30
|
editType: 'legend',
|
|
31
31
|
description: 'Sets the font used to text the legend items.'
|
|
32
32
|
}),
|
|
33
|
+
grouptitlefont: fontAttrs({
|
|
34
|
+
editType: 'legend',
|
|
35
|
+
description: [
|
|
36
|
+
'Sets the font for group titles in legend.',
|
|
37
|
+
'Defaults to `legend.font` with its size increased about 10%.'
|
|
38
|
+
].join(' ')
|
|
39
|
+
}),
|
|
33
40
|
orientation: {
|
|
34
41
|
valType: 'enumerated',
|
|
35
42
|
values: ['v', 'h'],
|
|
@@ -4,6 +4,7 @@ var Registry = require('../../registry');
|
|
|
4
4
|
var Lib = require('../../lib');
|
|
5
5
|
var Template = require('../../plot_api/plot_template');
|
|
6
6
|
|
|
7
|
+
var plotsAttrs = require('../../plots/attributes');
|
|
7
8
|
var attributes = require('./attributes');
|
|
8
9
|
var basePlotLayoutAttributes = require('../../plots/layout_attributes');
|
|
9
10
|
var helpers = require('./helpers');
|
|
@@ -11,13 +12,30 @@ var helpers = require('./helpers');
|
|
|
11
12
|
|
|
12
13
|
module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
|
|
13
14
|
var containerIn = layoutIn.legend || {};
|
|
15
|
+
var containerOut = Template.newContainer(layoutOut, 'legend');
|
|
16
|
+
|
|
17
|
+
function coerce(attr, dflt) {
|
|
18
|
+
return Lib.coerce(containerIn, containerOut, attributes, attr, dflt);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var trace;
|
|
22
|
+
var traceCoerce = function(attr, dflt) {
|
|
23
|
+
var traceIn = trace._input;
|
|
24
|
+
var traceOut = trace;
|
|
25
|
+
return Lib.coerce(traceIn, traceOut, plotsAttrs, attr, dflt);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var globalFont = layoutOut.font || {};
|
|
29
|
+
var grouptitlefont = Lib.coerceFont(coerce, 'grouptitlefont', Lib.extendFlat({}, globalFont, {
|
|
30
|
+
size: Math.round(globalFont.size * 1.1)
|
|
31
|
+
}));
|
|
14
32
|
|
|
15
33
|
var legendTraceCount = 0;
|
|
16
34
|
var legendReallyHasATrace = false;
|
|
17
35
|
var defaultOrder = 'normal';
|
|
18
36
|
|
|
19
37
|
for(var i = 0; i < fullData.length; i++) {
|
|
20
|
-
|
|
38
|
+
trace = fullData[i];
|
|
21
39
|
|
|
22
40
|
if(!trace.visible) continue;
|
|
23
41
|
|
|
@@ -44,6 +62,8 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
|
|
|
44
62
|
legendTraceCount++;
|
|
45
63
|
}
|
|
46
64
|
}
|
|
65
|
+
|
|
66
|
+
Lib.coerceFont(traceCoerce, 'legendgrouptitle.font', grouptitlefont);
|
|
47
67
|
}
|
|
48
68
|
|
|
49
69
|
if((Registry.traceIs(trace, 'bar') && layoutOut.barmode === 'stack') ||
|
|
@@ -62,13 +82,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
|
|
|
62
82
|
basePlotLayoutAttributes, 'showlegend',
|
|
63
83
|
legendReallyHasATrace && legendTraceCount > 1);
|
|
64
84
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var containerOut = Template.newContainer(layoutOut, 'legend');
|
|
85
|
+
// delete legend
|
|
86
|
+
if(showLegend === false) layoutOut.legend = undefined;
|
|
68
87
|
|
|
69
|
-
|
|
70
|
-
return Lib.coerce(containerIn, containerOut, attributes, attr, dflt);
|
|
71
|
-
}
|
|
88
|
+
if(showLegend === false && !containerIn.uirevision) return;
|
|
72
89
|
|
|
73
90
|
coerce('uirevision', layoutOut.uirevision);
|
|
74
91
|
|
|
@@ -96,8 +96,10 @@ function draw(gd, titleClass, options) {
|
|
|
96
96
|
|
|
97
97
|
var elShouldExist = txt || editable;
|
|
98
98
|
|
|
99
|
+
var hColorbarMoveTitle;
|
|
99
100
|
if(!group) {
|
|
100
101
|
group = Lib.ensureSingle(fullLayout._infolayer, 'g', 'g-' + titleClass);
|
|
102
|
+
hColorbarMoveTitle = fullLayout._hColorbarMoveTitle;
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
var el = group.selectAll('text')
|
|
@@ -121,13 +123,17 @@ function draw(gd, titleClass, options) {
|
|
|
121
123
|
function drawTitle(titleEl) {
|
|
122
124
|
var transformVal;
|
|
123
125
|
|
|
126
|
+
if(!transform && hColorbarMoveTitle) {
|
|
127
|
+
transform = {};
|
|
128
|
+
}
|
|
129
|
+
|
|
124
130
|
if(transform) {
|
|
125
131
|
transformVal = '';
|
|
126
132
|
if(transform.rotate) {
|
|
127
133
|
transformVal += 'rotate(' + [transform.rotate, attributes.x, attributes.y] + ')';
|
|
128
134
|
}
|
|
129
|
-
if(transform.offset) {
|
|
130
|
-
transformVal += strTranslate(0, transform.offset);
|
|
135
|
+
if(transform.offset || hColorbarMoveTitle) {
|
|
136
|
+
transformVal += strTranslate(0, (transform.offset || 0) - (hColorbarMoveTitle || 0));
|
|
131
137
|
}
|
|
132
138
|
} else {
|
|
133
139
|
transformVal = null;
|
package/src/plot_api/plot_api.js
CHANGED
|
@@ -1719,7 +1719,7 @@ function cleanDeprecatedAttributeKeys(aobj) {
|
|
|
1719
1719
|
if((key === 'title' || oldAxisTitleRegex.test(key) || colorbarRegex.test(key)) &&
|
|
1720
1720
|
(typeof value === 'string' || typeof value === 'number')) {
|
|
1721
1721
|
replace(key, key.replace('title', 'title.text'));
|
|
1722
|
-
} else if(key.indexOf('titlefont') > -1) {
|
|
1722
|
+
} else if(key.indexOf('titlefont') > -1 && key.indexOf('grouptitlefont') === -1) {
|
|
1723
1723
|
replace(key, key.replace('titlefont', 'title.font'));
|
|
1724
1724
|
} else if(key.indexOf('titleposition') > -1) {
|
|
1725
1725
|
replace(key, key.replace('titleposition', 'title.position'));
|
|
@@ -2396,7 +2396,8 @@ function findUIPattern(key, patternSpecs) {
|
|
|
2396
2396
|
var spec = patternSpecs[i];
|
|
2397
2397
|
var match = key.match(spec.pattern);
|
|
2398
2398
|
if(match) {
|
|
2399
|
-
|
|
2399
|
+
var head = match[1] || '';
|
|
2400
|
+
return {head: head, tail: key.substr(head.length + 1), attr: spec.attr};
|
|
2400
2401
|
}
|
|
2401
2402
|
}
|
|
2402
2403
|
}
|
|
@@ -2448,26 +2449,54 @@ function valsMatch(v1, v2) {
|
|
|
2448
2449
|
|
|
2449
2450
|
function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
|
|
2450
2451
|
var layoutPreGUI = oldFullLayout._preGUI;
|
|
2451
|
-
var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal;
|
|
2452
|
+
var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal, head, tail;
|
|
2452
2453
|
var bothInheritAutorange = [];
|
|
2454
|
+
var newAutorangeIn = {};
|
|
2453
2455
|
var newRangeAccepted = {};
|
|
2454
2456
|
for(key in layoutPreGUI) {
|
|
2455
2457
|
match = findUIPattern(key, layoutUIControlPatterns);
|
|
2456
2458
|
if(match) {
|
|
2457
|
-
|
|
2459
|
+
head = match.head;
|
|
2460
|
+
tail = match.tail;
|
|
2461
|
+
revAttr = match.attr || (head + '.uirevision');
|
|
2458
2462
|
oldRev = nestedProperty(oldFullLayout, revAttr).get();
|
|
2459
2463
|
newRev = oldRev && getNewRev(revAttr, layout);
|
|
2464
|
+
|
|
2460
2465
|
if(newRev && (newRev === oldRev)) {
|
|
2461
2466
|
preGUIVal = layoutPreGUI[key];
|
|
2462
2467
|
if(preGUIVal === null) preGUIVal = undefined;
|
|
2463
2468
|
newNP = nestedProperty(layout, key);
|
|
2464
2469
|
newVal = newNP.get();
|
|
2470
|
+
|
|
2465
2471
|
if(valsMatch(newVal, preGUIVal)) {
|
|
2466
|
-
if(newVal === undefined &&
|
|
2467
|
-
bothInheritAutorange.push(
|
|
2472
|
+
if(newVal === undefined && tail === 'autorange') {
|
|
2473
|
+
bothInheritAutorange.push(head);
|
|
2468
2474
|
}
|
|
2469
2475
|
newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get()));
|
|
2470
2476
|
continue;
|
|
2477
|
+
} else if(tail === 'autorange' || tail.substr(0, 6) === 'range[') {
|
|
2478
|
+
// Special case for (auto)range since we push it back into the layout
|
|
2479
|
+
// so all null should be treated equivalently to autorange: true with any range
|
|
2480
|
+
var pre0 = layoutPreGUI[head + '.range[0]'];
|
|
2481
|
+
var pre1 = layoutPreGUI[head + '.range[1]'];
|
|
2482
|
+
var preAuto = layoutPreGUI[head + '.autorange'];
|
|
2483
|
+
if(preAuto || (preAuto === null && pre0 === null && pre1 === null)) {
|
|
2484
|
+
// Only read the input layout once and stash the result,
|
|
2485
|
+
// so we get it before we start modifying it
|
|
2486
|
+
if(!(head in newAutorangeIn)) {
|
|
2487
|
+
var newContainer = nestedProperty(layout, head).get();
|
|
2488
|
+
newAutorangeIn[head] = newContainer && (
|
|
2489
|
+
newContainer.autorange ||
|
|
2490
|
+
(newContainer.autorange !== false && (
|
|
2491
|
+
!newContainer.range || newContainer.range.length !== 2)
|
|
2492
|
+
)
|
|
2493
|
+
);
|
|
2494
|
+
}
|
|
2495
|
+
if(newAutorangeIn[head]) {
|
|
2496
|
+
newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get()));
|
|
2497
|
+
continue;
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2471
2500
|
}
|
|
2472
2501
|
}
|
|
2473
2502
|
} else {
|
|
@@ -2478,12 +2507,12 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
|
|
|
2478
2507
|
// so remove it from _preGUI for next time.
|
|
2479
2508
|
delete layoutPreGUI[key];
|
|
2480
2509
|
|
|
2481
|
-
if(
|
|
2482
|
-
newRangeAccepted[
|
|
2510
|
+
if(match && match.tail.substr(0, 6) === 'range[') {
|
|
2511
|
+
newRangeAccepted[match.head] = 1;
|
|
2483
2512
|
}
|
|
2484
2513
|
}
|
|
2485
2514
|
|
|
2486
|
-
//
|
|
2515
|
+
// More special logic for `autorange`, since it interacts with `range`:
|
|
2487
2516
|
// If the new figure's matching `range` was kept, and `autorange`
|
|
2488
2517
|
// wasn't supplied explicitly in either the original or the new figure,
|
|
2489
2518
|
// we shouldn't alter that - but we may just have done that, so fix it.
|
|
@@ -53,6 +53,9 @@ module.exports = function(opts) {
|
|
|
53
53
|
description: '' + (opts.description || '') + ''
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
+
if(opts.autoSize) attrs.size.dflt = 'auto';
|
|
57
|
+
if(opts.autoColor) attrs.color.dflt = 'auto';
|
|
58
|
+
|
|
56
59
|
if(opts.arrayOk) {
|
|
57
60
|
attrs.family.arrayOk = true;
|
|
58
61
|
attrs.size.arrayOk = true;
|
|
@@ -722,11 +722,14 @@ proto.project = function(v) {
|
|
|
722
722
|
proto.getView = function() {
|
|
723
723
|
var map = this.map;
|
|
724
724
|
var mapCenter = map.getCenter();
|
|
725
|
-
var
|
|
725
|
+
var lon = mapCenter.lng;
|
|
726
|
+
var lat = mapCenter.lat;
|
|
727
|
+
var center = { lon: lon, lat: lat };
|
|
726
728
|
|
|
727
729
|
var canvas = map.getCanvas();
|
|
728
|
-
var w = canvas.width;
|
|
729
|
-
var h = canvas.height;
|
|
730
|
+
var w = parseInt(canvas.style.width);
|
|
731
|
+
var h = parseInt(canvas.style.height);
|
|
732
|
+
|
|
730
733
|
return {
|
|
731
734
|
center: center,
|
|
732
735
|
zoom: map.getZoom(),
|
package/src/plots/plots.js
CHANGED
|
@@ -1321,13 +1321,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac
|
|
|
1321
1321
|
);
|
|
1322
1322
|
|
|
1323
1323
|
coerce('legendgroup');
|
|
1324
|
-
|
|
1325
|
-
if(titleText) {
|
|
1326
|
-
Lib.coerceFont(coerce, 'legendgrouptitle.font', Lib.extendFlat({}, layout.font, {
|
|
1327
|
-
size: Math.round(layout.font.size * 1.1) // default to larger font size
|
|
1328
|
-
}));
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1324
|
+
coerce('legendgrouptitle.text');
|
|
1331
1325
|
coerce('legendrank');
|
|
1332
1326
|
|
|
1333
1327
|
traceOut._dfltShowLegend = true;
|
|
@@ -1475,16 +1469,14 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
|
|
|
1475
1469
|
|
|
1476
1470
|
coerce('autotypenumbers');
|
|
1477
1471
|
|
|
1478
|
-
var
|
|
1479
|
-
|
|
1480
|
-
coerce('title.text', layoutOut._dfltTitle.plot);
|
|
1472
|
+
var font = Lib.coerceFont(coerce, 'font');
|
|
1473
|
+
var fontSize = font.size;
|
|
1481
1474
|
|
|
1482
|
-
Lib.coerceFont(coerce, 'title.font', {
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
color: globalFont.color
|
|
1486
|
-
});
|
|
1475
|
+
Lib.coerceFont(coerce, 'title.font', Lib.extendFlat({}, font, {
|
|
1476
|
+
size: Math.round(fontSize * 1.4)
|
|
1477
|
+
}));
|
|
1487
1478
|
|
|
1479
|
+
coerce('title.text', layoutOut._dfltTitle.plot);
|
|
1488
1480
|
coerce('title.xref');
|
|
1489
1481
|
coerce('title.yref');
|
|
1490
1482
|
coerce('title.x');
|
package/src/traces/bar/plot.js
CHANGED
|
@@ -428,7 +428,7 @@ function appendBarText(gd, plotinfo, bar, cd, i, x0, x1, y0, y1, opts, makeOnCom
|
|
|
428
428
|
}
|
|
429
429
|
|
|
430
430
|
transform.fontSize = font.size;
|
|
431
|
-
recordMinTextSize(trace.type, transform, fullLayout);
|
|
431
|
+
recordMinTextSize(trace.type === 'histogram' ? 'bar' : trace.type, transform, fullLayout);
|
|
432
432
|
calcBar.transform = transform;
|
|
433
433
|
|
|
434
434
|
transition(textSelection, fullLayout, opts, makeOnCompleteCallback)
|
|
@@ -631,10 +631,11 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) {
|
|
|
631
631
|
if(!texttemplate) return '';
|
|
632
632
|
var isWaterfall = (trace.type === 'waterfall');
|
|
633
633
|
var isFunnel = (trace.type === 'funnel');
|
|
634
|
+
var isHorizontal = trace.orientation === 'h';
|
|
634
635
|
|
|
635
636
|
var pLetter, pAxis;
|
|
636
637
|
var vLetter, vAxis;
|
|
637
|
-
if(
|
|
638
|
+
if(isHorizontal) {
|
|
638
639
|
pLetter = 'y';
|
|
639
640
|
pAxis = ya;
|
|
640
641
|
vLetter = 'x';
|
|
@@ -669,6 +670,11 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) {
|
|
|
669
670
|
var pt = {};
|
|
670
671
|
appendArrayPointValue(pt, trace, cdi.i);
|
|
671
672
|
|
|
673
|
+
if(pt.x === undefined) pt.x = isHorizontal ? obj.value : obj.label;
|
|
674
|
+
if(pt.y === undefined) pt.y = isHorizontal ? obj.label : obj.value;
|
|
675
|
+
if(pt.xLabel === undefined) pt.xLabel = isHorizontal ? obj.valueLabel : obj.labelLabel;
|
|
676
|
+
if(pt.yLabel === undefined) pt.yLabel = isHorizontal ? obj.labelLabel : obj.valueLabel;
|
|
677
|
+
|
|
672
678
|
if(isWaterfall) {
|
|
673
679
|
obj.delta = +cdi.rawS || cdi.s;
|
|
674
680
|
obj.deltaLabel = formatNumber(obj.delta);
|
|
@@ -42,6 +42,18 @@ module.exports = extendFlat({
|
|
|
42
42
|
yhoverformat: axisHoverFormat('y'),
|
|
43
43
|
zhoverformat: axisHoverFormat('z', 1),
|
|
44
44
|
hovertemplate: heatmapAttrs.hovertemplate,
|
|
45
|
+
texttemplate: extendFlat({}, heatmapAttrs.texttemplate, {
|
|
46
|
+
description: [
|
|
47
|
+
'For this trace it only has an effect if `coloring` is set to *heatmap*.',
|
|
48
|
+
heatmapAttrs.texttemplate.description
|
|
49
|
+
].join(' ')
|
|
50
|
+
}),
|
|
51
|
+
textfont: extendFlat({}, heatmapAttrs.textfont, {
|
|
52
|
+
description: [
|
|
53
|
+
'For this trace it only has an effect if `coloring` is set to *heatmap*.',
|
|
54
|
+
heatmapAttrs.textfont.description
|
|
55
|
+
].join(' ')
|
|
56
|
+
}),
|
|
45
57
|
hoverongaps: heatmapAttrs.hoverongaps,
|
|
46
58
|
connectgaps: extendFlat({}, heatmapAttrs.connectgaps, {
|
|
47
59
|
description: [
|
|
@@ -7,6 +7,7 @@ var handlePeriodDefaults = require('../scatter/period_defaults');
|
|
|
7
7
|
var handleConstraintDefaults = require('./constraint_defaults');
|
|
8
8
|
var handleContoursDefaults = require('./contours_defaults');
|
|
9
9
|
var handleStyleDefaults = require('./style_defaults');
|
|
10
|
+
var handleHeatmapLabelDefaults = require('../heatmap/label_defaults');
|
|
10
11
|
var attributes = require('./attributes');
|
|
11
12
|
|
|
12
13
|
|
|
@@ -31,8 +32,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
|
|
|
31
32
|
|
|
32
33
|
coerce('text');
|
|
33
34
|
coerce('hovertext');
|
|
34
|
-
coerce('hovertemplate');
|
|
35
35
|
coerce('hoverongaps');
|
|
36
|
+
coerce('hovertemplate');
|
|
36
37
|
|
|
37
38
|
var isConstraint = (coerce('contours.type') === 'constraint');
|
|
38
39
|
coerce('connectgaps', Lib.isArray1D(traceOut.z));
|
|
@@ -43,4 +44,11 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
|
|
|
43
44
|
handleContoursDefaults(traceIn, traceOut, coerce, coerce2);
|
|
44
45
|
handleStyleDefaults(traceIn, traceOut, coerce, layout);
|
|
45
46
|
}
|
|
47
|
+
|
|
48
|
+
if(
|
|
49
|
+
traceOut.contours &&
|
|
50
|
+
traceOut.contours.coloring === 'heatmap'
|
|
51
|
+
) {
|
|
52
|
+
handleHeatmapLabelDefaults(coerce, layout);
|
|
53
|
+
}
|
|
46
54
|
};
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var scatterAttrs = require('../scatter/attributes');
|
|
4
4
|
var baseAttrs = require('../../plots/attributes');
|
|
5
|
+
var fontAttrs = require('../../plots/font_attributes');
|
|
5
6
|
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
|
|
6
7
|
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
|
|
8
|
+
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
|
|
7
9
|
var colorScaleAttrs = require('../../components/colorscale/attributes');
|
|
8
10
|
|
|
9
11
|
var extendFlat = require('../../lib/extend').extendFlat;
|
|
@@ -116,6 +118,20 @@ module.exports = extendFlat({
|
|
|
116
118
|
zhoverformat: axisHoverFormat('z', 1),
|
|
117
119
|
|
|
118
120
|
hovertemplate: hovertemplateAttrs(),
|
|
121
|
+
texttemplate: texttemplateAttrs({
|
|
122
|
+
arrayOk: false,
|
|
123
|
+
editType: 'plot'
|
|
124
|
+
}, {
|
|
125
|
+
keys: ['x', 'y', 'z', 'text']
|
|
126
|
+
}),
|
|
127
|
+
textfont: fontAttrs({
|
|
128
|
+
editType: 'plot',
|
|
129
|
+
autoSize: true,
|
|
130
|
+
autoColor: true,
|
|
131
|
+
colorEditType: 'style',
|
|
132
|
+
description: 'Sets the text font.'
|
|
133
|
+
}),
|
|
134
|
+
|
|
119
135
|
showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false})
|
|
120
136
|
}, {
|
|
121
137
|
transforms: undefined
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var Lib = require('../../lib');
|
|
4
4
|
|
|
5
5
|
var handleXYZDefaults = require('./xyz_defaults');
|
|
6
|
+
var handleHeatmapLabelDefaults = require('./label_defaults');
|
|
6
7
|
var handlePeriodDefaults = require('../scatter/period_defaults');
|
|
7
8
|
var handleStyleDefaults = require('./style_defaults');
|
|
8
9
|
var colorscaleDefaults = require('../../components/colorscale/defaults');
|
|
@@ -28,6 +29,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
|
|
|
28
29
|
coerce('hovertext');
|
|
29
30
|
coerce('hovertemplate');
|
|
30
31
|
|
|
32
|
+
handleHeatmapLabelDefaults(coerce, layout);
|
|
31
33
|
handleStyleDefaults(traceIn, traceOut, coerce, layout);
|
|
32
34
|
|
|
33
35
|
coerce('hoverongaps');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Lib = require('../../lib');
|
|
4
|
+
|
|
5
|
+
module.exports = function handleHeatmapLabelDefaults(coerce, layout) {
|
|
6
|
+
coerce('texttemplate');
|
|
7
|
+
|
|
8
|
+
var fontDflt = Lib.extendFlat({}, layout.font, {
|
|
9
|
+
color: 'auto',
|
|
10
|
+
size: 'auto'
|
|
11
|
+
});
|
|
12
|
+
Lib.coerceFont(coerce, 'textfont', fontDflt);
|
|
13
|
+
};
|