From 9e6b16a510b2851e20206790b68151e9b27e70f1 Mon Sep 17 00:00:00 2001 From: xiguaxigua Date: Tue, 10 Jul 2018 11:35:12 +0800 Subject: [PATCH] fix(heatmap): display error while data us empty --- src/packages/heatmap/main.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/packages/heatmap/main.js b/src/packages/heatmap/main.js index 9323551..5c6e929 100644 --- a/src/packages/heatmap/main.js +++ b/src/packages/heatmap/main.js @@ -41,7 +41,7 @@ function getAxis (list, name) { } function getVisualMap (args) { - const { innerMin: min, innerMax: max, type, heatColor } = args + const { innerMin: min, innerMax: max, type, heatColor, series } = args let result = { min, max, @@ -55,6 +55,7 @@ function getVisualMap (args) { bottom: 0, inRange: { color: heatColor || HEAT_MAP_COLOR } } + if (!series[0].data.length) extra.show = false } else if (type === 'bmap' || type === 'amap') { extra = { show: false, @@ -167,14 +168,15 @@ export const heatmap = (columns, rows, settings, status) => { extraMetrics }) } - const metricsList = metrics ? rows.map(row => row[metrics]) : [0, 5] + let metricsList = metrics ? rows.map(row => row[metrics]) : [0, 5] + if (!metricsList.length) metricsList = [0] const innerMin = min || Math.min.apply(null, metricsList) const innerMax = max || Math.max.apply(null, metricsList) const xAxis = getAxis(innerXAxisList, xAxisName) const yAxis = getAxis(innerYAxisList, yAxisName) - const visualMap = getVisualMap({ innerMin, innerMax, type, heatColor }) const series = getSeries({ chartData }) + const visualMap = getVisualMap({ innerMin, innerMax, type, heatColor, series }) const tooltip = tooltipVisible && getTooltip({ dataType, innerXAxisList, @@ -193,7 +195,6 @@ export const heatmap = (columns, rows, settings, status) => { }) } else if (type === 'map') { options.series[0].coordinateSystem = 'geo' - return getMapJSON({ position, positionJsonLink,