You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
double-click (i.e auto/reset range) performance. This thing currently goes through editType: 'calc' which is slow as a turtle. I'll try to cache the autorange value somewhere (and clearing it when new data comes in) and use the axrange pathway to speed thing up. This will benefit big data gl and svg graphs too!
Axes.expand (which happens during calc does nothing if the axis isn't autoranged - which can speed up initial drawing but means if you turn on autorange later you don't know whether ax._min/_max are populated. We could either calculate min/max no matter what during calc, or at least stash the arrays & options used to generate them so that when autorange is enabled we can pull it back out and proceed with the calculation without needing to go all the way through calc again.
There would also be some advantages to keeping separate track of each trace / object that called Axes.expand - ie keep a separate _min/_max for each trace/shape/annotation etc. and only combine them when finally calculating the range. That would avoid calc for visibility changes, for example (you'd just have to know to include or not include that object's _min/_max) and for moving annotations/shapes, and down the road would allow calc per trace.
Getting this right will improve double-click axis autorange performance and play an important role in #2358 (faster extendTraces) and other autorange-related improvements (e.g. #387)
Swapping editType: 'calc' for editType: 'plot' in the axis autorange declaration went almost too smoothly. Just one test was falling (apart from tests checking for undefined ax._min and ax._max) :
By this old little test was enough to highlight a pretty important problem with this approach and 'calcIfAutorange' edits - which has the name suggests leads to a calc edit pathway if one or more axis has autorange: true.
For example, scatter marker.size is a 'calcIfAutorange' attribute as it can expand the axis ranges. So consider,
Plotly.newPlot(gd,[{y: [1,2,1]}],{xaxis: {range: [0,2]},yaxis: {range: [0,2]}})// thenPlotly.restyle(gd,'marker.size',30)// thenPlotly.relayout(gd,{'xaxis.autorange': true,'yaxis.autorange': true})// then gd.layout.xaxis.range// (on master) => [-0.18848653667595172, 2.188486536675952]// (with editType: 'plot' autorange) => [0, 2]// i.e. the autorange change doesn't get picked up!
There are a few ways to solve the problem:
🔪 the 'calcIfAutorange' edit type and replace it with 'calc'. This solution is easy to implement, but leads to slower update pathways.
replace 'calcIfAutorange' with something like 'axexpand+plot', that only updates ax._min / ax._max accordingly as opposed to going through the entire calc pathway.
something to 2) but with per-trace update as proposed in the issue description above
Personally, I think speeding up double-click and legend visible trace toggling is more important than keeping marker.size edits and the few other 'calcIfAutorange' attributes (mostly in annotations and shapes) updating fast when the range is set. If some of you disagree, please let me know.
Activity
etpinard commentedon Jul 16, 2018
Swapping
editType: 'calc'foreditType: 'plot'in the axisautorangedeclaration went almost too smoothly. Just one test was falling (apart from tests checking for undefinedax._minandax._max) :plotly.js/test/jasmine/tests/click_test.js
Lines 754 to 789 in 0de19be
By this old little test was enough to highlight a pretty important problem with this approach and 'calcIfAutorange' edits - which has the name suggests leads to a
calcedit pathway if one or more axis hasautorange: true.For example, scatter
marker.sizeis a 'calcIfAutorange' attribute as it can expand the axis ranges. So consider,There are a few ways to solve the problem:
ax._min/ax._maxaccordingly as opposed to going through the entire calc pathway.Personally, I think speeding up double-click and legend
visibletrace toggling is more important than keepingmarker.sizeedits and the few other 'calcIfAutorange' attributes (mostly in annotations and shapes) updating fast when the range is set. If some of you disagree, please let me know.etpinard commentedon Jul 16, 2018
Oh and here are some benchmarks for
Axes.expand(withautorange: true):Scatter at 1e4 pts:
Scattergl at 1e5-1 pts (the worse case before the "mean(marker.size)" approximation):
Scattergl at 1e6 pts:
All in all, I think skipping
Axes.expandduring calc when axis ranges are set is an unnecessary optimization.