Skip to content

Commit e68c170

Browse files
committed
categorical 2dMap: fill missing category in input data with undefined
1 parent ae3ecf5 commit e68c170

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/traces/heatmap/clean_2d_array.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ module.exports = function clean2dArray(zOld, trace, xa, ya) {
3131
old2new = function(zOld, i, j) { return zOld[i][j]; };
3232
}
3333

34+
var padOld2new = function(zOld, i, j) {
35+
if(i === undefined || j === undefined) return undefined;
36+
return old2new(zOld, i, j);
37+
};
38+
3439
function axisMapping(ax) {
3540
if(trace && trace.type !== 'carpet' && trace.type !== 'contourcarpet' &&
3641
ax && ax.type === 'category' && trace['_' + ax._id.charAt(0)].length) {
@@ -51,10 +56,13 @@ module.exports = function clean2dArray(zOld, trace, xa, ya) {
5156

5257
if(ya && ya.type === 'category') rowlen = ya._categories.length;
5358
for(i = 0; i < rowlen; i++) {
54-
collen = getCollen(zOld, i);
55-
if(xa && xa.type === 'category') collen = xa._categories.length;
59+
if(xa && xa.type === 'category') {
60+
collen = xa._categories.length;
61+
} else {
62+
collen = getCollen(zOld, i);
63+
}
5664
zNew[i] = new Array(collen);
57-
for(j = 0; j < collen; j++) zNew[i][j] = cleanZvalue(old2new(zOld, yMap(i), xMap(j)));
65+
for(j = 0; j < collen; j++) zNew[i][j] = cleanZvalue(padOld2new(zOld, yMap(i), xMap(j)));
5866
}
5967

6068
return zNew;

0 commit comments

Comments
 (0)