Skip to content

Fix rangebreaks on heatmap with 2d z array #4821

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 6 commits into from
May 11, 2020
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
33 changes: 33 additions & 0 deletions src/traces/heatmap/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var clean2dArray = require('./clean_2d_array');
var interp2d = require('./interp2d');
var findEmpties = require('./find_empties');
var makeBoundArray = require('./make_bound_array');
var BADNUM = require('../../constants/numerical').BADNUM;

module.exports = function calc(gd, trace) {
// prepare the raw data
Expand Down Expand Up @@ -71,6 +72,12 @@ module.exports = function calc(gd, trace) {

z = clean2dArray(zIn, trace, xa, ya);

if(xa.rangebreaks || ya.rangebreaks) {
z = dropZonBreaks(z, trace);
x = trace._x = skipBreaks(trace._x);
y = trace._y = skipBreaks(trace._y);
}

if(isContour || trace.connectgaps) {
trace._emptypoints = findEmpties(z);
interp2d(z, trace._emptypoints);
Expand Down Expand Up @@ -156,3 +163,29 @@ module.exports = function calc(gd, trace) {

return [cd0];
};

function skipBreaks(a) {
var b = [];
var len = a.length;
for(var i = 0; i < len; i++) {
var v = a[i];
if(v !== BADNUM) b.push(v);
}
return b;
}

function dropZonBreaks(z, trace) {
var newZ = [];
var k = -1;
for(var i = 0; i < z.length; i++) {
if(trace._y[i] === BADNUM) continue;
k++;
newZ[k] = [];
for(var j = 0; j < z[i].length; j++) {
if(trace._x[j] === BADNUM) continue;

newZ[k].push(z[i][j]);
}
}
return newZ;
}
11 changes: 7 additions & 4 deletions src/traces/heatmap/convert_column_xyz.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,21 @@ module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name,
var text;
var hovertext;

var nI = col2vals.length;
var nJ = col1vals.length;

for(i = 0; i < arrayVarNames.length; i++) {
newArrays[i] = Lib.init2dArray(col2vals.length, col1vals.length);
newArrays[i] = Lib.init2dArray(nI, nJ);
}

if(hasColumnText) {
text = Lib.init2dArray(col2vals.length, col1vals.length);
text = Lib.init2dArray(nI, nJ);
}
if(hasColumnHoverText) {
hovertext = Lib.init2dArray(col2vals.length, col1vals.length);
hovertext = Lib.init2dArray(nI, nJ);
}

var after2before = Lib.init2dArray(col2vals.length, col1vals.length);
var after2before = Lib.init2dArray(nI, nJ);

for(i = 0; i < colLen; i++) {
if(col1[i] !== BADNUM && col2[i] !== BADNUM) {
Expand Down
Binary file added test/image/baselines/axes_breaks-contour1d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/axes_breaks-contour2d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/axes_breaks-heatmap1d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/axes_breaks-heatmap2d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading