diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bar.ts index 817ab36a17..ead63e3e82 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bar.ts @@ -116,6 +116,7 @@ export class Bar extends G2PlotChartView { 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) { diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/horizontal-bar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/horizontal-bar.ts index 2d7e5b9f3c..1ddc990762 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/horizontal-bar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/horizontal-bar.ts @@ -164,11 +164,12 @@ export class HorizontalBar extends G2PlotChartView { } 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 { 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) {