Merge pull request #9162 from dataease/pr@dev-v2@chart-tooltip-fix

fix(图表-样式): 修复提示指标下拉框数据,有可能存在缺失的问题
This commit is contained in:
jianneng-fit2cloud 2024-04-17 14:10:55 +08:00 committed by GitHub
commit a721be0dd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,7 +7,7 @@ import cloneDeep from 'lodash-es/cloneDeep'
import defaultsDeep from 'lodash-es/defaultsDeep' import defaultsDeep from 'lodash-es/defaultsDeep'
import { formatterType, unitType } from '../../../js/formatter' import { formatterType, unitType } from '../../../js/formatter'
import { fieldType } from '@/utils/attr' import { fieldType } from '@/utils/attr'
import { partition } from 'lodash-es' import { partition, uniqWith, isEqual } from 'lodash-es'
import chartViewManager from '../../../js/panel' import chartViewManager from '../../../js/panel'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
@ -255,6 +255,9 @@ const updateSeriesTooltipFormatter = (form: AxisEditForm) => {
const addAxis = (form: AxisEditForm) => { const addAxis = (form: AxisEditForm) => {
const { axis, axisType } = form const { axis, axisType } = form
const axisMap = axis.reduce((pre, next) => { const axisMap = axis.reduce((pre, next) => {
if (!next) {
return pre
}
next.axisType = axisType next.axisType = axisType
next.seriesId = `${next.id}-${axisType}` next.seriesId = `${next.id}-${axisType}`
pre[next.id] = next pre[next.id] = next
@ -278,12 +281,15 @@ const addAxis = (form: AxisEditForm) => {
} }
} }
}) })
const dupAxisDistinct = uniqWith(dupAxis, isEqual) || []
state.tooltipForm.seriesTooltipFormatter = state.tooltipForm.seriesTooltipFormatter =
state.tooltipForm.seriesTooltipFormatter.concat(dupAxis) state.tooltipForm.seriesTooltipFormatter.concat(dupAxisDistinct)
state.tooltipForm.seriesTooltipFormatter = partition( state.tooltipForm.seriesTooltipFormatter = partition(
state.tooltipForm.seriesTooltipFormatter, state.tooltipForm.seriesTooltipFormatter,
ele => quotaAxis.value.findIndex(item => item.id === ele.id) !== -1 ele => quotaAxis.value.findIndex(item => item.id === ele.id) !== -1
).flat() ).flat()
state.tooltipForm.seriesTooltipFormatter =
uniqWith(state.tooltipForm.seriesTooltipFormatter, isEqual) || []
} }
const removeAxis = (form: AxisEditForm) => { const removeAxis = (form: AxisEditForm) => {
const { axis, axisType } = form const { axis, axisType } = form