diff --git a/core/core-frontend/src/views/chart/components/editor/drag-item/QuotaItem.vue b/core/core-frontend/src/views/chart/components/editor/drag-item/QuotaItem.vue index 52adaddbad..2550dde6e0 100644 --- a/core/core-frontend/src/views/chart/components/editor/drag-item/QuotaItem.vue +++ b/core/core-frontend/src/views/chart/components/editor/drag-item/QuotaItem.vue @@ -15,7 +15,7 @@ import { useI18n } from '@/hooks/web/useI18n' import { computed, onMounted, reactive, ref, toRefs, watch } from 'vue' import { formatterItem } from '@/views/chart/components/js/formatter' import { getItemType, resetValueFormatter } from '@/views/chart/components/editor/drag-item/utils' -import { quotaViews } from '@/views/chart/components/js/util' +import { quotaViews, notSupportAccumulateViews } from '@/views/chart/components/js/util' import { SUPPORT_Y_M } from '@/views/chart/components/editor/util/chart' import { fieldType } from '@/utils/attr' import { iconFieldMap } from '@/components/icon-group/field-list' @@ -27,7 +27,8 @@ const tagType = ref('success') const state = reactive({ formatterItem: formatterItem, disableEditCompare: false, - quotaViews: quotaViews + quotaViews: quotaViews, + notSupportAccumulateViews: notSupportAccumulateViews }) const props = defineProps({ @@ -93,6 +94,13 @@ watch( () => props.chart, () => { isEnableCompare() + // 不支持累加计算的图表,自动设置快速计算为无 + if ( + state.notSupportAccumulateViews.indexOf(chart.value.type) > -1 && + item.value.compareCalc.type === 'accumulate' + ) { + quickCalc({ type: 'none' }) + } }, { deep: true } ) @@ -318,6 +326,9 @@ const showSort = computed(() => { ) }) +// 同环比计算类型 +const yoyLabel = ['day_mom', 'month_yoy', 'year_yoy', 'month_mom', 'year_mom'] + onMounted(() => { isEnableCompare() getItemTagType() @@ -651,26 +662,30 @@ onMounted(() => { :disabled="state.disableEditCompare" :command="beforeQuickCalc('setting')" > - {{ t('chart.yoy_label') }} - - + - {{ t('chart.percent') }} @@ -678,16 +693,17 @@ onMounted(() => { > - + - {{ t('chart.accumulate') }} @@ -697,7 +713,7 @@ onMounted(() => { > - + diff --git a/core/core-frontend/src/views/chart/components/editor/drag-item/components/CompareEdit.vue b/core/core-frontend/src/views/chart/components/editor/drag-item/components/CompareEdit.vue index f64d3a0fc7..3211d5007c 100644 --- a/core/core-frontend/src/views/chart/components/editor/drag-item/components/CompareEdit.vue +++ b/core/core-frontend/src/views/chart/components/editor/drag-item/components/CompareEdit.vue @@ -204,7 +204,8 @@ const initFieldList = () => { compareItem.value.compareCalc.field = state.fieldList[0].id } } - +// 同环比计算类型 +const yoyLabel = ['day_mom', 'month_yoy', 'year_yoy', 'month_mom', 'year_mom'] // 获得不同字段格式对应能计算的同环比列表 const initCompareType = () => { const checkedField = state.fieldList.filter(ele => ele.id === compareItem.value.compareCalc.field) @@ -226,12 +227,7 @@ const initCompareType = () => { state.compareList = [] } // 如果没有选中一个同环比类型,则默认选中第一个 - if ( - (!compareItem.value.compareCalc.type || - compareItem.value.compareCalc.type === '' || - compareItem.value.compareCalc.type === 'none') && - state.compareList.length > 0 - ) { + if (!yoyLabel.includes(compareItem.value.compareCalc.type) && state.compareList.length > 0) { compareItem.value.compareCalc.type = state.compareList[0].value } } diff --git a/core/core-frontend/src/views/chart/components/js/util.ts b/core/core-frontend/src/views/chart/components/js/util.ts index a9bf45330f..595a29fbb7 100644 --- a/core/core-frontend/src/views/chart/components/js/util.ts +++ b/core/core-frontend/src/views/chart/components/js/util.ts @@ -241,6 +241,33 @@ export function getRemark(chart) { } export const quotaViews = ['label', 'richTextView', 'indicator', 'gauge', 'liquid'] +// 地图 +const mapChartTypes = ['bubble-map', 'flow-map', 'heat-map', 'map', 'symbolic-map'] +// 分布图 +const distributionChartTypes = [ + 'pie', + 'pie-donut', + 'pie-rose', + 'pie-donut-rose', + 'radar', + 'treemap', + 'word-cloud' +] +// 关系图 +const relationChartTypes = ['scatter', 'quadrant', 'funnel', 'sankey', 'circle-packing'] +// 不支持指标累加的图表 +export const notSupportAccumulateViews = [ + ...quotaViews, + ...mapChartTypes, + ...distributionChartTypes, + ...relationChartTypes, + 'table-info', + 't-heatmap', + 'percentage-bar-stack', + 'percentage-bar-stack-horizontal', + 'progress-bar', + 'stock-line' +] export function handleEmptyDataStrategy(chart: Chart, options: O): O { const { data } = options as unknown as Options