diff --git a/src/traces/heatmap/calc.js b/src/traces/heatmap/calc.js index ac92da9dd86..0f8f0c50f95 100644 --- a/src/traces/heatmap/calc.js +++ b/src/traces/heatmap/calc.js @@ -71,19 +71,25 @@ module.exports = function calc(gd, trace) { dy = trace.dy; 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(xa.rangebreaks || ya.rangebreaks) { + z = dropZonBreaks(x, y, z); + + if(!isHist) { + x = skipBreaks(x); + y = skipBreaks(y); - if(isContour || trace.connectgaps) { - trace._emptypoints = findEmpties(z); - interp2d(z, trace._emptypoints); + trace._x = x; + trace._y = y; } } + if(!isHist && (isContour || trace.connectgaps)) { + trace._emptypoints = findEmpties(z); + interp2d(z, trace._emptypoints); + } + function noZsmooth(msg) { zsmooth = trace._input.zsmooth = trace.zsmooth = false; Lib.warn('cannot use zsmooth: "fast": ' + msg); @@ -174,15 +180,15 @@ function skipBreaks(a) { return b; } -function dropZonBreaks(z, trace) { +function dropZonBreaks(x, y, z) { var newZ = []; var k = -1; for(var i = 0; i < z.length; i++) { - if(trace._y[i] === BADNUM) continue; + if(y[i] === BADNUM) continue; k++; newZ[k] = []; for(var j = 0; j < z[i].length; j++) { - if(trace._x[j] === BADNUM) continue; + if(x[j] === BADNUM) continue; newZ[k].push(z[i][j]); } diff --git a/test/image/baselines/axes_breaks-histogram2d.png b/test/image/baselines/axes_breaks-histogram2d.png new file mode 100644 index 00000000000..a822bcc8528 Binary files /dev/null and b/test/image/baselines/axes_breaks-histogram2d.png differ diff --git a/test/image/mocks/axes_breaks-histogram2d.json b/test/image/mocks/axes_breaks-histogram2d.json new file mode 100644 index 00000000000..c9cf100821d --- /dev/null +++ b/test/image/mocks/axes_breaks-histogram2d.json @@ -0,0 +1,491 @@ +{ + "data": [{ + "type": "histogram2d", + "x": [ + "2020-01-02 17:00", + "2020-01-02 17:10", + "2020-01-02 17:20", + "2020-01-02 17:30", + "2020-01-02 17:40", + "2020-01-02 17:50", + "2020-01-02 18:00", + "2020-01-02 18:10", + "2020-01-02 18:20", + "2020-01-02 18:30", + "2020-01-02 18:40", + "2020-01-02 18:50", + "2020-01-02 19:00", + "2020-01-02 19:10", + "2020-01-02 19:20", + "2020-01-02 19:30", + "2020-01-02 19:40", + "2020-01-02 19:50", + "2020-01-02 20:00", + "2020-01-02 20:10", + "2020-01-02 20:20", + "2020-01-02 20:30", + "2020-01-02 20:40", + "2020-01-02 20:50", + "2020-01-02 21:00", + "2020-01-02 21:10", + "2020-01-02 21:20", + "2020-01-02 21:30", + "2020-01-02 21:40", + "2020-01-02 21:50", + "2020-01-02 22:00", + "2020-01-02 22:10", + "2020-01-02 22:20", + "2020-01-02 22:30", + "2020-01-02 22:40", + "2020-01-02 22:50", + "2020-01-02 23:00", + "2020-01-02 23:10", + "2020-01-02 23:20", + "2020-01-02 23:30", + "2020-01-02 23:40", + "2020-01-02 23:50", + "2020-01-03 00:00", + "2020-01-03 00:10", + "2020-01-03 00:20", + "2020-01-03 00:30", + "2020-01-03 00:40", + "2020-01-03 00:50", + "2020-01-03 01:00", + "2020-01-03 01:10", + "2020-01-03 01:20", + "2020-01-03 01:30", + "2020-01-03 01:40", + "2020-01-03 01:50", + "2020-01-03 02:00", + "2020-01-03 02:10", + "2020-01-03 02:20", + "2020-01-03 02:30", + "2020-01-03 02:40", + "2020-01-03 02:50", + "2020-01-03 03:00", + "2020-01-03 03:10", + "2020-01-03 03:20", + "2020-01-03 03:30", + "2020-01-03 03:40", + "2020-01-03 03:50", + "2020-01-03 04:00", + "2020-01-03 04:10", + "2020-01-03 04:20", + "2020-01-03 04:30", + "2020-01-03 04:40", + "2020-01-03 04:50", + "2020-01-03 05:00", + "2020-01-03 05:10", + "2020-01-03 05:20", + "2020-01-03 05:30", + "2020-01-03 05:40", + "2020-01-03 05:50", + "2020-01-03 06:00", + "2020-01-03 06:10", + "2020-01-03 06:20", + "2020-01-03 06:30", + "2020-01-03 06:40", + "2020-01-03 06:50", + "2020-01-03 07:00", + "2020-01-03 07:10", + "2020-01-03 07:20", + "2020-01-03 07:30", + "2020-01-03 07:40", + "2020-01-03 07:50", + "2020-01-03 08:00", + "2020-01-03 08:10", + "2020-01-03 08:20", + "2020-01-03 08:30", + "2020-01-03 08:40", + "2020-01-03 08:50", + "2020-01-03 09:00", + "2020-01-03 09:10", + "2020-01-03 09:20", + "2020-01-03 09:30", + "2020-01-03 09:40", + "2020-01-03 09:50", + + "2020-01-02 17:00", + "2020-01-02 17:10", + "2020-01-02 17:20", + "2020-01-02 17:30", + "2020-01-02 17:40", + "2020-01-02 17:50", + "2020-01-02 18:00", + "2020-01-02 18:10", + "2020-01-02 18:20", + "2020-01-02 18:30", + "2020-01-02 18:40", + "2020-01-02 18:50", + "2020-01-02 19:00", + "2020-01-02 19:10", + "2020-01-02 19:20", + "2020-01-02 19:30", + "2020-01-02 19:40", + "2020-01-02 19:50", + "2020-01-02 20:00", + "2020-01-02 20:10", + "2020-01-02 20:20", + "2020-01-02 20:30", + "2020-01-02 20:40", + "2020-01-02 20:50", + "2020-01-02 21:00", + "2020-01-02 21:10", + "2020-01-02 21:20", + "2020-01-02 21:30", + "2020-01-02 21:40", + "2020-01-02 21:50", + "2020-01-02 22:00", + "2020-01-02 22:10", + "2020-01-02 22:20", + "2020-01-02 22:30", + "2020-01-02 22:40", + "2020-01-02 22:50", + "2020-01-02 23:00", + "2020-01-02 23:10", + "2020-01-02 23:20", + "2020-01-02 23:30", + "2020-01-02 23:40", + "2020-01-02 23:50", + "2020-01-03 00:00", + "2020-01-03 00:10", + "2020-01-03 00:20", + "2020-01-03 00:30", + "2020-01-03 00:40", + "2020-01-03 00:50", + "2020-01-03 01:00", + "2020-01-03 01:10", + "2020-01-03 01:20", + "2020-01-03 01:30", + "2020-01-03 01:40", + "2020-01-03 01:50", + "2020-01-03 02:00", + "2020-01-03 02:10", + "2020-01-03 02:20", + "2020-01-03 02:30", + "2020-01-03 02:40", + "2020-01-03 02:50", + "2020-01-03 03:00", + "2020-01-03 03:10", + "2020-01-03 03:20", + "2020-01-03 03:30", + "2020-01-03 03:40", + "2020-01-03 03:50", + "2020-01-03 04:00", + "2020-01-03 04:10", + "2020-01-03 04:20", + "2020-01-03 04:30", + "2020-01-03 04:40", + "2020-01-03 04:50", + "2020-01-03 05:00", + "2020-01-03 05:10", + "2020-01-03 05:20", + "2020-01-03 05:30", + "2020-01-03 05:40", + "2020-01-03 05:50", + "2020-01-03 06:00", + "2020-01-03 06:10", + "2020-01-03 06:20", + "2020-01-03 06:30", + "2020-01-03 06:40", + "2020-01-03 06:50", + "2020-01-03 07:00", + "2020-01-03 07:10", + "2020-01-03 07:20", + "2020-01-03 07:30", + "2020-01-03 07:40", + "2020-01-03 07:50", + "2020-01-03 08:00", + "2020-01-03 08:10", + "2020-01-03 08:20", + "2020-01-03 08:30", + "2020-01-03 08:40", + "2020-01-03 08:50", + "2020-01-03 09:00", + "2020-01-03 09:10", + "2020-01-03 09:20", + "2020-01-03 09:30", + "2020-01-03 09:40", + "2020-01-03 09:50", + + "2020-01-02 17:30", + "2020-01-03 00:00", + "2020-01-03 09:30" + ], + "y": [ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + + 1, 2, 3 + ], + "xbins": { + "start": "2020-01-02 16:55", + "end": "2020-01-03 09:55", + "size": 600000 + }, + "ybins": { + "start": 0.5, + "end": 3.5, + "size": 1 + } + }, { + "type": "histogram2d", + "x": [ + "2020-01-02 17:00", + "2020-01-02 17:10", + "2020-01-02 17:20", + "2020-01-02 17:30", + "2020-01-02 17:40", + "2020-01-02 17:50", + "2020-01-02 18:00", + "2020-01-02 18:10", + "2020-01-02 18:20", + "2020-01-02 18:30", + "2020-01-02 18:40", + "2020-01-02 18:50", + "2020-01-02 19:00", + "2020-01-02 19:10", + "2020-01-02 19:20", + "2020-01-02 19:30", + "2020-01-02 19:40", + "2020-01-02 19:50", + "2020-01-02 20:00", + "2020-01-02 20:10", + "2020-01-02 20:20", + "2020-01-02 20:30", + "2020-01-02 20:40", + "2020-01-02 20:50", + "2020-01-02 21:00", + "2020-01-02 21:10", + "2020-01-02 21:20", + "2020-01-02 21:30", + "2020-01-02 21:40", + "2020-01-02 21:50", + "2020-01-02 22:00", + "2020-01-02 22:10", + "2020-01-02 22:20", + "2020-01-02 22:30", + "2020-01-02 22:40", + "2020-01-02 22:50", + "2020-01-02 23:00", + "2020-01-02 23:10", + "2020-01-02 23:20", + "2020-01-02 23:30", + "2020-01-02 23:40", + "2020-01-02 23:50", + "2020-01-03 00:00", + "2020-01-03 00:10", + "2020-01-03 00:20", + "2020-01-03 00:30", + "2020-01-03 00:40", + "2020-01-03 00:50", + "2020-01-03 01:00", + "2020-01-03 01:10", + "2020-01-03 01:20", + "2020-01-03 01:30", + "2020-01-03 01:40", + "2020-01-03 01:50", + "2020-01-03 02:00", + "2020-01-03 02:10", + "2020-01-03 02:20", + "2020-01-03 02:30", + "2020-01-03 02:40", + "2020-01-03 02:50", + "2020-01-03 03:00", + "2020-01-03 03:10", + "2020-01-03 03:20", + "2020-01-03 03:30", + "2020-01-03 03:40", + "2020-01-03 03:50", + "2020-01-03 04:00", + "2020-01-03 04:10", + "2020-01-03 04:20", + "2020-01-03 04:30", + "2020-01-03 04:40", + "2020-01-03 04:50", + "2020-01-03 05:00", + "2020-01-03 05:10", + "2020-01-03 05:20", + "2020-01-03 05:30", + "2020-01-03 05:40", + "2020-01-03 05:50", + "2020-01-03 06:00", + "2020-01-03 06:10", + "2020-01-03 06:20", + "2020-01-03 06:30", + "2020-01-03 06:40", + "2020-01-03 06:50", + "2020-01-03 07:00", + "2020-01-03 07:10", + "2020-01-03 07:20", + "2020-01-03 07:30", + "2020-01-03 07:40", + "2020-01-03 07:50", + "2020-01-03 08:00", + "2020-01-03 08:10", + "2020-01-03 08:20", + "2020-01-03 08:30", + "2020-01-03 08:40", + "2020-01-03 08:50", + "2020-01-03 09:00", + "2020-01-03 09:10", + "2020-01-03 09:20", + "2020-01-03 09:30", + "2020-01-03 09:40", + "2020-01-03 09:50", + + "2020-01-02 17:00", + "2020-01-02 17:10", + "2020-01-02 17:20", + "2020-01-02 17:30", + "2020-01-02 17:40", + "2020-01-02 17:50", + "2020-01-02 18:00", + "2020-01-02 18:10", + "2020-01-02 18:20", + "2020-01-02 18:30", + "2020-01-02 18:40", + "2020-01-02 18:50", + "2020-01-02 19:00", + "2020-01-02 19:10", + "2020-01-02 19:20", + "2020-01-02 19:30", + "2020-01-02 19:40", + "2020-01-02 19:50", + "2020-01-02 20:00", + "2020-01-02 20:10", + "2020-01-02 20:20", + "2020-01-02 20:30", + "2020-01-02 20:40", + "2020-01-02 20:50", + "2020-01-02 21:00", + "2020-01-02 21:10", + "2020-01-02 21:20", + "2020-01-02 21:30", + "2020-01-02 21:40", + "2020-01-02 21:50", + "2020-01-02 22:00", + "2020-01-02 22:10", + "2020-01-02 22:20", + "2020-01-02 22:30", + "2020-01-02 22:40", + "2020-01-02 22:50", + "2020-01-02 23:00", + "2020-01-02 23:10", + "2020-01-02 23:20", + "2020-01-02 23:30", + "2020-01-02 23:40", + "2020-01-02 23:50", + "2020-01-03 00:00", + "2020-01-03 00:10", + "2020-01-03 00:20", + "2020-01-03 00:30", + "2020-01-03 00:40", + "2020-01-03 00:50", + "2020-01-03 01:00", + "2020-01-03 01:10", + "2020-01-03 01:20", + "2020-01-03 01:30", + "2020-01-03 01:40", + "2020-01-03 01:50", + "2020-01-03 02:00", + "2020-01-03 02:10", + "2020-01-03 02:20", + "2020-01-03 02:30", + "2020-01-03 02:40", + "2020-01-03 02:50", + "2020-01-03 03:00", + "2020-01-03 03:10", + "2020-01-03 03:20", + "2020-01-03 03:30", + "2020-01-03 03:40", + "2020-01-03 03:50", + "2020-01-03 04:00", + "2020-01-03 04:10", + "2020-01-03 04:20", + "2020-01-03 04:30", + "2020-01-03 04:40", + "2020-01-03 04:50", + "2020-01-03 05:00", + "2020-01-03 05:10", + "2020-01-03 05:20", + "2020-01-03 05:30", + "2020-01-03 05:40", + "2020-01-03 05:50", + "2020-01-03 06:00", + "2020-01-03 06:10", + "2020-01-03 06:20", + "2020-01-03 06:30", + "2020-01-03 06:40", + "2020-01-03 06:50", + "2020-01-03 07:00", + "2020-01-03 07:10", + "2020-01-03 07:20", + "2020-01-03 07:30", + "2020-01-03 07:40", + "2020-01-03 07:50", + "2020-01-03 08:00", + "2020-01-03 08:10", + "2020-01-03 08:20", + "2020-01-03 08:30", + "2020-01-03 08:40", + "2020-01-03 08:50", + "2020-01-03 09:00", + "2020-01-03 09:10", + "2020-01-03 09:20", + "2020-01-03 09:30", + "2020-01-03 09:40", + "2020-01-03 09:50", + + "2020-01-02 17:30", + "2020-01-03 00:00", + "2020-01-03 09:30" + ], + "y": [ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + + 1, 2, 3 + ], + "xbins": { + "start": "2020-01-02 16:55", + "end": "2020-01-03 09:55", + "size": 600000 + }, + "ybins": { + "start": 0.5, + "end": 3.5, + "size": 1 + }, + "xaxis": "x2", + "yaxis": "y2" + }], + "layout": { + "width": 1000, + "height": 400, + "title": { + "text": "histogram2d with (left) / without (right) rangebreaks" + }, + + "yaxis2": { + "anchor": "x2" + }, + + "xaxis2": { + "domain": [0.55, 1], + "anchor": "y2" + }, + + "xaxis": { + "domain": [0, 0.45], + "range": [ + "2020-01-02 16:55", + "2020-01-03 09:55" + ], + "rangebreaks": [{ + "pattern": "hour", + "bounds": [18, 9] + }] + } + } +} diff --git a/test/jasmine/tests/mock_test.js b/test/jasmine/tests/mock_test.js index b0d96b8e281..0685d8f6001 100644 --- a/test/jasmine/tests/mock_test.js +++ b/test/jasmine/tests/mock_test.js @@ -58,6 +58,7 @@ var list = [ 'axes_breaks-gridlines', 'axes_breaks-heatmap1d', 'axes_breaks-heatmap2d', + 'axes_breaks-histogram2d', 'axes_breaks-night_autorange-reversed', 'axes_breaks-rangeslider', 'axes_breaks-reversed-without-pattern', @@ -1092,6 +1093,7 @@ figs['axes_breaks-finance'] = require('@mocks/axes_breaks-finance'); figs['axes_breaks-gridlines'] = require('@mocks/axes_breaks-gridlines'); figs['axes_breaks-heatmap1d'] = require('@mocks/axes_breaks-heatmap1d'); figs['axes_breaks-heatmap2d'] = require('@mocks/axes_breaks-heatmap2d'); +figs['axes_breaks-histogram2d'] = require('@mocks/axes_breaks-histogram2d'); figs['axes_breaks-night_autorange-reversed'] = require('@mocks/axes_breaks-night_autorange-reversed'); figs['axes_breaks-rangeslider'] = require('@mocks/axes_breaks-rangeslider'); figs['axes_breaks-reversed-without-pattern'] = require('@mocks/axes_breaks-reversed-without-pattern');