Merge pull request #11277 from dataease/pr@dev-v2@refactor_extreme_value_label

refactor(图表): 最值标签不显示
This commit is contained in:
wisonic-s 2024-07-30 17:50:06 +08:00 committed by GitHub
commit c6ac91e316
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -104,8 +104,10 @@ const noChildrenFieldChart = chart => {
export const extremumEvt = (newChart, chart, _options, container) => {
chart.container = container
newChart.on('afterrender', ev => {
createExtremumPoint(chart, ev)
newChart.on('beforerender', ev => {
newChart.chart.geometries[0].on('beforerenderlabel', () => {
createExtremumPoint(chart, ev)
})
})
}
@ -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
}