Skip to content

Commit

Permalink
fix(heatmap): display error while data us empty
Browse files Browse the repository at this point in the history
  • Loading branch information
xiguaxigua committed Jul 10, 2018
1 parent 7e4e39b commit 9e6b16a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/packages/heatmap/main.js
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -193,7 +195,6 @@ export const heatmap = (columns, rows, settings, status) => {
})
} else if (type === 'map') {
options.series[0].coordinateSystem = 'geo'

return getMapJSON({
position,
positionJsonLink,
Expand Down

0 comments on commit 9e6b16a

Please sign in to comment.