fix(图表): 修复瀑布图提示格式化错误

This commit is contained in:
wisonic
2025-12-15 18:04:01 +08:00
committed by wisonic-s
parent 6015f84f87
commit b608d8f76b

View File

@@ -102,7 +102,12 @@ export class Waterfall extends G2PlotChartView<WaterfallOptions, G2Waterfall> {
xField: 'field',
yField: 'value',
seriesField: 'category',
appendPadding: getPadding(chart)
appendPadding: getPadding(chart),
meta: {
field: {
type: 'cat'
}
}
}
const options = this.setupOptions(chart, baseOptions)
const { Waterfall: G2Waterfall } = await import('@antv/g2plot/esm/plots/waterfall')
@@ -113,33 +118,6 @@ export class Waterfall extends G2PlotChartView<WaterfallOptions, G2Waterfall> {
return newChart
}
protected configMeta(chart: Chart, options: WaterfallOptions): WaterfallOptions {
const yAxis = chart.yAxis
const meta: WaterfallOptions['meta'] = {
field: {
type: 'cat'
}
}
if (!yAxis?.length) {
return {
...options,
meta
}
}
const f = yAxis[0]
const yAxisStyle = parseJson(chart.customStyle).yAxis
meta.value = {
alias: f.name,
formatter: (value: number) => {
return valueFormatter(value, yAxisStyle.axisLabelFormatter)
}
}
return {
...options,
meta
}
}
protected configBasicStyle(chart: Chart, options: WaterfallOptions): WaterfallOptions {
const customAttr = parseJson(chart.customAttr)
const { colors, gradient, alpha } = customAttr.basicStyle
@@ -177,6 +155,11 @@ export class Waterfall extends G2PlotChartView<WaterfallOptions, G2Waterfall> {
return tmpOptions
}
const yAxis = parseJson(chart.customStyle).yAxis
if (tmpOptions.yAxis.label) {
tmpOptions.yAxis.label.formatter = value => {
return valueFormatter(value, yAxis.axisLabelFormatter)
}
}
const axisValue = yAxis.axisValue
if (!axisValue?.auto) {
const axis = {
@@ -329,7 +312,6 @@ export class Waterfall extends G2PlotChartView<WaterfallOptions, G2Waterfall> {
this.configTooltip,
this.configXAxis,
this.configYAxis,
this.configMeta,
this.configBarConditions
)(chart, options)
}