Merge pull request #8065 from dataease/pr@dev-v2@feat——rich-text

feat(图表): 富文本视图支持指数格式化 #7444
This commit is contained in:
王嘉豪 2024-02-19 19:01:31 +08:00 committed by GitHub
commit d1406a3686
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -55,6 +55,7 @@ import { storeToRefs } from 'pinia'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import ChartError from '@/views/chart/components/views/components/ChartError.vue'
import { useEmitt } from '@/hooks/web/useEmitt'
import { valueFormatter } from '@/views/chart/components/js/formatter'
const snapshotStore = snapshotStoreWithOut()
const errMsg = ref('')
const dvMainStore = dvMainStoreWithOut()
@ -389,9 +390,18 @@ const initCurFields = chartDetails => {
yDataeaseNamesCfg[yItem.dataeaseName] = yItem.formatterCfg
})
}
const valueFieldMap: Record<string, Axis> = chartDetails.yAxis.reduce((p, n) => {
p[n.dataeaseName] = n
return p
}, {})
for (const key in rowData) {
dataRowSelect.value[nameIdMap[key]] = rowData[key]
dataRowNameSelect.value[sourceFieldNameIdMap[key]] = rowData[key]
let rowDataValue = rowData[key]
const f = valueFieldMap[key]
if (f && f.formatterCfg) {
rowDataValue = valueFormatter(rowDataValue, f.formatterCfg)
}
dataRowNameSelect.value[sourceFieldNameIdMap[key]] = rowDataValue
}
}
element.value.propValue['innerType'] = chartDetails.type

View File

@ -82,7 +82,7 @@ watch(
},
{ deep: true }
)
const AXIS_FORMAT_VIEW = ['table-normal', 'table-info', 'table-pivot', 'indicator']
const AXIS_FORMAT_VIEW = ['table-normal', 'table-info', 'table-pivot', 'indicator', 'rich-text']
const showValueFormatter = computed<boolean>(() => {
return (
AXIS_FORMAT_VIEW.includes(props.chart.type) &&