Skip to content

Commit 55c4b35

Browse files
authoredJan 18, 2018
Merge pull request #2264 from plotly/candlestick-hover-label-regression
Candlestick hover label fix
2 parents 41fc131 + 281598d commit 55c4b35

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed
 

‎src/traces/box/calc.js

+5
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ module.exports = function calc(gd, trace) {
136136
}
137137
};
138138

139+
// don't show labels in candlestick hover labels
140+
if(trace._fullInput && trace._fullInput.type === 'candlestick') {
141+
delete cd[0].t.labels;
142+
}
143+
139144
fullLayout[numKey]++;
140145
return cd;
141146
} else {

‎src/traces/box/hover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function hoverOnBoxes(pointData, xval, yval, hovermode) {
159159

160160
pointData2[vLetter + '0'] = pointData2[vLetter + '1'] = valPx;
161161
pointData2[vLetter + 'LabelVal'] = val;
162-
pointData2[vLetter + 'Label'] = t.labels[attr] + ' ' + Axes.hoverLabelText(vAxis, val);
162+
pointData2[vLetter + 'Label'] = (t.labels ? t.labels[attr] + ' ' : '') + Axes.hoverLabelText(vAxis, val);
163163

164164
if(attr === 'mean' && ('sd' in di) && trace.boxmean === 'sd') {
165165
pointData2[vLetter + 'err'] = di.sd;

‎test/jasmine/tests/finance_test.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -384,16 +384,19 @@ describe('finance charts calc transforms:', function() {
384384
return calcTrace[0].trace;
385385
}
386386

387-
function _calc(data, layout) {
387+
function _calcRaw(data, layout) {
388388
var gd = {
389389
data: data,
390390
layout: layout || {}
391391
};
392392

393393
supplyAllDefaults(gd);
394394
Plots.doCalcdata(gd);
395+
return gd.calcdata;
396+
}
395397

396-
return gd.calcdata.map(calcDatatoTrace);
398+
function _calc(data, layout) {
399+
return _calcRaw(data, layout).map(calcDatatoTrace);
397400
}
398401

399402
// add some points that shouldn't make it into calcdata because
@@ -758,6 +761,15 @@ describe('finance charts calc transforms:', function() {
758761
2, 2, 2, 2, 2, 2
759762
]);
760763
});
764+
765+
it('should not include box hover labels prefix in candlestick calcdata', function() {
766+
var trace0 = Lib.extendDeep({}, mock0, {
767+
type: 'candlestick',
768+
});
769+
var out = _calcRaw([trace0]);
770+
771+
expect(out[0][0].t.labels).toBeUndefined();
772+
});
761773
});
762774

763775
describe('finance charts updates:', function() {

0 commit comments

Comments
 (0)
Please sign in to comment.