style(图表-基础折线图): 自定义排序后,图例个数超过9个时,图例marker未着色

This commit is contained in:
jianneng-fit2cloud 2024-09-03 21:28:19 +08:00
parent 96085792b2
commit c5e6fa9253

View File

@ -288,14 +288,12 @@ export class Line extends G2PlotChartView<LineOptions, G2Line> {
} }
protected configLegend(chart: Chart, options: LineOptions): LineOptions { protected configLegend(chart: Chart, options: LineOptions): LineOptions {
const optionTmp = super.configLegend(chart, options) const optionTmp = super.configLegend(chart, options)
const xAxisExt = chart.xAxisExt const xAxisExt = chart.xAxisExt[0]
if (!optionTmp.legend || xAxisExt.length === 0 || xAxisExt[0].customSort?.length === 0) { if (optionTmp.legend && xAxisExt?.customSort?.length > 0) {
return optionTmp
}
// 图例自定义排序 // 图例自定义排序
const l = optionTmp.legend const l = optionTmp.legend
const basicStyle = parseJson(chart.customAttr).basicStyle const basicStyle = parseJson(chart.customAttr).basicStyle
const sort = xAxisExt[0].customSort ?? [] const sort = xAxisExt.customSort ?? []
const legendItems = [] const legendItems = []
sort.forEach((item, index) => { sort.forEach((item, index) => {
legendItems.push({ legendItems.push({
@ -308,7 +306,7 @@ export class Line extends G2PlotChartView<LineOptions, G2Line> {
fill: 'rgba(0,0,0,0)', fill: 'rgba(0,0,0,0)',
lineWidth: 2, lineWidth: 2,
lineJoin: 'round', lineJoin: 'round',
stroke: basicStyle.colors[index] stroke: basicStyle.colors[index % basicStyle.colors.length]
} }
} }
}) })
@ -323,6 +321,8 @@ export class Line extends G2PlotChartView<LineOptions, G2Line> {
legend legend
} }
} }
return optionTmp
}
protected setupOptions(chart: Chart, options: LineOptions): LineOptions { protected setupOptions(chart: Chart, options: LineOptions): LineOptions {
return flow( return flow(
this.configTheme, this.configTheme,