Skip to content

Commit

Permalink
Closes #3497: Show correct values on hover of scatterplot.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marina Samuel committed Mar 12, 2019
1 parent 5943bf0 commit 5af8294
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/app/visualizations/chart/plotly/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ export function prepareLayout(element, seriesList, options, data) {
if (options.globalSeriesType === 'box') {
result.boxmode = 'group';
result.boxgroupgap = 0.50;
} else if (options.globalSeriesType === 'scatter') {
result.hovermode = 'closest';
}

result.xaxis = {
Expand Down Expand Up @@ -635,14 +637,15 @@ function updateSeriesText(seriesList, options) {
series.text = [];
series.hover = [];
const xValues = (options.globalSeriesType === 'pie') ? series.labels : series.x;
xValues.forEach((x) => {
xValues.forEach((x, i) => {
const text = {
'@@name': series.name,
// '@@x' is already in `item.$raw`
};
const item = series.sourceData.get(x);
const yVal = series.y ? series.y[i] : item.y;
if (item) {
text['@@y'] = includes(['bubble', 'scatter'], seriesOptions.type) ? item.y : series.formatNumber(item.y);
text['@@y'] = includes(['bubble', 'scatter'], seriesOptions.type) ? yVal : series.formatNumber(item.y);
if (item.yError !== undefined) {
text['@@yError'] = series.formatNumber(item.yError);
}
Expand Down

0 comments on commit 5af8294

Please sign in to comment.