@@ -3,6 +3,7 @@ import { computed, nextTick, onMounted, onUnmounted, watch } from 'vue'
33import { getChartInstance } from ' @/views/chat/component/index.ts'
44import type { BaseChart , ChartAxis , ChartData } from ' @/views/chat/component/BaseChart.ts'
55import { useEmitt } from ' @/utils/useEmitt.ts'
6+ import { filter , includes } from ' lodash-es'
67
78const params = withDefaults (
89 defineProps <{
@@ -15,6 +16,7 @@ const params = withDefaults(
1516 series? : Array <ChartAxis >
1617 multiQuotaName? : string | undefined
1718 showLabel? : boolean
19+ thousandsSeparatorList? : Array <string >
1820 }>(),
1921 {
2022 data : () => [],
@@ -24,6 +26,7 @@ const params = withDefaults(
2426 series : () => [],
2527 multiQuotaName: undefined ,
2628 showLabel: false ,
29+ thousandsSeparatorList : () => [],
2730 }
2831)
2932
@@ -34,21 +37,36 @@ const chartId = computed(() => {
3437const axis = computed (() => {
3538 const _list: Array <ChartAxis > = []
3639 params .columns .forEach ((column ) => {
37- _list .push ({ name: column .name , value: column .value })
40+ _list .push ({
41+ name: column .name ,
42+ value: column .value ,
43+ formatNumber: includes (params .thousandsSeparatorList , column .value ),
44+ })
3845 })
3946 params .x .forEach ((column ) => {
40- _list .push ({ name: column .name , value: column .value , type: ' x' })
47+ _list .push ({
48+ name: column .name ,
49+ value: column .value ,
50+ type: ' x' ,
51+ formatNumber: includes (params .thousandsSeparatorList , column .value ),
52+ })
4153 })
4254 params .y .forEach ((column ) => {
4355 _list .push ({
4456 name: column .name ,
4557 value: column .value ,
4658 type: ' y' ,
4759 ' multi-quota' : column [' multi-quota' ],
60+ formatNumber: includes (params .thousandsSeparatorList , column .value ),
4861 })
4962 })
5063 params .series .forEach ((column ) => {
51- _list .push ({ name: column .name , value: column .value , type: ' series' })
64+ _list .push ({
65+ name: column .name ,
66+ value: column .value ,
67+ type: ' series' ,
68+ formatNumber: includes (params .thousandsSeparatorList , column .value ),
69+ })
5270 })
5371 if (params .multiQuotaName ) {
5472 _list .push ({
@@ -67,16 +85,17 @@ function renderChart() {
6785 chartInstance = getChartInstance (params .type , chartId .value )
6886 if (chartInstance ) {
6987 chartInstance .showLabel = params .showLabel
70- chartInstance .init (axis .value , params .data )
88+ chartInstance .init (axis .value , params .data , params . thousandsSeparatorList )
7189 chartInstance .render ()
7290 }
7391}
7492
7593watch (
76- () => params .showLabel ,
94+ () => [ params .showLabel , params . thousandsSeparatorList ] ,
7795 () => {
7896 renderChart ()
79- }
97+ },
98+ { deep: true }
8099)
81100
82101function destroyChart() {
@@ -93,6 +112,10 @@ function getExcelData() {
93112 }
94113}
95114
115+ function getBaseAxis() {
116+ return filter (axis .value , (a ) => ! a .hidden )
117+ }
118+
96119useEmitt ({
97120 name: ' view-render-all' ,
98121 callback: renderChart ,
@@ -107,6 +130,7 @@ defineExpose({
107130 renderChart ,
108131 destroyChart ,
109132 getExcelData ,
133+ getBaseAxis ,
110134})
111135
112136onMounted (() => {
0 commit comments