From a08a6eb7ce5491c80a562371131f557357494dca Mon Sep 17 00:00:00 2001 From: ghfan Date: Thu, 12 Jul 2018 11:59:43 +0800 Subject: [PATCH 1/3] Heatmap metric data points should only be quantized while the data full range is grate than the maxmum allowed color count --- .../visualizations/point_series/heatmap_chart.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js b/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js index 9d33f222d3417..4bc32be6db4cd 100644 --- a/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js +++ b/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js @@ -90,8 +90,14 @@ export function VislibVisualizationsHeatmapChartProvider(Private) { } else { val = val * (max - min) + min; nextVal = nextVal * (max - min) + min; - if (max > 1) { - val = Math.ceil(val); + if (max - min > 10) { + let valInt = Math.ceil(val); + if (i === 0) { + val = (valInt === val ? val : valInt -1); + } + else{ + val = valInt; + } nextVal = Math.ceil(nextVal); } if (isFinite(val)) val = zAxisFormatter(val); From d2a6d6656ca4116e25c2d4ad76bdd8ad2385c50c Mon Sep 17 00:00:00 2001 From: ghfan Date: Thu, 12 Jul 2018 12:04:56 +0800 Subject: [PATCH 2/3] The data cell with metric value 'null' should always be hidden in the heatmap --- .../vislib/visualizations/point_series/heatmap_chart.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js b/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js index 4bc32be6db4cd..5e27890842cc5 100644 --- a/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js +++ b/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js @@ -191,12 +191,16 @@ export function VislibVisualizationsHeatmapChartProvider(Private) { val = Math.min(colorsNumber - 1, Math.floor(val * colorsNumber)); } } + if (d.y == null) { + return -1; + } return !isNaN(val) ? val : -1; } function label(d) { const colorBucket = getColorBucket(d); - if (colorBucket === -1) d.hide = true; + // colorBucket id should always GTE 0 + if (colorBucket < 0) d.hide = true; return labels[colorBucket]; } From 5996c1edb980cf1d231795f00f8fc3a4ab67c068 Mon Sep 17 00:00:00 2001 From: ghfan Date: Mon, 23 Jul 2018 09:39:27 +0800 Subject: [PATCH 3/3] Add one variable for max color count and follow the coding style --- .../vislib/visualizations/point_series/heatmap_chart.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js b/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js index 5e27890842cc5..9fcf2ed635fe9 100644 --- a/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js +++ b/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js @@ -69,6 +69,7 @@ export function VislibVisualizationsHeatmapChartProvider(Private) { const zScale = this.getValueAxis().getScale(); const [min, max] = zScale.domain(); const labels = []; + const maxColorCnt = 10; if (cfg.get('setColorRange')) { colorsRange.forEach(range => { const from = isFinite(range.from) ? zAxisFormatter(range.from) : range.from; @@ -90,10 +91,10 @@ export function VislibVisualizationsHeatmapChartProvider(Private) { } else { val = val * (max - min) + min; nextVal = nextVal * (max - min) + min; - if (max - min > 10) { - let valInt = Math.ceil(val); + if (max - min > maxColorCnt) { + const valInt = Math.ceil(val); if (i === 0) { - val = (valInt === val ? val : valInt -1); + val = (valInt === val ? val : valInt - 1); } else{ val = valInt;