Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 60adfe9

Browse filesBrowse files
authored
Merge pull request plotly#3922 from plotly/histogram2d-single-sample-fix
histogram2d fixes
2 parents f66aff3 + c38673f commit 60adfe9
Copy full SHA for 60adfe9
Expand file treeCollapse file tree

12 files changed

+1742
-160
lines changed

‎src/plots/plots.js

Copy file name to clipboardExpand all lines: src/plots/plots.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2961,7 +2961,10 @@ function sortAxisCategoriesByValue(axList, gd) {
29612961
if(fullTrace.visible !== true) continue;
29622962

29632963
var type = fullTrace.type;
2964-
if(Registry.traceIs(fullTrace, 'histogram')) delete fullTrace._autoBinFinished;
2964+
if(Registry.traceIs(fullTrace, 'histogram')) {
2965+
delete fullTrace._xautoBinFinished;
2966+
delete fullTrace._yautoBinFinished;
2967+
}
29652968

29662969
var cd = gd.calcdata[traceIndex];
29672970
for(k = 0; k < cd.length; k++) {

‎src/traces/heatmap/make_bound_array.js

Copy file name to clipboardExpand all lines: src/traces/heatmap/make_bound_array.js
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,17 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
6262
} else {
6363
var calendar = trace[ax._id.charAt(0) + 'calendar'];
6464

65-
if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) {
66-
v0 = arrayIn[0];
67-
} else if(v0In === undefined) {
68-
v0 = 0;
69-
} else if(isHist || ax.type === 'category' || ax.type === 'multicategory') {
65+
if(isHist) {
7066
v0 = ax.r2c(v0In, 0, calendar);
7167
} else {
72-
v0 = ax.d2c(v0In, 0, calendar);
68+
if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) {
69+
v0 = arrayIn[0];
70+
} else if(v0In === undefined) {
71+
v0 = 0;
72+
} else {
73+
var fn = ax.type === 'log' ? ax.d2c : ax.r2c;
74+
v0 = fn(v0In, 0, calendar);
75+
}
7376
}
7477

7578
dv = dvIn || 1;

‎src/traces/histogram/calc.js

Copy file name to clipboardExpand all lines: src/traces/histogram/calc.js
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) {
232232

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

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

258258
if(trace.visible === true) {
259259
if(isFirstVisible) {
260260
isFirstVisible = false;
261261
} else {
262262
delete tracei._autoBin;
263-
tracei._autoBinFinished = 1;
263+
tracei['_' + mainData + 'autoBinFinished'] = 1;
264264
}
265265
if(Registry.traceIs(tracei, '2dMap')) {
266266
has2dMap = true;
@@ -421,7 +421,7 @@ function handleSingleValueOverlays(gd, trace, pa, mainData, binAttr) {
421421

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

427427
if(isSingleValued) {

‎src/traces/histogram/cross_trace_defaults.js

Copy file name to clipboardExpand all lines: src/traces/histogram/cross_trace_defaults.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) {
106106

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

111112
// N.B. need to coerce *alignmentgroup* before *bingroup*, as traces
112113
// in same alignmentgroup "have to match"

‎src/traces/histogram2d/calc.js

Copy file name to clipboardExpand all lines: src/traces/histogram2d/calc.js
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,13 @@ function getRanges(edges, uniqueVals, gapLow, gapHigh, ax, calendar) {
205205
var i;
206206
var len = edges.length - 1;
207207
var out = new Array(len);
208-
if(uniqueVals) {
209-
for(i = 0; i < len; i++) out[i] = [uniqueVals[i], uniqueVals[i]];
210-
} else {
211-
var roundFn = getBinSpanLabelRound(gapLow, gapHigh, edges, ax, calendar);
212-
for(i = 0; i < len; i++) out[i] = [roundFn(edges[i]), roundFn(edges[i + 1], true)];
208+
var roundFn = getBinSpanLabelRound(gapLow, gapHigh, edges, ax, calendar);
209+
210+
for(i = 0; i < len; i++) {
211+
var v = (uniqueVals || [])[i];
212+
out[i] = v === undefined ?
213+
[roundFn(edges[i]), roundFn(edges[i + 1], true)] :
214+
[v, v];
213215
}
214216
return out;
215217
}
Loading
Loading

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.