diff --git a/src/component/marker/MarkAreaView.ts b/src/component/marker/MarkAreaView.ts index 8f99610770..9ecf7d32ee 100644 --- a/src/component/marker/MarkAreaView.ts +++ b/src/component/marker/MarkAreaView.ts @@ -66,8 +66,15 @@ const markAreaTransform = function ( maModel: MarkAreaModel, item: MarkArea2DDataItemOption ): MarkAreaMergedItemOption { - const lt = markerHelper.dataTransform(seriesModel, item[0]); - const rb = markerHelper.dataTransform(seriesModel, item[1]); + // item may be null + const item0 = item[0]; + const item1 = item[1]; + if (!item0 || !item1) { + return; + } + + const lt = markerHelper.dataTransform(seriesModel, item0); + const rb = markerHelper.dataTransform(seriesModel, item1); // FIXME make sure lt is less than rb const ltCoord = lt.coord; diff --git a/src/component/marker/markerHelper.ts b/src/component/marker/markerHelper.ts index 8da0f9dc07..2777b137f4 100644 --- a/src/component/marker/markerHelper.ts +++ b/src/component/marker/markerHelper.ts @@ -99,16 +99,20 @@ export function dataTransform( seriesModel: SeriesModel, item: MarkerPositionOption ) { + if (!item) { + return; + } + const data = seriesModel.getData(); const coordSys = seriesModel.coordinateSystem; + const dims = coordSys.dimensions; // 1. If not specify the position with pixel directly // 2. If `coord` is not a data array. Which uses `xAxis`, // `yAxis` to specify the coord on each dimension // parseFloat first because item.x and item.y can be percent string like '20%' - if (item && !hasXAndY(item) && !isArray(item.coord) && coordSys) { - const dims = coordSys.dimensions; + if (!hasXAndY(item) && !isArray(item.coord) && coordSys) { const axisInfo = getAxisInfo(item, data, coordSys, seriesModel); // Clone the option @@ -130,21 +134,26 @@ export function dataTransform( // Force to use the value of calculated value. // let item use the value without stack. item.value = coordInfo[1]; - } else { // FIXME Only has one of xAxis and yAxis. - const coord = [ + item.coord = [ item.xAxis != null ? item.xAxis : item.radiusAxis, item.yAxis != null ? item.yAxis : item.angleAxis ]; - // Each coord support max, min, average - for (let i = 0; i < 2; i++) { - if (markerTypeCalculator[coord[i] as MarkerStatisticType]) { - coord[i] = numCalculate(data, data.mapDimension(dims[i]), coord[i] as MarkerStatisticType); - } + } + } + // x y is provided + if (item.coord == null) { + item.coord = []; + } + else { + // Each coord support max, min, average + const coord = item.coord; + for (let i = 0; i < 2; i++) { + if (markerTypeCalculator[coord[i] as MarkerStatisticType]) { + coord[i] = numCalculate(data, data.mapDimension(dims[i]), coord[i] as MarkerStatisticType); } - item.coord = coord; } } return item; diff --git a/test/markArea.html b/test/markArea.html index 8ec2352e10..d19744c8e7 100644 --- a/test/markArea.html +++ b/test/markArea.html @@ -23,24 +23,19 @@ + + - -
-
+
+
+
@@ -146,7 +144,7 @@ 'echarts' ], function (echarts) { - let option = { + var option = { title: { text: 'Distribution of Electricity', subtext: 'Fake Data' @@ -220,13 +218,136 @@ ] }; - var chartDom = document.getElementById('main1'); - var myChart = echarts.init(chartDom); - - option && myChart.setOption(option); + var chart = testHelper.create(echarts, 'main1', { + option: option + }); }); + + - \ No newline at end of file +