Merge pull request #10649 from ulleo/dev-v2

fix(图表): 修复柱线组合图设置提示中没有使用的字段后导致图表无法显示的问题
This commit is contained in:
ulleo 2024-07-01 14:55:52 +08:00 committed by GitHub
commit bcb1ecb70b
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 { defaultTo, partition, union } from 'lodash-es' import { defaultTo, partition, map, includes } 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'
@ -41,13 +41,7 @@ const toolTip = computed(() => {
}) })
const emit = defineEmits(['onTooltipChange', 'onExtTooltipChange']) const emit = defineEmits(['onTooltipChange', 'onExtTooltipChange'])
const curSeriesFormatter = ref<DeepPartial<SeriesFormatter>>({}) const curSeriesFormatter = ref<DeepPartial<SeriesFormatter>>({})
const realQuota = ref<Axis[]>(inject('quotaData')) const quotaData = ref<Axis[]>(inject('quotaData'))
const yAxis = computed(() => {
return union(defaultTo(props.chart.yAxis, []), defaultTo(props.chart.yAxisExt, []))
})
const quotaData = computed<Axis[]>(() => {
return props.chart.type.includes('chart-mix') ? yAxis.value : realQuota.value
})
const showSeriesTooltipFormatter = computed(() => { const showSeriesTooltipFormatter = computed(() => {
return showProperty('seriesTooltipFormatter') && !batchOptStatus.value && props.chart.id return showProperty('seriesTooltipFormatter') && !batchOptStatus.value && props.chart.id
}) })
@ -116,6 +110,18 @@ const quotaAxis = computed(() => {
}) })
return result return result
}) })
const quotaAxisIds = computed(() => {
return map(quotaAxis.value, a => a.id)
})
function showOption(item) {
if (props.chart.type.includes('chart-mix')) {
return includes(quotaAxisIds.value, item.id)
}
return true
}
const extTooltip = computed(() => { const extTooltip = computed(() => {
const quotaIds = quotaAxis.value?.map(i => i.id) const quotaIds = quotaAxis.value?.map(i => i.id)
return state.tooltipForm.seriesTooltipFormatter.filter( return state.tooltipForm.seriesTooltipFormatter.filter(
@ -617,14 +623,14 @@ onMounted(() => {
/> />
</el-icon> </el-icon>
</template> </template>
<template v-for="item in state.tooltipForm.seriesTooltipFormatter" :key="item.seriesId">
<el-option <el-option
class="series-select-option" class="series-select-option"
:key="item.seriesId"
:value="item" :value="item"
:label="`${item.name}${ :label="`${item.name}${
item.summary !== '' ? '(' + t('chart.' + item.summary) + ')' : '' item.summary !== '' ? '(' + t('chart.' + item.summary) + ')' : ''
}`" }`"
v-for="item in state.tooltipForm.seriesTooltipFormatter" v-if="showOption(item)"
> >
<el-icon style="margin-right: 8px"> <el-icon style="margin-right: 8px">
<Icon <Icon
@ -635,6 +641,7 @@ onMounted(() => {
{{ item.name }} {{ item.name }}
{{ item.summary !== '' ? '(' + t('chart.' + item.summary) + ')' : '' }} {{ item.summary !== '' ? '(' + t('chart.' + item.summary) + ')' : '' }}
</el-option> </el-option>
</template>
</el-select> </el-select>
</el-form-item> </el-form-item>
<template v-if="curSeriesFormatter?.seriesId"> <template v-if="curSeriesFormatter?.seriesId">