Skip to content

Commit

Permalink
generalize _autoBinFinished for histogram2d
Browse files Browse the repository at this point in the history
- this fixes some shared histogram2d (via bingroup) edge cases
- this fixes a performance regression from #3845
  • Loading branch information
etpinard committed May 29, 2019
1 parent 6a8baf9 commit 401029a
Show file tree
Hide file tree
Showing 6 changed files with 769 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -2961,7 +2961,10 @@ function sortAxisCategoriesByValue(axList, gd) {
if(fullTrace.visible !== true) continue;

var type = fullTrace.type;
if(Registry.traceIs(fullTrace, 'histogram')) delete fullTrace._autoBinFinished;
if(Registry.traceIs(fullTrace, 'histogram')) {
delete fullTrace._xautoBinFinished;
delete fullTrace._yautoBinFinished;
}

var cd = gd.calcdata[traceIndex];
for(k = 0; k < cd.length; k++) {
Expand Down
10 changes: 5 additions & 5 deletions src/traces/histogram/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) {

// all but the first trace in this group has already been marked finished
// clear this flag, so next time we run calc we will run autobin again
if(trace._autoBinFinished) {
delete trace._autoBinFinished;
if(trace['_' + mainData + 'autoBinFinished']) {
delete trace['_' + mainData + 'autoBinFinished'];
} else {
traces = binOpts.traces;
var allPos = [];
Expand All @@ -253,14 +253,14 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) {
pos0 = tracei['_' + mainDatai + 'pos0'] = pa.makeCalcdata(tracei, mainDatai);

allPos = Lib.concat(allPos, pos0);
delete tracei._autoBinFinished;
delete tracei['_' + mainData + 'autoBinFinished'];

if(trace.visible === true) {
if(isFirstVisible) {
isFirstVisible = false;
} else {
delete tracei._autoBin;
tracei._autoBinFinished = 1;
tracei['_' + mainData + 'autoBinFinished'] = 1;
}
if(Registry.traceIs(tracei, '2dMap')) {
has2dMap = true;
Expand Down Expand Up @@ -421,7 +421,7 @@ function handleSingleValueOverlays(gd, trace, pa, mainData, binAttr) {

// so we can use this result when we get to tracei in the normal
// course of events, mark it as done and put _pos0 back
tracei._autoBinFinished = 1;
tracei['_' + mainData + 'autoBinFinished'] = 1;
tracei['_' + mainData + 'pos0'] = resulti[1];

if(isSingleValued) {
Expand Down
3 changes: 2 additions & 1 deletion src/traces/histogram/cross_trace_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) {

// TODO: this shouldn't be relinked as it's only used within calc
// https://github.com/plotly/plotly.js/issues/749
delete traceOut._autoBinFinished;
delete traceOut._xautoBinFinished;
delete traceOut._yautoBinFinished;

// N.B. need to coerce *alignmentgroup* before *bingroup*, as traces
// in same alignmentgroup "have to match"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 401029a

Please sign in to comment.