diff --git a/frontend/src/views/chart/chart/common/common_antv.js b/frontend/src/views/chart/chart/common/common_antv.js
index 79c92db299..69a69be62d 100644
--- a/frontend/src/views/chart/chart/common/common_antv.js
+++ b/frontend/src/views/chart/chart/common/common_antv.js
@@ -132,6 +132,31 @@ export function getLabel(chart) {
fill: l.color,
fontSize: parseInt(l.fontSize)
}
+ // label value formatter
+ if (chart.type && chart.type !== 'waterfall') {
+ label.formatter = function(param) {
+ let yAxis
+ let res = param.value
+ try {
+ yAxis = JSON.parse(chart.yaxis)
+ } catch (e) {
+ yAxis = JSON.parse(JSON.stringify(chart.yaxis))
+ }
+
+ for (let i = 0; i < yAxis.length; i++) {
+ const f = yAxis[i]
+ if (f.name === param.category) {
+ if (f.formatterCfg) {
+ res = valueFormatter(param.value, f.formatterCfg)
+ } else {
+ res = valueFormatter(param.value, formatterItem)
+ }
+ break
+ }
+ }
+ return res
+ }
+ }
} else {
label = false
}
@@ -150,6 +175,68 @@ export function getTooltip(chart) {
const t = JSON.parse(JSON.stringify(customAttr.tooltip))
if (t.show) {
tooltip = {}
+ // tooltip value formatter
+ if (chart.type && chart.type !== 'waterfall') {
+ tooltip.formatter = function(param) {
+ let yAxis
+ let res
+ try {
+ yAxis = JSON.parse(chart.yaxis)
+ } catch (e) {
+ yAxis = JSON.parse(JSON.stringify(chart.yaxis))
+ }
+
+ let obj
+ if (chart.type === 'word-cloud') {
+ obj = { name: param.text, value: param.value }
+ for (let i = 0; i < yAxis.length; i++) {
+ const f = yAxis[i]
+ if (f.formatterCfg) {
+ res = valueFormatter(param.value, f.formatterCfg)
+ } else {
+ res = valueFormatter(param.value, formatterItem)
+ }
+ }
+ } else if (chart.type.includes('treemap')) {
+ obj = { name: param.name, value: param.value }
+ for (let i = 0; i < yAxis.length; i++) {
+ const f = yAxis[i]
+ if (f.formatterCfg) {
+ res = valueFormatter(param.value, f.formatterCfg)
+ } else {
+ res = valueFormatter(param.value, formatterItem)
+ }
+ }
+ } else if (chart.type.includes('pie') || chart.type.includes('funnel')) {
+ obj = { name: param.field, value: param.value }
+ for (let i = 0; i < yAxis.length; i++) {
+ const f = yAxis[i]
+ if (f.formatterCfg) {
+ res = valueFormatter(param.value, f.formatterCfg)
+ } else {
+ res = valueFormatter(param.value, formatterItem)
+ }
+ }
+ } else if (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter') || chart.type.includes('radar')) {
+ obj = { name: param.category, value: param.value }
+ for (let i = 0; i < yAxis.length; i++) {
+ const f = yAxis[i]
+ if (f.name === param.category) {
+ if (f.formatterCfg) {
+ res = valueFormatter(param.value, f.formatterCfg)
+ } else {
+ res = valueFormatter(param.value, formatterItem)
+ }
+ break
+ }
+ }
+ } else {
+ res = param.value
+ }
+ obj.value = res
+ return obj
+ }
+ }
} else {
tooltip = false
}
diff --git a/frontend/src/views/chart/components/drag-item/QuotaExtItem.vue b/frontend/src/views/chart/components/drag-item/QuotaExtItem.vue
index 8f093a08ce..6da2657a2e 100644
--- a/frontend/src/views/chart/components/drag-item/QuotaExtItem.vue
+++ b/frontend/src/views/chart/components/drag-item/QuotaExtItem.vue
@@ -100,7 +100,7 @@
{{ $t('chart.filter') }}...
-
+
{{ $t('chart.value_formatter') }}...
diff --git a/frontend/src/views/chart/components/drag-item/QuotaItem.vue b/frontend/src/views/chart/components/drag-item/QuotaItem.vue
index 95831b6a2f..80b65eb55b 100644
--- a/frontend/src/views/chart/components/drag-item/QuotaItem.vue
+++ b/frontend/src/views/chart/components/drag-item/QuotaItem.vue
@@ -100,7 +100,7 @@
{{ $t('chart.filter') }}...
-
+
{{ $t('chart.value_formatter') }}...