Skip to content

histogram2d fixes #3922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 9 additions & 6 deletions src/traces/heatmap/make_bound_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,17 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
} else {
var calendar = trace[ax._id.charAt(0) + 'calendar'];

if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) {
v0 = arrayIn[0];
} else if(v0In === undefined) {
v0 = 0;
} else if(isHist || ax.type === 'category' || ax.type === 'multicategory') {
if(isHist) {
v0 = ax.r2c(v0In, 0, calendar);
} else {
v0 = ax.d2c(v0In, 0, calendar);
if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) {
v0 = arrayIn[0];
} else if(v0In === undefined) {
v0 = 0;
} else {
var fn = ax.type === 'log' ? ax.d2c : ax.r2c;
v0 = fn(v0In, 0, calendar);
}
}

dv = dvIn || 1;
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']) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixup from #3909

As now both histogram and histogram2d* traces go through calcAllAutoBins, we need to split the "has autoBin finished` logic into x and y values.

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
12 changes: 7 additions & 5 deletions src/traces/histogram2d/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,13 @@ function getRanges(edges, uniqueVals, gapLow, gapHigh, ax, calendar) {
var i;
var len = edges.length - 1;
var out = new Array(len);
if(uniqueVals) {
for(i = 0; i < len; i++) out[i] = [uniqueVals[i], uniqueVals[i]];
} else {
var roundFn = getBinSpanLabelRound(gapLow, gapHigh, edges, ax, calendar);
for(i = 0; i < len; i++) out[i] = [roundFn(edges[i]), roundFn(edges[i + 1], true)];
var roundFn = getBinSpanLabelRound(gapLow, gapHigh, edges, ax, calendar);

for(i = 0; i < len; i++) {
var v = (uniqueVals || [])[i];
out[i] = v === undefined ?
[roundFn(edges[i]), roundFn(edges[i + 1], true)] :
[v, v];
}
return out;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading