From 4a09ed1ae4f8dce0b12ab08cece2c5eb4d1418f4 Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Thu, 20 Feb 2025 20:11:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E6=8C=87=E6=A0=87=E5=BF=AB=E9=80=9F=E8=AE=A1=E7=AE=97=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E4=B8=8D=E6=94=AF=E6=8C=81=E7=9A=84=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E6=8C=87=E6=A0=87=E7=B4=AF=E5=8A=A0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E7=BD=AE=E7=81=B0=EF=BC=8C=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=90=8C=E7=8E=AF=E6=AF=94=E6=97=B6=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=80=89=E6=8B=A9=E7=AC=AC=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=90=8C=E6=AF=94=E7=B1=BB=E5=9E=8B=E3=80=81=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=90=8C=E7=8E=AF=E6=AF=94=E5=90=8E=E4=B8=8D?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/editor/drag-item/QuotaItem.vue | 38 +++++++++++++------ .../drag-item/components/CompareEdit.vue | 10 ++--- .../src/views/chart/components/js/util.ts | 27 +++++++++++++ 3 files changed, 57 insertions(+), 18 deletions(-) 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