From e8c8e096d275174dbc0899b11a431a66d782bf28 Mon Sep 17 00:00:00 2001 From: yufeng04 Date: Mon, 23 Sep 2019 22:27:50 +0800 Subject: [PATCH] fix typo & itemModel should not be created twice --- src/visual/dataColor.js | 10 ++++++---- test/legend-borderColor.html | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/visual/dataColor.js b/src/visual/dataColor.js index a408c584cf..63c2b84e9a 100644 --- a/src/visual/dataColor.js +++ b/src/visual/dataColor.js @@ -56,9 +56,13 @@ export default function (seriesType) { var singleDataBorderColor = filteredIdx != null && data.getItemVisual(filteredIdx, 'borderColor', true); - if (!singleDataColor) { + var itemModel; + if (!singleDataColor || !singleDataBorderColor) { // FIXME Performance - var itemModel = dataAll.getItemModel(rawIdx); + itemModel = dataAll.getItemModel(rawIdx); + } + + if (!singleDataColor) { var color = itemModel.get('itemStyle.color') || seriesModel.getColorFromPalette( dataAll.getName(rawIdx) || (rawIdx + ''), seriesModel.__paletteScope, @@ -78,8 +82,6 @@ export default function (seriesType) { } if (!singleDataBorderColor) { - // FIXME Performance - var itemModel = dataAll.getItemModel(rawIdx); var borderColor = itemModel.get('itemStyle.borderColor'); // Legend may use the visual info in data before processed dataAll.setItemVisual(rawIdx, 'borderColor', borderColor); diff --git a/test/legend-borderColor.html b/test/legend-borderColor.html index 056f61839e..7caa9fbd2d 100644 --- a/test/legend-borderColor.html +++ b/test/legend-borderColor.html @@ -299,7 +299,7 @@ // chart1.setOption(option1); testHelper.create(echarts, 'plain1', { title: [ - '(Legend symbol of line)', + '(Legend symbol of bar)', 'the borderColor of first legend symbol should be black', 'the borderColor of second legend symbol should be blue', 'the bar borderColor of second series should be red, because the legend borderColor is incompatible with barBorderColor', @@ -423,7 +423,7 @@ // chart2.setOption(option2); testHelper.create(echarts, 'plain2', { title: [ - '(Legend symbol of line)', + '(Legend symbol of pie)', 'the first legend symbol should be unselected', 'the borderColor of legend symbol should be red', 'the borderWidth of all legend symbols should be 3'