Skip to content

Commit

Permalink
Fix selection of histograms with multiple traces (#2771)
Browse files Browse the repository at this point in the history
* sort indices only if a single trace exists
  • Loading branch information
meffmadd authored Apr 23, 2021
1 parent f18576b commit b343fcc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/javascript/plotlywidget/src/Figure.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var widgets = require("@jupyter-widgets/base");
var _ = require("lodash");

window.PlotlyConfig = { MathJaxConfig: "local" };
window.PlotlyConfig = {MathJaxConfig: "local"};
var Plotly = require("plotly.js/dist/plotly");
var semver_range = "^" + require("../package.json").version;

Expand Down Expand Up @@ -919,9 +919,18 @@ var FigureView = widgets.DOMWidgetView.extend({
pointsObject["trace_indexes"][flatPointIndex] = pointObjects[p]["curveNumber"];
}
}
pointsObject["point_indexes"].sort(function(a, b) {
return a - b;
});

let single_trace = true;
for (let i = 1; i < numPointNumbers; i++) {
single_trace = single_trace && (pointsObject["trace_indexes"][i - 1] === pointsObject["trace_indexes"][i])
if (!single_trace) break;
}
if (single_trace) {
pointsObject["point_indexes"].sort((function (a, b) {
return a - b
}))
}

} else {
for (var p = 0; p < numPoints; p++) {
pointsObject["trace_indexes"][p] = pointObjects[p]["curveNumber"];
Expand Down

0 comments on commit b343fcc

Please sign in to comment.