From 696798dcf5c8462899fa56b37ca38dc7e5ccb7c7 Mon Sep 17 00:00:00 2001 From: xiguaxigua Date: Mon, 25 Jun 2018 22:12:58 +0800 Subject: [PATCH] fix(line): line display error while use dataZoom when use string data in series.m sometimes will trigger display error, such as the title say, and use array data will not. fixed #394 #387 --- src/packages/line/main.js | 25 ++-- test/load/cdn/line/dataZoom.html | 210 +++++++++++++++++++++++++++++++ 2 files changed, 218 insertions(+), 17 deletions(-) create mode 100644 test/load/cdn/line/dataZoom.html diff --git a/src/packages/line/main.js b/src/packages/line/main.js index 70e4277..4fe709a 100755 --- a/src/packages/line/main.js +++ b/src/packages/line/main.js @@ -1,4 +1,3 @@ -import { itemPoint } from '../../constants' import { getFormated, getStackMap } from '../../utils' import { isArray } from 'utils-lite' @@ -28,7 +27,6 @@ function getLineSeries (args) { itemStyle, lineStyle, areaStyle, - xAxisType, dimension } = args let series = [] @@ -43,10 +41,7 @@ function getLineSeries (args) { } else if (nullAddZero) { value = 0 } - const dataItem = xAxisType === 'category' - ? value - : [row[dimension[0]], value] - dataTemp[item].push(dataItem) + dataTemp[item].push([row[dimension[0]], value]) }) }) metrics.forEach(item => { @@ -112,7 +107,7 @@ function getLineYAxis (args) { } function getLineTooltip (args) { - const { axisSite, yAxisType, digit, labelMap, xAxisType, tooltipFormatter } = args + const { axisSite, yAxisType, digit, labelMap, tooltipFormatter } = args const rightItems = axisSite.right || [] const rightList = labelMap ? rightItems.map(item => { @@ -129,17 +124,13 @@ function getLineTooltip (args) { const { name, axisValueLabel } = items[0] const title = name || axisValueLabel tpl.push(`${title}
`) - items.forEach(item => { + items.forEach(({ seriesName, data, marker }) => { let showData = null - const type = ~rightList.indexOf(item.seriesName) - ? yAxisType[1] - : yAxisType[0] - const data = xAxisType === 'category' - ? item.data - : item.data[1] - showData = getFormated(data, type, digit) - tpl.push(itemPoint(item.color)) - tpl.push(`${item.seriesName}: ${showData}`) + const type = ~rightList.indexOf(seriesName) ? yAxisType[1] : yAxisType[0] + const itemData = isArray(data) ? data[1] : data + showData = getFormated(itemData, type, digit) + tpl.push(marker) + tpl.push(`${seriesName}: ${showData}`) tpl.push('
') }) return tpl.join('') diff --git a/test/load/cdn/line/dataZoom.html b/test/load/cdn/line/dataZoom.html new file mode 100644 index 0000000..3e06eed --- /dev/null +++ b/test/load/cdn/line/dataZoom.html @@ -0,0 +1,210 @@ + + + + + + + + + + RunJS 演示代码 + + + +
+ + + +
+ + + +