Skip to content

Histogram events & bin hover label improvements #2113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/traces/bar/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
pointData[posLetter + '0'] = pa.c2p(minPos(di), true);
pointData[posLetter + '1'] = pa.c2p(maxPos(di), true);
pointData[posLetter + 'LabelVal'] = di.p;
// for histograms
if(di.p0 !== undefined && di.p1 !== undefined) {
pointData[posLetter + 'LabelVal0'] = di.p0;
pointData[posLetter + 'LabelVal1'] = di.p1;
}

// for histograms
if(di.pts) pointData.pts = di.pts;

fillHoverText(di, trace, pointData);
ErrorBars.hoverInfo(di, trace, pointData);
Expand Down
29 changes: 29 additions & 0 deletions src/traces/histogram/hover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var barHover = require('../bar/hover');

module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very very nice.

var pts = barHover(pointData, xval, yval, hovermode);

if(!pts) return;

pointData = pts[0];
var di = pointData.cd[pointData.index];

var posLetter = pointData.cd[0].trace.orientation === 'h' ? 'y' : 'x';

pointData[posLetter + 'LabelVal0'] = di.p0;
pointData[posLetter + 'LabelVal1'] = di.p1;
pointData.pts = di.pts;

return pts;
};
2 changes: 1 addition & 1 deletion src/traces/histogram/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Histogram.setPositions = require('../bar/set_positions');
Histogram.plot = require('../bar/plot');
Histogram.style = require('../bar/style');
Histogram.colorbar = require('../scatter/colorbar');
Histogram.hoverPoints = require('../bar/hover');
Histogram.hoverPoints = require('./hover');
Histogram.selectPoints = require('../bar/select');
Histogram.eventData = require('./event_data');

Expand Down