Skip to content

Commit b91d1cb

Browse files
committed
exclude CDFs from new histogram event & label features
1 parent 6b74fbe commit b91d1cb

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

src/traces/histogram/calc.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,19 @@ module.exports = function calc(gd, trace) {
171171
var cdi = {
172172
p: pos[i],
173173
s: size[i],
174-
b: 0,
175-
pts: inputPoints[i]
174+
b: 0
176175
};
177-
if(uniqueValsPerBin) {
178-
cdi.p0 = cdi.p1 = (inputPoints[i].length) ? pos0[inputPoints[i][0]] : pos[i];
179-
}
180-
else {
181-
cdi.p0 = roundFn(binEdges[i]);
182-
cdi.p1 = roundFn(binEdges[i + 1], true);
176+
177+
// pts and p0/p1 don't seem to make much sense for cumulative distributions
178+
if(!cumulativeSpec.enabled) {
179+
cdi.pts = inputPoints[i];
180+
if(uniqueValsPerBin) {
181+
cdi.p0 = cdi.p1 = (inputPoints[i].length) ? pos0[inputPoints[i][0]] : pos[i];
182+
}
183+
else {
184+
cdi.p0 = roundFn(binEdges[i]);
185+
cdi.p1 = roundFn(binEdges[i + 1], true);
186+
}
183187
}
184188
cd.push(cdi);
185189
}

src/traces/histogram/event_data.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ module.exports = function eventData(out, pt) {
1818
out.yaxis = pt.ya;
1919

2020
// specific to histogram
21-
out.pointNumbers = pt.pts;
22-
out.binNumber = out.pointNumber;
23-
delete out.pointNumber;
21+
// CDFs do not have pts (yet?)
22+
if(pt.pts) {
23+
out.pointNumbers = pt.pts;
24+
out.binNumber = out.pointNumber;
25+
delete out.pointNumber;
26+
}
2427

2528
return out;
2629
};

src/traces/histogram/hover.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
1818

1919
pointData = pts[0];
2020
var di = pointData.cd[pointData.index];
21+
var trace = pointData.cd[0].trace;
2122

22-
var posLetter = pointData.cd[0].trace.orientation === 'h' ? 'y' : 'x';
23+
if(!trace.cumulative.enabled) {
24+
var posLetter = trace.orientation === 'h' ? 'y' : 'x';
2325

24-
pointData[posLetter + 'LabelVal0'] = di.p0;
25-
pointData[posLetter + 'LabelVal1'] = di.p1;
26-
pointData.pts = di.pts;
26+
pointData[posLetter + 'LabelVal0'] = di.p0;
27+
pointData[posLetter + 'LabelVal1'] = di.p1;
28+
pointData.pts = di.pts;
29+
}
2730

2831
return pts;
2932
};

0 commit comments

Comments
 (0)