Merge pull request #12525 from dataease/pr@dev-v2@chart-show-extremum-fix

fix(图表): 修复修改指标显示名称后,无法显示最值的问题
This commit is contained in:
jianneng-fit2cloud 2024-09-27 18:40:42 +08:00 committed by GitHub
commit af4d253273
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -106,6 +106,14 @@ const noChildrenFieldChart = chart => {
return ['area', 'bar'].includes(chart.type)
}
/**
* 支持最值图表的折线图面积图柱状图分组柱状图
* @param chart
*/
const supportExtremumChartType = chart => {
return ['line', 'area', 'bar', 'bar-group'].includes(chart.type)
}
const chartContainerId = chart => {
return chart.container + '_'
}
@ -131,6 +139,10 @@ function removeDivsWithPrefix(parentDivId, prefix) {
export const extremumEvt = (newChart, chart, _options, container) => {
chart.container = container
if (!supportExtremumChartType(chart)) {
clearExtremum(chart)
return
}
const { label: labelAttr } = parseJson(chart.customAttr)
const { yAxis } = parseJson(chart)
newChart.once('beforerender', ev => {
@ -145,8 +157,12 @@ export const extremumEvt = (newChart, chart, _options, container) => {
}
let showExtremum = false
if (noChildrenFieldChart(chart) || yAxis.length > 1) {
const seriesLabelFormatter = labelAttr.seriesLabelFormatter.find(
d => d.name === minItem._origin.category || d.name === maxItem._origin.category
const seriesLabelFormatter = labelAttr.seriesLabelFormatter.find(d =>
d.chartShowName
? d.chartShowName
: d.name === minItem._origin.category || d.chartShowName
? d.chartShowName
: d.name === maxItem._origin.category
)
showExtremum = seriesLabelFormatter?.showExtremum
} else {
@ -248,8 +264,10 @@ export const createExtremumPoint = (chart, ev) => {
let attr
let showExtremum = false
if (noChildrenFieldChart(chart) || yAxis.length > 1) {
const seriesLabelFormatter = labelAttr.seriesLabelFormatter.find(
d => d.name === pointObj._origin.category
const seriesLabelFormatter = labelAttr.seriesLabelFormatter.find(d =>
d.chartShowName
? d.chartShowName === pointObj._origin.category
: d.name === pointObj._origin.category
)
showExtremum = seriesLabelFormatter?.showExtremum
attr = seriesLabelFormatter