提交 da6d0409 编写于 作者: O Ovilia

fix(legend): fix line series icon

上级 c125b4a4
......@@ -217,24 +217,27 @@ class LineSeriesModel extends SeriesModel<LineSeriesOption> {
getLegendIcon(opt: LegendSymbolParams): ECSymbol | Group {
const group = new Group();
// Line
const line = createSymbol(
'line',
0,
opt.itemHeight / 2,
opt.itemWidth,
0,
opt.lineStyle.stroke,
false
);
group.add(line);
// Draw line only if legend.icon is not defined
if (!opt.legendIconType) {
const line = createSymbol(
'line',
0,
opt.itemHeight / 2,
opt.itemWidth,
0,
opt.lineStyle.stroke,
false
);
group.add(line);
line.setStyle(opt.lineStyle);
}
line.setStyle(opt.lineStyle);
const visualType = opt.series.getData().getVisual('symbol');
const symbolType = opt.legendIconType
|| (visualType === 'none' ? 'circle' : visualType);
// Symbol in the center
const symbolType = opt.symbolType
|| opt.series.getData().getVisual('symbol');
const size = opt.itemHeight * 0.8;
// Symbol size is 80% when there is a line
const size = opt.itemHeight * (opt.legendIconType ? 1 : 0.8);
const symbol = createSymbol(
symbolType,
(opt.itemWidth - size) / 2,
......
......@@ -143,7 +143,14 @@ export interface LegendSymbolParams {
series: SeriesModel,
itemWidth: number,
itemHeight: number,
/**
* symbolType is from legend.icon, legend.data.icon, or series visual
*/
symbolType: string,
/**
* legendIconType is from legend.icon or legend.data.icon
*/
legendIconType: string,
symbolKeepAspect: boolean,
itemStyle: PathStyleProps,
lineStyle: LineStyleProps
......
......@@ -27,7 +27,7 @@ import {setLabelStyle, createTextStyle} from '../../label/labelStyle';
import {makeBackground} from '../helper/listComponent';
import * as layoutUtil from '../../util/layout';
import ComponentView from '../../view/Component';
import LegendModel, { LegendItemStyleOption, LegendLineStyleOption, LegendOption, LegendSelectorButtonOption, LegendTooltipFormatterParams } from './LegendModel';
import LegendModel, { LegendItemStyleOption, LegendLineStyleOption, LegendOption, LegendSelectorButtonOption, LegendSymbolParams, LegendTooltipFormatterParams } from './LegendModel';
import GlobalModel from '../../model/Global';
import ExtensionAPI from '../../core/ExtensionAPI';
import {
......@@ -343,8 +343,8 @@ class LegendView extends ComponentView {
const isSelected = legendModel.isSelected(name);
const symbolKeepAspect = itemModel.get('symbolKeepAspect');
const legendSymbolType = itemModel.get('icon') || symbolType;
symbolType = legendSymbolType || 'roundRect';
const legendIconType = itemModel.get('icon');
symbolType = legendIconType || symbolType || 'roundRect';
const legendLineStyle = legendModel.getModel('lineStyle');
const style = getLegendStyle(symbolType, itemModel, legendLineStyle, lineVisualStyle, itemVisualStyle, drawType, isSelected);
......@@ -359,7 +359,8 @@ class LegendView extends ComponentView {
series: seriesModel,
itemWidth,
itemHeight,
symbolType: legendSymbolType,
symbolType,
legendIconType: legendIconType,
symbolKeepAspect,
itemStyle: style.itemStyle,
lineStyle: style.lineStyle
......@@ -371,7 +372,8 @@ class LegendView extends ComponentView {
series: seriesModel,
itemWidth,
itemHeight,
symbolType: symbolType || 'roundRect',
symbolType,
legendIconType,
symbolKeepAspect,
itemStyle: style.itemStyle,
lineStyle: style.lineStyle
......@@ -629,15 +631,7 @@ function getLegendStyle(
return { itemStyle, lineStyle };
}
function getDefaultLegendIcon(opt: {
series: SeriesModel,
itemWidth: number,
itemHeight: number,
symbolType: string,
symbolKeepAspect: boolean,
itemStyle: PathStyleProps,
lineStyle: LineStyleProps
}): ECSymbol {
function getDefaultLegendIcon(opt: LegendSymbolParams): ECSymbol {
const symboType = opt.symbolType || 'roundRect';
const symbol = createSymbol(
symboType,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册