8000 Fix rangebreaks on heatmap with 2d z array by archmoj · Pull Request #4821 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Fix rangebreaks on heatmap with 2d z array #4821

New issue 8000

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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
remove BADNUMs i.e. rangebreak gaps from heatmap trace.x & y and drop…
… z values from the array
  • Loading branch information
archmoj committed May 7, 2020
commit 9051ab67178e3beea710701750215f2eff8c9747
33 changes: 33 additions & 0 deletions src/traces/heatmap/calc.js
Original file line number Diff line number Diff line change
C6B0 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;
}
0