refactor(图表): 最值标签不显示

This commit is contained in:
wisonic 2024-07-30 17:48:53 +08:00
parent 44c89d1147
commit a95e34aad0
2 changed files with 9 additions and 2 deletions

View File

@ -104,9 +104,11 @@ const noChildrenFieldChart = chart => {
export const extremumEvt = (newChart, chart, _options, container) => {
chart.container = container
newChart.on('afterrender', ev => {
newChart.on('beforerender', ev => {
newChart.chart.geometries[0].on('beforerenderlabel', () => {
createExtremumPoint(chart, ev)
})
})
}
const findMinMax = (data): { minItem; maxItem } => {
@ -158,6 +160,8 @@ export const createExtremumPoint = (chart, ev) => {
if (pointObjList && pointObjList.length > 0) {
const pointObj = pointObjList[0]
const { minItem, maxItem } = findMinMax(pointObjList.reverse())
minItem._origin.EXTREME = true
maxItem._origin.EXTREME = true
let attr
let showExtremum = false
if (noChildrenFieldChart(chart) || yAxis.length > 1) {

View File

@ -132,6 +132,9 @@ export class Bar extends G2PlotChartView<ColumnOptions, Column> {
fields: [],
...tmpOptions.label,
formatter: (data: Datum, _point) => {
if (data.EXTREME) {
return ''
}
if (!labelAttr.seriesLabelFormatter?.length) {
return data.value
}