Skip to content

Commit

Permalink
address N = 1 and len < N cases
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-matteson committed Jan 19, 2024
1 parent b9954f0 commit 8be6a41
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/traces/heatmap/make_bound_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
// contour plots only want the centers
if(isContour || isGL2D) arrayOut = Array.from(arrayIn).slice(0, numbricks);
else if(numbricks === 1) {
arrayOut = [arrayIn[0] - 0.5, arrayIn[0] + 0.5];
if(ax.type === 'log') {
arrayOut = [0.5 * arrayIn[0], 2 * arrayIn[0]];
} else {
arrayOut = [arrayIn[0] - 0.5, arrayIn[0] + 0.5];
}
} else if(ax.type === 'log') {
arrayOut = [Math.pow(arrayIn[0], 1.5) / Math.pow(arrayIn[1], 0.5)];

Expand All @@ -47,11 +51,21 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,

if(len < numbricks) {
var lastPt = arrayOut[arrayOut.length - 1];
var delta = lastPt - arrayOut[arrayOut.length - 2];
var delta; // either multiplicative delta (log axis type) or arithmetic delta (all other axis types)
if(ax.type === 'log') {
delta = lastPt / arrayOut[arrayOut.length - 2];

for(i = len; i < numbricks; i++) {
lastPt *= delta;
arrayOut.push(lastPt);
}
} else {
delta = lastPt - arrayOut[arrayOut.length - 2];

for(i = len; i < numbricks; i++) {
lastPt += delta;
arrayOut.push(lastPt);
for(i = len; i < numbricks; i++) {
lastPt += delta;
arrayOut.push(lastPt);
}
}
}
} else {
Expand Down

0 comments on commit 8be6a41

Please sign in to comment.