Skip to content

Commit 6036045

Browse files
committed
ohlc: don't force hovermode: 'closest'
- the default hovermode: 'x' now looks good after adding transformed hover text
1 parent f6f072f commit 6036045

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/traces/candlestick/transform.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ exports.transform = function transform(dataIn, state) {
4242
);
4343
}
4444

45-
// add a few layout features
46-
var layout = state.layout;
47-
helpers.addRangeSlider(layout);
45+
helpers.addRangeSlider(state.layout);
4846

4947
return dataOut;
5048
};

src/traces/ohlc/transform.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ exports.transform = function transform(dataIn, state) {
4444
);
4545
}
4646

47-
// add a few layout features
48-
var layout = state.layout;
49-
if(!layout.hovermode) layout.hovermode = 'closest';
50-
helpers.addRangeSlider(layout);
47+
helpers.addRangeSlider(state.layout);
5148

5249
return dataOut;
5350
};
@@ -96,7 +93,15 @@ function makeTrace(traceIn, state, direction) {
9693
return traceOut;
9794
}
9895

99-
// let scatter hoverPoint format 'x' coordinates, if desired
96+
// Let scatter hoverPoint format 'x' coordinates, if desired.
97+
//
98+
// Note that, this solution isn't perfect: it shows open and close
99+
// values at slightly different 'x' coordinates then the rest of the
100+
// segments, but is for more robust than calling `Axes.tickText` during
101+
// calcTransform.
102+
//
103+
// A future iteration should perhaps try to add a hook for transforms in
104+
// the hoverPoints handlers.
100105
function makeHoverInfo(traceIn) {
101106
var hoverinfo = traceIn.hoverinfo;
102107

test/jasmine/tests/finance_test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ describe('finance charts defaults:', function() {
251251

252252
var out0 = _supply([trace0], layout0);
253253

254-
expect(out0.layout.hovermode).toEqual('closest');
255-
expect(out0._fullLayout.hovermode).toEqual('closest');
256254
expect(out0.layout.xaxis.rangeslider).toBeDefined();
257255
expect(out0._fullLayout.xaxis.rangeslider.visible).toBe(true);
258256

0 commit comments

Comments
 (0)