refactor(视图): 优化视图默认图例配置

This commit is contained in:
wisonic-s 2024-02-27 14:56:01 +08:00
parent 5401a1f9e6
commit 4db2c3e273
4 changed files with 12 additions and 4 deletions

View File

@ -125,7 +125,7 @@ export class Funnel extends G2PlotChartView<FunnelOptions, G2Funnel> {
)(chart, options)
}
setupDefaultOptions(chart: ChartObj): ChartObj {
const { customAttr } = chart
const { customAttr, customStyle } = chart
const { label } = customAttr
if (!['left', 'middle', 'right'].includes(label.position)) {
label.position = 'middle'
@ -134,6 +134,8 @@ export class Funnel extends G2PlotChartView<FunnelOptions, G2Funnel> {
...label,
show: true
}
const { legend } = customStyle
legend.show = false
return chart
}

View File

@ -201,7 +201,7 @@ export class Treemap extends G2PlotChartView<TreemapOptions, G2Treemap> {
}
setupDefaultOptions(chart: ChartObj): ChartObj {
const customAttr = chart.customAttr
const { customAttr, customStyle } = chart
const { label } = customAttr
customAttr.label = {
...label,
@ -210,6 +210,8 @@ export class Treemap extends G2PlotChartView<TreemapOptions, G2Treemap> {
showProportion: true,
reserveDecimalCount: 2
}
const { legend } = customStyle
legend.show = false
return chart
}

View File

@ -218,7 +218,7 @@ export class Pie extends G2PlotChartView<PieOptions, G2Pie> {
}
}
setupDefaultOptions(chart: ChartObj): ChartObj {
const customAttr = chart.customAttr
const { customAttr, customStyle } = chart
const { label } = customAttr
if (!['inner', 'outer'].includes(label.position)) {
label.position = 'outer'
@ -230,6 +230,8 @@ export class Pie extends G2PlotChartView<PieOptions, G2Pie> {
showProportion: true,
reserveDecimalCount: 2
}
const { legend } = customStyle
legend.show = false
return chart
}

View File

@ -203,7 +203,7 @@ export class Rose extends G2PlotChartView<RoseOptions, G2Rose> {
}
setupDefaultOptions(chart: ChartObj): ChartObj {
const customAttr = chart.customAttr
const { customAttr, customStyle } = chart
const { label } = customAttr
if (!['inner', 'outer'].includes(label.position)) {
label.position = 'outer'
@ -215,6 +215,8 @@ export class Rose extends G2PlotChartView<RoseOptions, G2Rose> {
showProportion: true,
reserveDecimalCount: 2
}
const { legend } = customStyle
legend.show = false
return chart
}