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 3f2391eb1e3516..b765ccb31838e7 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,8 +91,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 > maxColorCnt) { + const 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); @@ -184,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]; }