Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e1716c7

Browse files
committed
heatmap: reorder data based on categoryarray
1 parent adf9bee commit e1716c7

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/traces/heatmap/calc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module.exports = function calc(gd, trace) {
7171
y0 = trace.y0;
7272
dy = trace.dy;
7373

74-
z = clean2dArray(zIn, trace.transpose);
74+
z = clean2dArray(zIn, trace.transpose, trace, xa, ya);
7575

7676
if(isContour || trace.connectgaps) {
7777
trace._emptypoints = findEmpties(z);

src/traces/heatmap/clean_2d_array.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
var isNumeric = require('fast-isnumeric');
1212

13-
module.exports = function clean2dArray(zOld, transpose) {
13+
module.exports = function clean2dArray(zOld, transpose, trace, xa, ya) {
1414
var rowlen, collen, getCollen, old2new, i, j;
1515

1616
function cleanZvalue(v) {
@@ -30,12 +30,21 @@ module.exports = function clean2dArray(zOld, transpose) {
3030
old2new = function(zOld, i, j) { return zOld[i][j]; };
3131
}
3232

33+
var xMap = function(i) {return i;};
34+
var yMap = function(i) {return i;};
35+
if(ya.type === 'category') {
36+
yMap = function(i) {return ya._categoriesMap[trace.y[i]];};
37+
}
38+
if(xa.type === 'category') {
39+
xMap = function(i) {return xa._categoriesMap[trace.x[i]];};
40+
}
41+
3342
var zNew = new Array(rowlen);
3443

3544
for(i = 0; i < rowlen; i++) {
3645
collen = getCollen(zOld, i);
3746
zNew[i] = new Array(collen);
38-
for(j = 0; j < collen; j++) zNew[i][j] = cleanZvalue(old2new(zOld, i, j));
47+
for(j = 0; j < collen; j++) zNew[i][j] = cleanZvalue(old2new(zOld, yMap(i), xMap(j)));
3948
}
4049

4150
return zNew;

0 commit comments

Comments
 (0)