From 8600f3ce27c07f54699c37d337804d6b969e1ac4 Mon Sep 17 00:00:00 2001 From: Matthias Matt Date: Tue, 15 Sep 2020 12:43:21 +0200 Subject: [PATCH 1/3] no sorting of point indices --- packages/javascript/plotlywidget/src/Figure.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/javascript/plotlywidget/src/Figure.js b/packages/javascript/plotlywidget/src/Figure.js index a997ae7533..4589001ce5 100644 --- a/packages/javascript/plotlywidget/src/Figure.js +++ b/packages/javascript/plotlywidget/src/Figure.js @@ -919,9 +919,6 @@ var FigureView = widgets.DOMWidgetView.extend({ pointsObject["trace_indexes"][flatPointIndex] = pointObjects[p]["curveNumber"]; } } - 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"]; From 6373184a3f3b5f02707dbdad7551ffed0e9723b1 Mon Sep 17 00:00:00 2001 From: Matthias Matt Date: Tue, 15 Sep 2020 15:39:12 +0200 Subject: [PATCH 2/3] sort indices only if a single trace exists --- .../javascript/plotlywidget/src/Figure.js | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/javascript/plotlywidget/src/Figure.js b/packages/javascript/plotlywidget/src/Figure.js index 4589001ce5..40bfe3734f 100644 --- a/packages/javascript/plotlywidget/src/Figure.js +++ b/packages/javascript/plotlywidget/src/Figure.js @@ -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; @@ -437,14 +437,16 @@ var FigureModel = widgets.DOMWidgetModel.extend( * * This should only happed on FigureModel initialization */ - do_data: function () {}, + do_data: function () { + }, /** * Log changes to the _layout trait * * This should only happed on FigureModel initialization */ - do_layout: function () {}, + do_layout: function () { + }, /** * Handle addTraces message @@ -600,7 +602,7 @@ var FigureModel = widgets.DOMWidgetModel.extend( { serializers: _.extend( { - _data: { deserialize: py2js_deserializer, serialize: js2py_serializer }, + _data: {deserialize: py2js_deserializer, serialize: js2py_serializer}, _layout: { deserialize: py2js_deserializer, serialize: js2py_serializer, @@ -707,7 +709,7 @@ var FigureView = widgets.DOMWidgetView.extend({ // MathJax configuration // --------------------- if (window.MathJax) { - MathJax.Hub.Config({ SVG: { font: "STIX-Web" } }); + MathJax.Hub.Config({SVG: {font: "STIX-Web"}}); } // Get message ids @@ -769,7 +771,7 @@ var FigureView = widgets.DOMWidgetView.extend({ // Emit event indicating that the widget has finished // rendering var event = new CustomEvent("plotlywidget-after-render", { - detail: { element: that.el, viewID: that.viewID }, + detail: {element: that.el, viewID: that.viewID}, }); // Dispatch/Trigger/Fire the event @@ -919,6 +921,18 @@ var FigureView = widgets.DOMWidgetView.extend({ pointsObject["trace_indexes"][flatPointIndex] = pointObjects[p]["curveNumber"]; } } + + 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"]; @@ -1166,7 +1180,8 @@ var FigureView = widgets.DOMWidgetView.extend({ * Stub for future handling of plotly_doubleclick * @param data */ - handle_plotly_doubleclick: function (data) {}, + handle_plotly_doubleclick: function (data) { + }, /** * Handle Plotly.addTraces request From 44d90aa5fb989fda3852b189cc6e9bd9bdf754b0 Mon Sep 17 00:00:00 2001 From: Matthias Matt Date: Tue, 15 Sep 2020 15:46:49 +0200 Subject: [PATCH 3/3] revert changes from automatic code formatting --- packages/javascript/plotlywidget/src/Figure.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/javascript/plotlywidget/src/Figure.js b/packages/javascript/plotlywidget/src/Figure.js index 40bfe3734f..62b301a8ec 100644 --- a/packages/javascript/plotlywidget/src/Figure.js +++ b/packages/javascript/plotlywidget/src/Figure.js @@ -437,16 +437,14 @@ var FigureModel = widgets.DOMWidgetModel.extend( * * This should only happed on FigureModel initialization */ - do_data: function () { - }, + do_data: function () {}, /** * Log changes to the _layout trait * * This should only happed on FigureModel initialization */ - do_layout: function () { - }, + do_layout: function () {}, /** * Handle addTraces message @@ -602,7 +600,7 @@ var FigureModel = widgets.DOMWidgetModel.extend( { serializers: _.extend( { - _data: {deserialize: py2js_deserializer, serialize: js2py_serializer}, + _data: { deserialize: py2js_deserializer, serialize: js2py_serializer }, _layout: { deserialize: py2js_deserializer, serialize: js2py_serializer, @@ -709,7 +707,7 @@ var FigureView = widgets.DOMWidgetView.extend({ // MathJax configuration // --------------------- if (window.MathJax) { - MathJax.Hub.Config({SVG: {font: "STIX-Web"}}); + MathJax.Hub.Config({ SVG: { font: "STIX-Web" } }); } // Get message ids @@ -771,7 +769,7 @@ var FigureView = widgets.DOMWidgetView.extend({ // Emit event indicating that the widget has finished // rendering var event = new CustomEvent("plotlywidget-after-render", { - detail: {element: that.el, viewID: that.viewID}, + detail: { element: that.el, viewID: that.viewID }, }); // Dispatch/Trigger/Fire the event @@ -1180,8 +1178,7 @@ var FigureView = widgets.DOMWidgetView.extend({ * Stub for future handling of plotly_doubleclick * @param data */ - handle_plotly_doubleclick: function (data) { - }, + handle_plotly_doubleclick: function (data) {}, /** * Handle Plotly.addTraces request