Skip to content

Commit dd05c6e

Browse files
committed
calc: add 'placeholder' field in calc traces that have no data pts
- traces with no data points are given a place-holder calc trace to retatin fullData.length === gd.calcdata.length, and make some component (e.g. legend) logic easier - tag these place-holder traces so that the plot modules can easily skip over them
1 parent 52c1b89 commit dd05c6e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/plots/plots.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1669,10 +1669,13 @@ plots.doCalcdata = function(gd, traces) {
16691669
if(_module.calc) cd = _module.calc(gd, trace);
16701670
}
16711671

1672-
// make sure there is a first point
1673-
// this ensures there is a calcdata item for every trace,
1674-
// even if cartesian logic doesn't handle it
1675-
if(!Array.isArray(cd) || !cd[0]) cd = [{x: false, y: false}];
1672+
// Make sure there is a first point.
1673+
// This ensures there is a calcdata item for every trace,
1674+
// even if cartesian logic doesn't handle it (for things like legends).
1675+
// Tag this artificial calc point with 'placeholder: true'
1676+
if(!Array.isArray(cd) || !cd[0]) {
1677+
cd = [{x: false, y: false, placeholder: true}];
1678+
}
16761679

16771680
// add the trace-wide properties to the first point,
16781681
// per point properties to every point

0 commit comments

Comments
 (0)