Skip to content

Commit

Permalink
Rename hoveron to hoverlabel.split.
Browse files Browse the repository at this point in the history
  • Loading branch information
codrut3 committed Sep 27, 2018
1 parent 4866dc4 commit 4622752
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/traces/candlestick/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ module.exports = {
text: OHLCattrs.text,
whiskerwidth: extendFlat({}, boxAttrs.whiskerwidth, { dflt: 0 }),

hoveron: OHLCattrs.hoveron,
hoverlabel: OHLCattrs.hoverlabel,
};
24 changes: 13 additions & 11 deletions src/traces/ohlc/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
var extendFlat = require('../../lib').extendFlat;
var scatterAttrs = require('../scatter/attributes');
var dash = require('../../components/drawing/attributes').dash;
var fxAttrs = require('../../components/fx/attributes');

var INCREASING_COLOR = '#3D9970';
var DECREASING_COLOR = '#FF4136';
Expand Down Expand Up @@ -117,15 +118,16 @@ module.exports = {
].join(' ')
},

hoveron: {
valType: 'flaglist',
flags: ['ohlc', 'points'],
dflt: 'points',
role: 'info',
editType: 'style',
description: [
'Do the hover effects show info in separate tooltips',
'or a single tooltip?'
].join(' ')
},
hoverlabel: extendFlat({}, fxAttrs.hoverlabel, {
split: {
valType: 'boolean',
role: 'info',
dflt: false,
editType: 'style',
description: [
'Show hover information (open, close, high, low) in',
'separate labels.'
].join(' ')
}
}),
};
14 changes: 5 additions & 9 deletions src/traces/ohlc/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ var DIRSYMBOL = {
function hoverPoints(pointData, xval, yval, hovermode) {
var cd = pointData.cd;
var trace = cd[0].trace;
var hoveron = trace.hoveron;

if(hoveron.indexOf('ohlc') !== -1) {
return hoverOnOhlc(pointData, xval, yval, hovermode);
}
else if(hoveron.indexOf('points') !== -1) {
return hoverOnPoints(pointData, xval, yval, hovermode);
if(trace.hoverlabel.split) {
return hoverSplit(pointData, xval, yval, hovermode);
}

return [];
return hoverOnPoints(pointData, xval, yval, hovermode);
}

function getClosestPoint(pointData, xval, yval, hovermode) {
Expand Down Expand Up @@ -94,7 +90,7 @@ function getClosestPoint(pointData, xval, yval, hovermode) {
return pointData;
}

function hoverOnOhlc(pointData, xval, yval, hovermode) {
function hoverSplit(pointData, xval, yval, hovermode) {
var cd = pointData.cd;
var ya = pointData.ya;
var trace = cd[0].trace;
Expand Down Expand Up @@ -197,6 +193,6 @@ function hoverOnPoints(pointData, xval, yval, hovermode) {

module.exports = {
hoverPoints: hoverPoints,
hoverOnOhlc: hoverOnOhlc,
hoverSplit: hoverSplit,
hoverOnPoints: hoverOnPoints
};
2 changes: 1 addition & 1 deletion src/traces/ohlc/ohlc_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function handleOHLC(traceIn, traceOut, coerce, layout) {
var low = coerce('low');
var close = coerce('close');

coerce('hoveron');
coerce('hoverlabel');

var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults');
handleCalendarDefaults(traceIn, traceOut, ['x'], layout);
Expand Down
6 changes: 4 additions & 2 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1054,11 +1054,13 @@ describe('hover info', function() {
.then(done);
});

it('shows correct labels in ohlc mode', function(done) {
it('shows correct labels in split mode', function(done) {
var pts;
Plotly.plot(gd, financeMock({
customdata: [11, 22, 33],
hoveron: 'ohlc'
hoverlabel: {
split: true
}
}))
.then(function() {
gd.on('plotly_hover', function(e) { pts = e.points; });
Expand Down

0 comments on commit 4622752

Please sign in to comment.