fix: 单系列条形图和柱状图标签颜色修改无效

This commit is contained in:
wisonic-s 2023-10-31 22:16:09 +08:00
parent 3ca1774cf2
commit a3e51bce30
2 changed files with 6 additions and 1 deletions

View File

@ -116,6 +116,7 @@ export class Bar extends G2PlotChartView<ColumnOptions, Column> {
pre[next.id] = next
return pre
}, {})
// 默认是灰色
tmpOptions.label.style.fill = DEFAULT_LABEL.color
const label = {
fields: [],
@ -242,6 +243,7 @@ export class StackBar extends Bar {
return baseOptions
}
const { label: labelAttr } = parseJson(chart.customAttr)
baseOptions.label.style.fill = labelAttr.color
const label = {
...baseOptions.label,
formatter: function (param: Datum) {

View File

@ -164,11 +164,12 @@ export class HorizontalBar extends G2PlotChartView<BarOptions, Bar> {
}
setupDefaultOptions(chart: ChartObj): ChartObj {
const { customAttr } = chart
const { customAttr, senior } = chart
const { label } = customAttr
if (!['left', 'middle', 'right'].includes(label.position)) {
label.position = 'middle'
}
senior.functionCfg.emptyDataStrategy = 'ignoreData'
return chart
}
@ -185,6 +186,7 @@ export class HorizontalBar extends G2PlotChartView<BarOptions, Bar> {
pre[next.id] = next
return pre
}, {})
// 默认灰色
tmpOptions.label.style.fill = DEFAULT_LABEL.color
const label = {
fields: [],
@ -272,6 +274,7 @@ export class HorizontalStackBar extends HorizontalBar {
return baseOptions
}
const { label: labelAttr } = parseJson(chart.customAttr)
baseOptions.label.style.fill = labelAttr.color
const label = {
...baseOptions.label,
formatter: function (param: Datum) {