win-chart 2.13.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +55 -7
  2. package/dist/cjs/components/ChartWrapper.cjs +39 -0
  3. package/dist/cjs/components/EarthChart.cjs +168 -0
  4. package/dist/cjs/components/GanttChart.cjs +302 -0
  5. package/dist/cjs/components/WinChart.cjs +125 -0
  6. package/dist/cjs/index.cjs +58 -0
  7. package/dist/cjs/types/index.cjs +51 -0
  8. package/dist/cjs/utils/const.cjs +68 -0
  9. package/dist/cjs/utils/data.cjs +9382 -0
  10. package/dist/cjs/utils/earthMockData.cjs +6017 -0
  11. package/dist/cjs/utils/getAreaSpec.cjs +143 -0
  12. package/dist/cjs/utils/getBarSpec.cjs +171 -0
  13. package/dist/cjs/utils/getChartOptions.cjs +78 -0
  14. package/dist/cjs/utils/getColumnSpec.cjs +127 -0
  15. package/dist/cjs/utils/getDualSpec.cjs +171 -0
  16. package/dist/cjs/utils/getFunnelSpec.cjs +89 -0
  17. package/dist/cjs/utils/getLineSpec.cjs +72 -0
  18. package/dist/cjs/utils/getPieSpec.cjs +140 -0
  19. package/dist/cjs/utils/getRadarSpec.cjs +100 -0
  20. package/dist/cjs/utils/tool.cjs +240 -0
  21. package/dist/esm/components/ChartWrapper.js +5 -0
  22. package/dist/esm/components/EarthChart.js +134 -0
  23. package/dist/esm/components/GanttChart.js +268 -0
  24. package/dist/esm/components/WinChart.js +79 -0
  25. package/dist/esm/index.js +6 -0
  26. package/dist/esm/types/index.js +17 -0
  27. package/dist/esm/utils/const.js +31 -0
  28. package/dist/esm/utils/data.js +9342 -0
  29. package/dist/esm/utils/earthMockData.js +5983 -0
  30. package/dist/esm/utils/getAreaSpec.js +106 -0
  31. package/dist/esm/utils/getBarSpec.js +134 -0
  32. package/dist/esm/utils/getChartOptions.js +44 -0
  33. package/dist/esm/utils/getColumnSpec.js +90 -0
  34. package/dist/esm/utils/getDualSpec.js +134 -0
  35. package/dist/esm/utils/getFunnelSpec.js +55 -0
  36. package/dist/esm/utils/getLineSpec.js +38 -0
  37. package/dist/esm/utils/getPieSpec.js +103 -0
  38. package/dist/esm/utils/getRadarSpec.js +66 -0
  39. package/dist/esm/utils/tool.js +146 -0
  40. package/dist/index.js +1219 -0
  41. package/dist/types/components/GanttChart.d.ts +0 -1
  42. package/dist/types/demos/DualSystemComparisonChart.d.ts +1 -0
  43. package/dist/types/demos/EastWestResourceComparisonChart.d.ts +1 -0
  44. package/dist/types/demos/PolicyGrowthChart.d.ts +1 -0
  45. package/dist/types/demos/PolicyOpennessChart.d.ts +1 -0
  46. package/dist/types/demos/PracticalUsageTrendChart.d.ts +1 -0
  47. package/dist/types/demos/index.d.ts +5 -0
  48. package/dist/types/types/index.d.ts +14 -14
  49. package/dist/types/utils/getAreaSpec.d.ts +1 -1
  50. package/dist/types/utils/getBarSpec.d.ts +1 -1
  51. package/dist/types/utils/getChartOptions.d.ts +1 -1
  52. package/dist/types/utils/getColumnSpec.d.ts +1 -1
  53. package/dist/types/utils/getDualSpec.d.ts +1 -1
  54. package/dist/types/utils/getFunnelSpec.d.ts +1 -1
  55. package/dist/types/utils/getLineSpec.d.ts +1 -1
  56. package/dist/types/utils/getPieSpec.d.ts +1 -1
  57. package/dist/types/utils/getRadarSpec.d.ts +1 -1
  58. package/dist/types/utils/tool.d.ts +59 -3
  59. package/package.json +33 -32
  60. package/dist/bundle.esm.js +0 -22
  61. package/dist/index.d.ts +0 -147
  62. package/dist/types/app.d.ts +0 -1
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ getFunnelOpt: ()=>getFunnelOpt
28
+ });
29
+ const external_tool_cjs_namespaceObject = require("./tool.cjs");
30
+ const getFunnelOpt = (winChartProps)=>{
31
+ const data = (0, external_tool_cjs_namespaceObject.dataDescOrder)(winChartProps.data)?.map((item)=>({
32
+ value: item.value ?? 0,
33
+ name: winChartProps.reserveValueWithLabelType ? item.label : item.type
34
+ })) ?? [];
35
+ const seriesConfig = {
36
+ type: 'funnel',
37
+ minSize: '20%',
38
+ left: 10,
39
+ top: 24,
40
+ width: '76%',
41
+ sort: 'descending',
42
+ data
43
+ };
44
+ return {
45
+ tooltip: {
46
+ trigger: 'item'
47
+ },
48
+ legend: {
49
+ bottom: 0,
50
+ type: 'scroll'
51
+ },
52
+ series: [
53
+ {
54
+ ...seriesConfig,
55
+ label: {
56
+ show: true,
57
+ position: 'outer',
58
+ formatter: '{c}'
59
+ }
60
+ },
61
+ {
62
+ ...seriesConfig,
63
+ emphasis: {
64
+ label: {
65
+ fontSize: 20
66
+ }
67
+ },
68
+ label: {
69
+ show: true,
70
+ position: 'inner',
71
+ color: '#fff',
72
+ formatter: (params)=>{
73
+ const currentIndex = params.dataIndex;
74
+ if (0 === currentIndex) return '100%';
75
+ const prevValue = data[currentIndex - 1].value;
76
+ return (0, external_tool_cjs_namespaceObject.handleToPercent)(params.value / prevValue);
77
+ }
78
+ }
79
+ }
80
+ ]
81
+ };
82
+ };
83
+ exports.getFunnelOpt = __webpack_exports__.getFunnelOpt;
84
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
85
+ "getFunnelOpt"
86
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
87
+ Object.defineProperty(exports, '__esModule', {
88
+ value: true
89
+ });
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ getLineOpt: ()=>getLineOpt
28
+ });
29
+ const external_tool_cjs_namespaceObject = require("./tool.cjs");
30
+ const getLineOpt = (winChartProps)=>{
31
+ const typeList = (0, external_tool_cjs_namespaceObject.getDataTypes)(winChartProps);
32
+ return {
33
+ tooltip: {
34
+ trigger: 'axis',
35
+ axisPointer: {
36
+ type: 'cross',
37
+ label: {
38
+ backgroundColor: '#999'
39
+ }
40
+ }
41
+ },
42
+ legend: {
43
+ bottom: 0,
44
+ type: 'scroll'
45
+ },
46
+ xAxis: (0, external_tool_cjs_namespaceObject.getXAxisOpt)(winChartProps),
47
+ yAxis: {
48
+ min: winChartProps.yStart?.[0]
49
+ },
50
+ series: typeList.map((type)=>({
51
+ name: type,
52
+ type: 'line',
53
+ smooth: false,
54
+ lineStyle: {
55
+ width: 2
56
+ },
57
+ showSymbol: true,
58
+ emphasis: {
59
+ focus: 'series'
60
+ },
61
+ label: (0, external_tool_cjs_namespaceObject.getSeriesLabelConfig)(winChartProps),
62
+ data: (0, external_tool_cjs_namespaceObject.getSeriesDataByType)(winChartProps, type)
63
+ }))
64
+ };
65
+ };
66
+ exports.getLineOpt = __webpack_exports__.getLineOpt;
67
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
68
+ "getLineOpt"
69
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
70
+ Object.defineProperty(exports, '__esModule', {
71
+ value: true
72
+ });
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ getPieCycleOpt: ()=>getPieCycleOpt,
28
+ getPieOpt: ()=>getPieOpt
29
+ });
30
+ const external_tool_cjs_namespaceObject = require("./tool.cjs");
31
+ const getPieOpt = (winChartProps)=>{
32
+ const total = (0, external_tool_cjs_namespaceObject.arraySum)(winChartProps.data?.map((item)=>item.value));
33
+ return {
34
+ tooltip: {
35
+ trigger: 'item'
36
+ },
37
+ legend: {
38
+ bottom: 0,
39
+ type: 'scroll'
40
+ },
41
+ series: [
42
+ {
43
+ top: -30,
44
+ type: 'pie',
45
+ radius: '50%',
46
+ data: (0, external_tool_cjs_namespaceObject.dataDescOrder)(winChartProps.data)?.map((item)=>({
47
+ value: item.value,
48
+ name: winChartProps.reserveValueWithLabelType ? item.label : item.type
49
+ })),
50
+ label: {
51
+ show: true,
52
+ fontSize: 12,
53
+ color: (0, external_tool_cjs_namespaceObject.getLabelColor)(winChartProps),
54
+ position: 'outside',
55
+ formatter: (data)=>(0, external_tool_cjs_namespaceObject.handleToPercent)(data.value / (total || 1))
56
+ },
57
+ emphasis: {
58
+ itemStyle: {
59
+ shadowBlur: 10,
60
+ shadowOffsetX: 0,
61
+ shadowColor: 'rgba(0, 0, 0, 0.5)'
62
+ }
63
+ }
64
+ }
65
+ ]
66
+ };
67
+ };
68
+ const getPieCycleOpt = (winChartProps)=>{
69
+ const total = (0, external_tool_cjs_namespaceObject.arraySum)(winChartProps.data?.map((item)=>item.value));
70
+ return {
71
+ tooltip: {
72
+ trigger: 'item'
73
+ },
74
+ legend: {
75
+ bottom: 0,
76
+ type: 'scroll'
77
+ },
78
+ series: [
79
+ {
80
+ top: -30,
81
+ type: 'pie',
82
+ radius: [
83
+ '60%',
84
+ '48%'
85
+ ],
86
+ data: (0, external_tool_cjs_namespaceObject.dataDescOrder)(winChartProps.data, winChartProps.sort)?.map((item)=>({
87
+ value: item.value,
88
+ name: winChartProps.reserveValueWithLabelType ? item.label : item.type
89
+ })),
90
+ label: {
91
+ show: true,
92
+ fontSize: 12,
93
+ color: (0, external_tool_cjs_namespaceObject.getLabelColor)(winChartProps),
94
+ position: 'outside',
95
+ formatter: (data)=>(0, external_tool_cjs_namespaceObject.handleToPercent)(data.value / (total || 1))
96
+ },
97
+ emphasis: {
98
+ itemStyle: {
99
+ shadowBlur: 10,
100
+ shadowOffsetX: 0,
101
+ shadowColor: 'rgba(0, 0, 0, 0.5)'
102
+ }
103
+ }
104
+ }
105
+ ],
106
+ graphic: [
107
+ {
108
+ type: 'text',
109
+ left: 'center',
110
+ top: winChartProps.cycleCenterConfig?.content?.top ?? 76,
111
+ style: {
112
+ text: winChartProps.cycleCenterConfig?.content?.value ?? Number(total.toFixed(2)).toString(),
113
+ fill: 'dark' === winChartProps.theme ? '#fff' : '#12161F',
114
+ fontFamily: 'roboto',
115
+ fontSize: winChartProps.cycleCenterConfig?.content?.fontSize ?? 28,
116
+ fontWeight: 'bold'
117
+ }
118
+ },
119
+ {
120
+ type: 'text',
121
+ left: 'center',
122
+ top: winChartProps.cycleCenterConfig?.title?.top ?? 112,
123
+ style: {
124
+ text: winChartProps.cycleCenterConfig?.title?.value ?? '总计',
125
+ fill: 'dark' === winChartProps.theme ? '#fff' : '#394252 ',
126
+ fontSize: winChartProps.cycleCenterConfig?.title?.fontSize ?? 14
127
+ }
128
+ }
129
+ ]
130
+ };
131
+ };
132
+ exports.getPieCycleOpt = __webpack_exports__.getPieCycleOpt;
133
+ exports.getPieOpt = __webpack_exports__.getPieOpt;
134
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
135
+ "getPieCycleOpt",
136
+ "getPieOpt"
137
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
138
+ Object.defineProperty(exports, '__esModule', {
139
+ value: true
140
+ });
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ getRadarOpt: ()=>getRadarOpt
28
+ });
29
+ const external_polished_namespaceObject = require("polished");
30
+ const external_const_cjs_namespaceObject = require("./const.cjs");
31
+ const external_tool_cjs_namespaceObject = require("./tool.cjs");
32
+ const getRadarOpt = (winChartProps)=>{
33
+ const typeList = (0, external_tool_cjs_namespaceObject.arrDeduplication)(winChartProps.data?.map((item)=>winChartProps.reserveValueWithLabelType ? item.label : item.type));
34
+ return {
35
+ tooltip: {
36
+ trigger: 'item'
37
+ },
38
+ legend: {
39
+ bottom: 0,
40
+ type: 'scroll'
41
+ },
42
+ radar: {
43
+ shape: 'circle',
44
+ radius: '60%',
45
+ indicator: (0, external_tool_cjs_namespaceObject.arrDeduplication)(winChartProps.data?.map((item)=>winChartProps.reserveValueWithLabelType ? item.type : item.label)).map((name)=>({
46
+ name
47
+ })),
48
+ axisName: {
49
+ color: '#5d677a'
50
+ },
51
+ splitArea: {
52
+ areaStyle: {
53
+ color: [
54
+ 'transparent'
55
+ ]
56
+ }
57
+ },
58
+ axisLine: {
59
+ lineStyle: {
60
+ color: 'rgba(226, 229, 235, .3)'
61
+ }
62
+ },
63
+ splitLine: {
64
+ lineStyle: {
65
+ color: '#e2e5eb',
66
+ type: 'dashed',
67
+ dashOffset: 1.5
68
+ }
69
+ }
70
+ },
71
+ series: [
72
+ {
73
+ type: 'radar',
74
+ data: typeList.map((name, index)=>({
75
+ name,
76
+ value: winChartProps.data?.filter((item)=>winChartProps.reserveValueWithLabelType ? item.label : item.type === name).map((item)=>item.value),
77
+ areaStyle: {
78
+ color: (0, external_polished_namespaceObject.rgba)(external_const_cjs_namespaceObject.COLOR_LIST[index], 0.2)
79
+ },
80
+ label: {
81
+ show: winChartProps.reserveValueWithLabelType,
82
+ formatter: (params)=>params.value?.toString()
83
+ }
84
+ })),
85
+ emphasis: {
86
+ lineStyle: {
87
+ width: 4
88
+ }
89
+ }
90
+ }
91
+ ]
92
+ };
93
+ };
94
+ exports.getRadarOpt = __webpack_exports__.getRadarOpt;
95
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
96
+ "getRadarOpt"
97
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
98
+ Object.defineProperty(exports, '__esModule', {
99
+ value: true
100
+ });
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ arraySum: ()=>arraySum,
28
+ getXAxisOpt: ()=>getXAxisOpt,
29
+ sortArrayByLabel: ()=>sortArrayByLabel,
30
+ getMainAxisLabels: ()=>getMainAxisLabels,
31
+ debounce: ()=>debounce,
32
+ getGradientColor: ()=>getGradientColor,
33
+ getLabelColor: ()=>getLabelColor,
34
+ handleMainAxisLabel: ()=>handleMainAxisLabel,
35
+ getExtraDataTypes: ()=>getExtraDataTypes,
36
+ mergeSeriesOption: ()=>mergeSeriesOption,
37
+ isNonEmptyArray: ()=>isNonEmptyArray,
38
+ sortArray: ()=>sortArray,
39
+ handleToPercent: ()=>handleToPercent,
40
+ dataDescOrder: ()=>dataDescOrder,
41
+ checkEntityArr: ()=>checkEntityArr,
42
+ getDataTypes: ()=>getDataTypes,
43
+ arrDeduplication: ()=>arrDeduplication,
44
+ getSeriesLabelConfig: ()=>getSeriesLabelConfig,
45
+ aggregateStackData: ()=>aggregateStackData,
46
+ handleSort: ()=>handleSort,
47
+ getSeriesDataByType: ()=>getSeriesDataByType
48
+ });
49
+ const external_echarts_namespaceObject = require("echarts");
50
+ const external_polished_namespaceObject = require("polished");
51
+ function isNonEmptyArray(data) {
52
+ return Array.isArray(data) && data.length > 0;
53
+ }
54
+ const handleToPercent = (value, num = 2)=>'number' == typeof value ? `${Number((100 * value).toFixed(num))}%` : '-%';
55
+ function arrDeduplication(data) {
56
+ if (Array.isArray(data)) return [
57
+ ...new Set(data)
58
+ ];
59
+ return [];
60
+ }
61
+ const arraySum = (list)=>{
62
+ if (Array.isArray(list) && 0 !== list.length) return list.reduce((a, b)=>{
63
+ const temp = Number(b);
64
+ return a + (Object.is(temp, NaN) ? 0 : temp);
65
+ }, 0);
66
+ return 0;
67
+ };
68
+ const checkEntityArr = (data)=>Array.isArray(data) && data.length > 0;
69
+ const dataDescOrder = (data, order = 'desc')=>{
70
+ if (Array.isArray(data) && 'asc' === order) {
71
+ const _data = JSON.parse(JSON.stringify(data));
72
+ return _data.sort((a, b)=>a.value - b.value);
73
+ }
74
+ if (Array.isArray(data) && 'desc' === order) {
75
+ const _data = JSON.parse(JSON.stringify(data));
76
+ return _data.sort((a, b)=>b.value - a.value);
77
+ }
78
+ return data;
79
+ };
80
+ const getMainAxisLabels = (winChartProps)=>{
81
+ const data = [
82
+ ...winChartProps.data ?? [],
83
+ ...winChartProps.extraData ?? []
84
+ ];
85
+ return arrDeduplication(data.map((item)=>item.label));
86
+ };
87
+ const getDataTypes = (winChartProps)=>arrDeduplication(winChartProps.data?.filter((item)=>!!item.type).map((item)=>item.type)) ?? [];
88
+ const getExtraDataTypes = (winChartProps)=>arrDeduplication(winChartProps.extraData?.filter((item)=>!!item.type).map((item)=>item.type)) ?? [];
89
+ const getSeriesDataByType = (winChartProps, type)=>{
90
+ const data = [
91
+ ...winChartProps.data ?? [],
92
+ ...winChartProps.extraData ?? []
93
+ ];
94
+ return getMainAxisLabels(winChartProps).map((label)=>data.find((item)=>item.type === type && item.label === label)?.value ?? 0);
95
+ };
96
+ const getSeriesLabelConfig = (winChartProps)=>winChartProps.showLabel ? {
97
+ show: true,
98
+ formatter: '{c}',
99
+ position: 'top',
100
+ showSymbol: true
101
+ } : {
102
+ show: false
103
+ };
104
+ const handleMainAxisLabel = (winChartProps, name)=>{
105
+ const configLength = winChartProps.xAxisLabelLength;
106
+ if ('number' == typeof configLength && name.length > configLength) return `${name.slice(0, configLength)}...`;
107
+ return name;
108
+ };
109
+ const getXAxisOpt = (winChartProps)=>({
110
+ boundaryGap: true,
111
+ axisTick: {
112
+ alignWithLabel: true
113
+ },
114
+ data: getMainAxisLabels(winChartProps),
115
+ axisLabel: {
116
+ rotate: winChartProps.xAxisLabelRotate,
117
+ formatter: (name)=>handleMainAxisLabel(winChartProps, name)
118
+ }
119
+ });
120
+ const getGradientColor = (winChartProps, color)=>{
121
+ const gradientColor = new external_echarts_namespaceObject.graphic.LinearGradient(0, 0, 0, 1, [
122
+ {
123
+ offset: 0,
124
+ color: (0, external_polished_namespaceObject.rgba)(color, 0.5)
125
+ },
126
+ {
127
+ offset: 1,
128
+ color: 'dark' === winChartProps.theme ? (0, external_polished_namespaceObject.rgba)('gray', 0.1) : '#fff'
129
+ }
130
+ ]);
131
+ return gradientColor;
132
+ };
133
+ const sortArray = (arr, order)=>{
134
+ if ('asc' === order) arr.sort((a, b)=>a.value - b.value);
135
+ else if ('desc' === order) arr.sort((a, b)=>b.value - a.value);
136
+ return arr;
137
+ };
138
+ const sortArrayByLabel = (arr, sortedLabels)=>{
139
+ arr.sort((a, b)=>{
140
+ const indexA = sortedLabels.indexOf(a.label);
141
+ const indexB = sortedLabels.indexOf(b.label);
142
+ return indexA - indexB;
143
+ });
144
+ return arr;
145
+ };
146
+ const handleSort = (winChartProps)=>{
147
+ const { data, extraData, sort } = winChartProps;
148
+ if (data && sort) {
149
+ const sortedData = sortArray([
150
+ ...data
151
+ ], sort);
152
+ const sortedLabels = arrDeduplication(sortedData.map((item)=>item.label));
153
+ const finalSortData = sortArrayByLabel(sortedData, sortedLabels);
154
+ const finalSortedExtraData = sortArrayByLabel([
155
+ ...extraData ?? []
156
+ ], sortedLabels);
157
+ return {
158
+ ...winChartProps,
159
+ data: finalSortData,
160
+ extraData: finalSortedExtraData
161
+ };
162
+ }
163
+ return winChartProps;
164
+ };
165
+ function debounce(func, delay) {
166
+ let timer = null;
167
+ return function(...args) {
168
+ clearTimeout(timer);
169
+ timer = setTimeout(()=>{
170
+ func.apply(globalThis, args);
171
+ }, delay);
172
+ };
173
+ }
174
+ const mergeSeriesOption = (option, seriesOption)=>{
175
+ if (isNonEmptyArray(option.series) && isNonEmptyArray(seriesOption)) seriesOption.forEach((config)=>{
176
+ option.series = option.series.map((item)=>({
177
+ ...item,
178
+ ...item.name === config.name && config
179
+ }));
180
+ });
181
+ return option;
182
+ };
183
+ const getLabelColor = (opt)=>'dark' === opt.theme ? 'rgba(255, 255, 255, 0.7)' : 'rgba(0, 0, 0, 0.7)';
184
+ function aggregateStackData(data) {
185
+ const result = data.reduce((acc, item)=>{
186
+ const { label, value } = item;
187
+ if (!acc[label]) acc[label] = 0;
188
+ if (value) acc[label] += Number(value);
189
+ return acc;
190
+ }, {});
191
+ const totals = Object.values(result).map((totalValue)=>parseFloat(totalValue.toFixed(2)));
192
+ return totals;
193
+ }
194
+ exports.aggregateStackData = __webpack_exports__.aggregateStackData;
195
+ exports.arrDeduplication = __webpack_exports__.arrDeduplication;
196
+ exports.arraySum = __webpack_exports__.arraySum;
197
+ exports.checkEntityArr = __webpack_exports__.checkEntityArr;
198
+ exports.dataDescOrder = __webpack_exports__.dataDescOrder;
199
+ exports.debounce = __webpack_exports__.debounce;
200
+ exports.getDataTypes = __webpack_exports__.getDataTypes;
201
+ exports.getExtraDataTypes = __webpack_exports__.getExtraDataTypes;
202
+ exports.getGradientColor = __webpack_exports__.getGradientColor;
203
+ exports.getLabelColor = __webpack_exports__.getLabelColor;
204
+ exports.getMainAxisLabels = __webpack_exports__.getMainAxisLabels;
205
+ exports.getSeriesDataByType = __webpack_exports__.getSeriesDataByType;
206
+ exports.getSeriesLabelConfig = __webpack_exports__.getSeriesLabelConfig;
207
+ exports.getXAxisOpt = __webpack_exports__.getXAxisOpt;
208
+ exports.handleMainAxisLabel = __webpack_exports__.handleMainAxisLabel;
209
+ exports.handleSort = __webpack_exports__.handleSort;
210
+ exports.handleToPercent = __webpack_exports__.handleToPercent;
211
+ exports.isNonEmptyArray = __webpack_exports__.isNonEmptyArray;
212
+ exports.mergeSeriesOption = __webpack_exports__.mergeSeriesOption;
213
+ exports.sortArray = __webpack_exports__.sortArray;
214
+ exports.sortArrayByLabel = __webpack_exports__.sortArrayByLabel;
215
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
216
+ "aggregateStackData",
217
+ "arrDeduplication",
218
+ "arraySum",
219
+ "checkEntityArr",
220
+ "dataDescOrder",
221
+ "debounce",
222
+ "getDataTypes",
223
+ "getExtraDataTypes",
224
+ "getGradientColor",
225
+ "getLabelColor",
226
+ "getMainAxisLabels",
227
+ "getSeriesDataByType",
228
+ "getSeriesLabelConfig",
229
+ "getXAxisOpt",
230
+ "handleMainAxisLabel",
231
+ "handleSort",
232
+ "handleToPercent",
233
+ "isNonEmptyArray",
234
+ "mergeSeriesOption",
235
+ "sortArray",
236
+ "sortArrayByLabel"
237
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
238
+ Object.defineProperty(exports, '__esModule', {
239
+ value: true
240
+ });
@@ -0,0 +1,5 @@
1
+ import { styled } from "styled-components";
2
+ const ChartWrapper = styled.div`
3
+ height: 100%;
4
+ `;
5
+ export { ChartWrapper };