diff --git a/src/chart/custom/install.ts b/src/chart/custom/install.ts index 0592854f604212220a65db05a0fd60717576f229..d3cf0244fd8fca7d229cda1e416cf897f2146f44 100644 --- a/src/chart/custom/install.ts +++ b/src/chart/custom/install.ts @@ -327,7 +327,7 @@ const NON_STYLE_VISUAL_PROPS = { symbol: 1, symbolSize: 1, symbolKeepAspect: 1, - legendSymbol: 1, + legendIcon: 1, visualMeta: 1, liftZ: 1, decal: 1 diff --git a/src/chart/map/MapSeries.ts b/src/chart/map/MapSeries.ts index cf08391e11519dd0c50004d4e773cd2300f473fc..2adfa92ce37916bd5ea87501853cf0bc30ce6581 100644 --- a/src/chart/map/MapSeries.ts +++ b/src/chart/map/MapSeries.ts @@ -242,12 +242,6 @@ class MapSeries extends SeriesModel { // Map do not use itemStyle.borderWidth as border width symbol.style.stroke = 'none'; - const symbolRotate = opt.symbolRotate === 'inherit' - ? 0 - : (opt.symbolRotate || 0); - symbol.rotation = symbolRotate * Math.PI / 180; - symbol.setOrigin([opt.itemWidth / 2, opt.itemHeight / 2]); - if (symbolType.indexOf('empty') > -1) { symbol.style.stroke = symbol.style.fill; symbol.style.fill = '#fff'; diff --git a/src/chart/map/mapSymbolLayout.ts b/src/chart/map/mapSymbolLayout.ts index 498788f1faaa1e7fd6b1cb891b2f13ae463cf1a6..9771eb53a459511442798d65d315b98c8d3af8c6 100644 --- a/src/chart/map/mapSymbolLayout.ts +++ b/src/chart/map/mapSymbolLayout.ts @@ -66,7 +66,7 @@ export default function mapSymbolLayout(ecModel: GlobalModel) { } }); - // Show label of those region not has legendSymbol(which is offset 0) + // Show label of those region not has legendIcon (which is offset 0) const data = mapSeries.getData(); data.each(function (idx) { const name = data.getName(idx); diff --git a/src/component/helper/MapDraw.ts b/src/component/helper/MapDraw.ts index c73dabd64660914e99264fc46b9b42cdbc943819..ef44f8087601da7a8666a3ec46633c009f207693 100644 --- a/src/component/helper/MapDraw.ts +++ b/src/component/helper/MapDraw.ts @@ -682,7 +682,7 @@ function resetLabelForRegion( // In the following cases label will be drawn // 1. In map series and data value is NaN // 2. In geo component - // 3. Region has no series legendSymbol, which will be add a showLabel flag in mapSymbolLayout + // 3. Region has no series legendIcon, which will be add a showLabel flag in mapSymbolLayout if ( ((isGeo || isDataNaN)) || (itemLayout && itemLayout.showLabel) diff --git a/src/component/legend/LegendView.ts b/src/component/legend/LegendView.ts index c6e4deff750ecd9ee08c2b5b1b69dbd2d5e59511..79f9967f1739ccba73c8e618ad8984b9602f8bd4 100644 --- a/src/component/legend/LegendView.ts +++ b/src/component/legend/LegendView.ts @@ -207,7 +207,7 @@ class LegendView extends ComponentView { if (seriesModel) { const data = seriesModel.getData(); const lineVisualStyle = data.getVisual('legendLineStyle') || {}; - const symbolType = data.getVisual('legendSymbol'); + const legendIcon = data.getVisual('legendIcon'); /** * `data.getVisual('style')` may be the color from the register @@ -218,7 +218,7 @@ class LegendView extends ComponentView { const itemGroup = this._createItem( seriesModel, name, dataIndex, legendItemModel, legendModel, itemAlign, - lineVisualStyle, style, symbolType, selectMode + lineVisualStyle, style, legendIcon, selectMode ); itemGroup.on('click', curry(dispatchSelectAction, name, null, api, excludeSeriesId)) @@ -245,7 +245,7 @@ class LegendView extends ComponentView { const idx = provider.indexOfName(name); const style = provider.getItemVisual(idx, 'style') as PathStyleProps; - const symbolType = provider.getItemVisual(idx, 'legendSymbol'); + const legendIcon = provider.getItemVisual(idx, 'legendIcon'); const colorArr = parse(style.fill as ColorString); // Color may be set to transparent in visualMap when data is out of range. @@ -259,7 +259,7 @@ class LegendView extends ComponentView { const itemGroup = this._createItem( seriesModel, name, dataIndex, legendItemModel, legendModel, itemAlign, - {}, style, symbolType, selectMode + {}, style, legendIcon, selectMode ); // FIXME: consider different series has items with the same name. @@ -339,7 +339,7 @@ class LegendView extends ComponentView { itemAlign: LegendOption['align'], lineVisualStyle: LineStyleProps, itemVisualStyle: PathStyleProps, - symbolType: string, + legendIcon: string, selectMode: LegendOption['selectedMode'] ) { const drawType = seriesModel.visualDrawType; @@ -350,11 +350,11 @@ class LegendView extends ComponentView { let symbolRotate = itemModel.get('symbolRotate'); const legendIconType = itemModel.get('icon'); - symbolType = legendIconType || symbolType || 'roundRect'; + legendIcon = legendIconType || legendIcon || 'roundRect'; const legendLineStyle = legendModel.getModel('lineStyle'); const style = getLegendStyle( - symbolType, + legendIcon, itemModel, legendLineStyle, lineVisualStyle, @@ -374,7 +374,7 @@ class LegendView extends ComponentView { itemGroup.add(seriesModel.getLegendIcon({ itemWidth, itemHeight, - symbolType, + symbolType: legendIcon, symbolRotate, itemStyle: style.itemStyle, lineStyle: style.lineStyle @@ -382,13 +382,15 @@ class LegendView extends ComponentView { } else { // Use default legend icon policy for most series - const rotate = symbolRotate === 'inherit' - ? seriesModel.get('symbolRotate') - : symbolRotate; + const rotate = legendIconType === 'inherit' && legendIcon + ? (symbolRotate === 'inherit' + ? seriesModel.get('symbolRotate') + : symbolRotate) + : 0; // No rotation for no icon itemGroup.add(getDefaultLegendIcon({ itemWidth, itemHeight, - symbolType, + symbolType: legendIcon, symbolRotate: rotate, itemStyle: style.itemStyle, lineStyle: style.lineStyle diff --git a/src/component/radar/install.ts b/src/component/radar/install.ts index d0abe8e8587101d36bec7849e021ecfaef67cd8a..bfaea5d5e79352b4753a554b2feb82772710f731 100644 --- a/src/component/radar/install.ts +++ b/src/component/radar/install.ts @@ -34,10 +34,10 @@ export function install(registers: EChartsExtensionInstallRegisters) { const data = seriesModel.getData(); // itemVisual symbol is for selected data data.each(function (idx) { - data.setItemVisual(idx, 'legendSymbol', 'roundRect'); + data.setItemVisual(idx, 'legendIcon', 'roundRect'); }); // visual is for unselected data - data.setVisual('legendSymbol', 'roundRect'); + data.setVisual('legendIcon', 'roundRect'); } }); } diff --git a/src/data/List.ts b/src/data/List.ts index 2e0f13141e16aabfb2b90cc98a529ff3159b398b..0ad2792fa49a95ba156f069c69836436221ec6de 100644 --- a/src/data/List.ts +++ b/src/data/List.ts @@ -141,7 +141,7 @@ export interface DefaultDataVisual { liftZ?: number // For legend. - legendSymbol?: string + legendIcon?: string legendLineStyle?: LineStyleProps // visualMap will inject visualMeta data diff --git a/src/model/Series.ts b/src/model/Series.ts index 8e90bf39df5c45e09e6a5d04112239ba4f0692d0..383adfd1b36226af237844c6ae01eae9da6a54c8 100644 --- a/src/model/Series.ts +++ b/src/model/Series.ts @@ -175,7 +175,7 @@ class SeriesModel extends ComponentMode // Default symbol type. defaultSymbol: string; // Symbol provide to legend. - legendSymbol: string; + legendIcon: string; // --------------------------------------- // Props about data selection diff --git a/src/visual/symbol.ts b/src/visual/symbol.ts index e15e42525425b6f675d38505334dad384ddb5d01..ae9f625c3843d52435d388f0568e3a0a9bbf1540 100644 --- a/src/visual/symbol.ts +++ b/src/visual/symbol.ts @@ -46,8 +46,8 @@ const seriesSymbolTask: StageHandler = { ) { const data = seriesModel.getData(); - if (seriesModel.legendSymbol) { - data.setVisual('legendSymbol', seriesModel.legendSymbol); + if (seriesModel.legendIcon) { + data.setVisual('legendIcon', seriesModel.legendIcon); } if (!seriesModel.hasSymbolVisual) { @@ -74,7 +74,7 @@ const seriesSymbolTask: StageHandler = { const seriesSymbolOffset = !hasSymbolOffsetCallback ? symbolOffset : null; data.setVisual({ - legendSymbol: seriesModel.legendSymbol || seriesSymbol as string, + legendIcon: seriesModel.legendIcon || seriesSymbol as string, // If seting callback functions on `symbol` or `symbolSize`, for simplicity and avoiding // to bring trouble, we do not pick a reuslt from one of its calling on data item here, // but just use the default value. Callback on `symbol` or `symbolSize` is convenient in diff --git a/test/legend-style.html b/test/legend-style.html index 0a559d43289e1e8d53f7b82a112265db5d885cce..d822235aaff1129ebb6b64b5d6600b6b9bb723bf 100644 --- a/test/legend-style.html +++ b/test/legend-style.html @@ -230,7 +230,8 @@ under the License. name: 'Line C', symbolRotate: -30, icon: 'emptyTriangle' - } + }, + 'Bar D' ], symbolRotate: 30, itemWidth: 100 @@ -254,6 +255,10 @@ under the License. name: 'Line C', symbol: 'emptyTriangle', symbolKeepAspect: true + }, { + data: getData(0), + type: 'bar', + name: 'Bar D' }], animation: 0 }; @@ -263,7 +268,8 @@ under the License. '**Legend options should work**', 'Line A: the rect in the legend should be placed at the center with rotation of 30 degrees', 'Line B: the triangle in the legend should be placed at the center with rotation of 30 degrees', - 'Line C: the triangle in the legend should be placed at the center with rotation of -30 degrees' + 'Line C: should not have rotate in legend', + 'Bar D: should not have rotate in legend' ], option: option });