win-chart 1.0.0 → 1.0.2

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 (184) hide show
  1. package/.vscode/settings.json +166 -0
  2. package/build/index.html +1 -0
  3. package/build/js/index.js +1 -0
  4. package/build/report-web.html +39 -0
  5. package/package.json +3 -1
  6. package/rsbuild.config.ts +5 -0
  7. package/tsconfig.json +1 -0
  8. package/src/api/README.md +0 -15
  9. package/src/api/index.js +0 -5
  10. package/src/api/layout/index.js +0 -32
  11. package/src/api/request.ts +0 -87
  12. package/src/api/url-map/index.js +0 -10
  13. package/src/api/user/index.js +0 -12
  14. package/src/components/FilterContext.tsx +0 -6
  15. package/src/components/GlobalStyle.tsx +0 -25
  16. package/src/components/HalfScreenBrowser.tsx +0 -95
  17. package/src/components/ImgBox.tsx +0 -19
  18. package/src/components/JumpBtn.tsx +0 -38
  19. package/src/components/MCardWrapper.tsx +0 -33
  20. package/src/components/NoContent/index.tsx +0 -85
  21. package/src/components/ResponsiveReactGridLayout.tsx +0 -218
  22. package/src/components/SliderDecoration.tsx +0 -27
  23. package/src/components/VisionUserConfigContext.ts +0 -6
  24. package/src/components/WinMenu/README.md +0 -11
  25. package/src/components/WinMenu/WinHeader.tsx +0 -5
  26. package/src/components/WinMenu/components/ExtraBox.tsx +0 -61
  27. package/src/components/WinMenu/components/FullMenuBox.tsx +0 -80
  28. package/src/components/WinMenu/components/FullMenuContainer.tsx +0 -50
  29. package/src/components/WinMenu/components/FullMenuItem.tsx +0 -128
  30. package/src/components/WinMenu/components/LangSwitch.tsx +0 -84
  31. package/src/components/WinMenu/components/LogoBox.tsx +0 -29
  32. package/src/components/WinMenu/components/PinDialog.tsx +0 -72
  33. package/src/components/WinMenu/components/PinnedMenuBox.tsx +0 -183
  34. package/src/components/WinMenu/components/UserBox.tsx +0 -83
  35. package/src/components/WinMenu/hooks/useUserInfo.ts +0 -21
  36. package/src/components/WinMenu/hooks/useUserMenu.ts +0 -35
  37. package/src/components/WinMenu/index.tsx +0 -100
  38. package/src/components/WinMenu/services/WinService.ts +0 -79
  39. package/src/components/WinMenu/services/request.ts +0 -53
  40. package/src/components/WinMenu/utils/const.ts +0 -80
  41. package/src/components/WinMenu/utils/enum.ts +0 -19
  42. package/src/components/WinMenu/utils/interface.ts +0 -61
  43. package/src/components/WinMenu/utils/map.ts +0 -39
  44. package/src/components/WinMenu/utils/tool.ts +0 -142
  45. package/src/components/WinMenu/utils/type.ts +0 -1
  46. package/src/components/hover-view.tsx +0 -48
  47. package/src/components/icon.tsx +0 -44
  48. package/src/components/indicator-remark.tsx +0 -25
  49. package/src/components/none-content.tsx +0 -93
  50. package/src/components/panel-tab.tsx +0 -150
  51. package/src/components/panel-title-tab.tsx +0 -60
  52. package/src/components/win-card/components/ChartContent.tsx +0 -47
  53. package/src/components/win-card/components/Indicator.tsx +0 -42
  54. package/src/components/win-card/components/IndicatorArea.tsx +0 -63
  55. package/src/components/win-card/components/IndicatorInfo.tsx +0 -78
  56. package/src/components/win-card/components/MatterContent.tsx +0 -121
  57. package/src/components/win-card/components/MatterList.tsx +0 -141
  58. package/src/components/win-card/components/NoticeContent.tsx +0 -73
  59. package/src/components/win-card/components/NoticeList.tsx +0 -68
  60. package/src/components/win-card/components/SelectDecoration.tsx +0 -34
  61. package/src/components/win-card/components/WinRankContent.tsx +0 -102
  62. package/src/components/win-card/index.tsx +0 -298
  63. package/src/components/win-card/utils/interface.ts +0 -12
  64. package/src/components/win-card/utils/tool.ts +0 -11
  65. package/src/components/win-card-mobile/components/ChartContent.tsx +0 -47
  66. package/src/components/win-card-mobile/components/DualLineBar.tsx +0 -61
  67. package/src/components/win-card-mobile/components/Indicator.tsx +0 -42
  68. package/src/components/win-card-mobile/components/IndicatorArea.tsx +0 -65
  69. package/src/components/win-card-mobile/components/IndicatorInfo.tsx +0 -83
  70. package/src/components/win-card-mobile/components/SelectDecoration.tsx +0 -28
  71. package/src/components/win-card-mobile/index.tsx +0 -235
  72. package/src/components/win-card-mobile/utils/interface.ts +0 -12
  73. package/src/components/win-card-mobile/utils/tool.ts +0 -9
  74. package/src/components/win-chart/components/chart-wrapper.tsx +0 -5
  75. package/src/components/win-chart/index.tsx +0 -59
  76. package/src/components/win-chart/theme/win-dark.json +0 -372
  77. package/src/components/win-chart/theme/win-light.json +0 -372
  78. package/src/components/win-chart/utils/const.ts +0 -37
  79. package/src/components/win-chart/utils/getAreaSpec.ts +0 -150
  80. package/src/components/win-chart/utils/getBarSpec.ts +0 -60
  81. package/src/components/win-chart/utils/getChartOptions.ts +0 -59
  82. package/src/components/win-chart/utils/getColumnSpec.ts +0 -112
  83. package/src/components/win-chart/utils/getDualSpec.ts +0 -79
  84. package/src/components/win-chart/utils/getFunnelSpec.ts +0 -70
  85. package/src/components/win-chart/utils/getLineSpec.ts +0 -53
  86. package/src/components/win-chart/utils/getPieSpec.ts +0 -124
  87. package/src/components/win-chart/utils/getRadarSpec.ts +0 -87
  88. package/src/components/win-chart/utils/tool.ts +0 -163
  89. package/src/components/win-chart/utils/type.ts +0 -96
  90. package/src/components/win-icon/index.tsx +0 -97
  91. package/src/components/win-v/components/EmptyBox.tsx +0 -9
  92. package/src/components/win-v/components/VDialog.tsx +0 -173
  93. package/src/components/win-v/components/VDialogBtn.tsx +0 -119
  94. package/src/components/win-v/components/VDialogMsg.tsx +0 -325
  95. package/src/components/win-v/components/VInput.tsx +0 -15
  96. package/src/components/win-v/components/VRemindMsgList.tsx +0 -303
  97. package/src/components/win-v/components/VRobot.tsx +0 -97
  98. package/src/components/win-v/hooks/useVDialogCore.ts +0 -102
  99. package/src/components/win-v/hooks/useVDialogOperate.ts +0 -132
  100. package/src/components/win-v/hooks/useVDialogState.ts +0 -52
  101. package/src/components/win-v/hooks/useVRemindMsgShow.ts +0 -15
  102. package/src/components/win-v/index.tsx +0 -205
  103. package/src/components/win-wrappers/card-wrapper.tsx +0 -103
  104. package/src/components/win-wrappers/dot-wrapper.tsx +0 -18
  105. package/src/components/win-wrappers/iframe-wrapper.tsx +0 -7
  106. package/src/components/win-wrappers/request-wrapper.tsx +0 -190
  107. package/src/global.d.ts +0 -53
  108. package/src/hooks/useCardOptionList.ts +0 -23
  109. package/src/hooks/useCostFiltersDicList.ts +0 -22
  110. package/src/hooks/useFbiUrl.ts +0 -22
  111. package/src/hooks/useHalfScreenState.ts +0 -50
  112. package/src/hooks/useHasIntersected.ts +0 -36
  113. package/src/hooks/useIndicatorCardInfo.ts +0 -26
  114. package/src/hooks/useIndicatorCardQueryList.ts +0 -22
  115. package/src/hooks/useIndicatorClassifyList.ts +0 -25
  116. package/src/hooks/useIndicatorDetailsDateList.ts +0 -22
  117. package/src/hooks/useIndicatorDetailsInfo.ts +0 -49
  118. package/src/hooks/useIndicatorDetailsTrend.ts +0 -25
  119. package/src/hooks/useIndicatorDicList.ts +0 -22
  120. package/src/hooks/useIndicatorLabelList.ts +0 -20
  121. package/src/hooks/useIndicatorList.ts +0 -24
  122. package/src/hooks/useIndicatorRangeList.ts +0 -20
  123. package/src/hooks/useIndicatorTypeList.ts +0 -20
  124. package/src/hooks/useIndicatorUnitList.ts +0 -21
  125. package/src/hooks/useListenQuery.ts +0 -29
  126. package/src/hooks/useMobile.ts +0 -58
  127. package/src/hooks/useNotice.ts +0 -42
  128. package/src/hooks/useOrgLevelList.ts +0 -23
  129. package/src/hooks/usePageSelection.ts +0 -121
  130. package/src/hooks/usePageState.ts +0 -22
  131. package/src/hooks/usePendingList.ts +0 -27
  132. package/src/hooks/usePortalPageInfo.ts +0 -43
  133. package/src/hooks/useRefreshByLocationChange.ts +0 -16
  134. package/src/hooks/useReportIndicatorList.ts +0 -21
  135. package/src/hooks/useReportInfo.ts +0 -45
  136. package/src/hooks/useReportPersonList.ts +0 -21
  137. package/src/hooks/useScriptLoader.ts +0 -22
  138. package/src/hooks/useUnreadMsgList.ts +0 -26
  139. package/src/hooks/useUserAvatar.ts +0 -23
  140. package/src/hooks/useVReportInfo.ts +0 -50
  141. package/src/hooks/useVisionUserConfig.ts +0 -25
  142. package/src/hooks/useWorkbenchOptions.ts +0 -63
  143. package/src/index.tsx +0 -20
  144. package/src/services/CardService.ts +0 -91
  145. package/src/services/CommonService.ts +0 -23
  146. package/src/services/CostService.ts +0 -56
  147. package/src/services/DialogService.ts +0 -74
  148. package/src/services/IndicatorService.ts +0 -406
  149. package/src/services/PageService.ts +0 -204
  150. package/src/services/ReportService.ts +0 -335
  151. package/src/services/WorkbenchService.ts +0 -411
  152. package/src/styles/README.md +0 -12
  153. package/src/styles/index.scss +0 -9
  154. package/src/styles/mixins/index.scss +0 -25
  155. package/src/styles/next-cover.scss +0 -4
  156. package/src/styles/normalize.scss +0 -27
  157. package/src/styles/utilities/index.scss +0 -5
  158. package/src/styles/vars/index.scss +0 -17
  159. package/src/types/enum-workbench.ts +0 -29
  160. package/src/types/enum.ts +0 -156
  161. package/src/types/index.ts +0 -19
  162. package/src/types/indicator.ts +0 -299
  163. package/src/types/interface.ts +0 -303
  164. package/src/types/portal.ts +0 -211
  165. package/src/types/report.ts +0 -28
  166. package/src/types/type.ts +0 -11
  167. package/src/types/user.ts +0 -28
  168. package/src/utils/README.md +0 -4
  169. package/src/utils/arms.ts +0 -59
  170. package/src/utils/arr.ts +0 -123
  171. package/src/utils/const-workbench.ts +0 -9
  172. package/src/utils/const.ts +0 -18
  173. package/src/utils/index.ts +0 -18
  174. package/src/utils/init.ts +0 -5
  175. package/src/utils/map-workbench.ts +0 -66
  176. package/src/utils/map.ts +0 -377
  177. package/src/utils/number.ts +0 -101
  178. package/src/utils/page.ts +0 -81
  179. package/src/utils/str.ts +0 -26
  180. package/src/utils/tools.ts +0 -44
  181. package/src/utils/tree.ts +0 -145
  182. package/src/utils/url.ts +0 -40
  183. package/src/utils/util.ts +0 -99
  184. package/src/utils/workbench.ts +0 -25
@@ -1,112 +0,0 @@
1
- import { IWinChartProps } from './type';
2
- import { arrDeduplication, getAxisOpt } from './tool';
3
- import * as echarts from 'echarts';
4
-
5
- /**
6
- * 柱状图
7
- * @param winChartProps
8
- * @returns
9
- */
10
- export const getColumnOpt = (
11
- winChartProps: IWinChartProps,
12
- ): echarts.EChartsOption => {
13
- const barTypeList = arrDeduplication<string>(
14
- winChartProps.data?.map((item) => item.type!),
15
- );
16
-
17
- return {
18
- tooltip: {
19
- trigger: 'axis',
20
- axisPointer: {
21
- type: 'cross',
22
- label: {
23
- backgroundColor: '#999',
24
- },
25
- },
26
- },
27
- legend: {
28
- bottom: 0,
29
- type: 'scroll',
30
- },
31
- xAxis: {
32
- ...getAxisOpt(winChartProps),
33
- axisPointer: {
34
- type: 'shadow',
35
- },
36
- },
37
- yAxis: {
38
- min: winChartProps.yStart?.[0],
39
- },
40
- series: barTypeList.map((name) => {
41
- return {
42
- name,
43
- type: 'bar',
44
- barGap: '30%',
45
- barCategoryGap: '30%',
46
- barMaxWidth: 8,
47
- data: winChartProps.data
48
- ?.filter((item) => item.type === name)
49
- .map((item) => ({
50
- value: item.value,
51
- itemStyle: {
52
- borderRadius:
53
- item.value > 0 ? [500, 500, 0, 0] : [0, 0, 500, 500],
54
- },
55
- })),
56
- };
57
- }),
58
- };
59
- };
60
-
61
- /**
62
- * 堆叠柱状图
63
- * @param winChartProps
64
- * @returns
65
- */
66
- export const getColumnStackOpt = (
67
- winChartProps: IWinChartProps,
68
- ): echarts.EChartsOption => {
69
- const barTypeList = arrDeduplication<string>(
70
- winChartProps.data?.map((item) => item.type!),
71
- );
72
-
73
- return {
74
- tooltip: {
75
- trigger: 'axis',
76
- axisPointer: {
77
- type: 'cross',
78
- label: {
79
- backgroundColor: '#999',
80
- },
81
- },
82
- },
83
- legend: {
84
- bottom: 0,
85
- type: 'scroll',
86
- },
87
- xAxis: {
88
- ...getAxisOpt(winChartProps),
89
- axisPointer: {
90
- type: 'shadow',
91
- },
92
- },
93
- yAxis: {
94
- min: winChartProps.yStart?.[0],
95
- },
96
- series: barTypeList.map((name) => {
97
- return {
98
- name,
99
- type: 'bar',
100
- stack: 'total',
101
- barGap: '30%',
102
- barCategoryGap: '30%',
103
- barMaxWidth: 8,
104
- data: winChartProps.data
105
- ?.filter((item) => item.type === name)
106
- .map((item) => ({
107
- value: item.value,
108
- })),
109
- };
110
- }),
111
- };
112
- };
@@ -1,79 +0,0 @@
1
- import { IWinChartProps } from './type';
2
- import { arrDeduplication, getAxisOpt } from './tool';
3
-
4
- /**
5
- * 双轴图(分组柱状 折线)
6
- * @param winChartProps
7
- * @returns
8
- */
9
- export const getDualOpt = (
10
- winChartProps: IWinChartProps,
11
- ): echarts.EChartsOption => {
12
- const barTypeList = arrDeduplication<string>(
13
- winChartProps.data?.map((item) => item.type!),
14
- );
15
-
16
- const lineTypeList = arrDeduplication<string>(
17
- winChartProps.extraData?.map((item) => item.type!),
18
- );
19
-
20
- return {
21
- tooltip: {
22
- trigger: 'axis',
23
- axisPointer: {
24
- type: 'cross',
25
- crossStyle: {
26
- color: '#999',
27
- },
28
- },
29
- },
30
- legend: {
31
- bottom: 0,
32
- type: 'scroll',
33
- },
34
- xAxis: {
35
- ...getAxisOpt(winChartProps),
36
- axisPointer: {
37
- type: 'shadow',
38
- },
39
- },
40
- yAxis: [
41
- {
42
- alignTicks: true,
43
- min: winChartProps.yStart?.[0],
44
- },
45
- {
46
- alignTicks: true,
47
- min: winChartProps.yStart?.[1],
48
- },
49
- ],
50
- series: [
51
- ...barTypeList.map((name) => ({
52
- name,
53
- type: 'bar' as any,
54
- barGap: '30%',
55
- barCategoryGap: '30%',
56
- barMaxWidth: 8,
57
- data: winChartProps.data
58
- ?.filter((item) => item.type === name)
59
- .map((item) => ({
60
- value: item.value,
61
- itemStyle: {
62
- borderRadius:
63
- item.value > 0 ? [500, 500, 0, 0] : [0, 0, 500, 500],
64
- },
65
- })),
66
- })),
67
- ...lineTypeList.map((name) => ({
68
- name,
69
- type: 'line' as any,
70
- smooth: true,
71
- yAxisIndex: 1,
72
- showSymbol: false,
73
- data: winChartProps.extraData
74
- ?.filter((item) => item.type === name)
75
- .map((item) => item.value),
76
- })),
77
- ],
78
- };
79
- };
@@ -1,70 +0,0 @@
1
- import { dataDescOrder, handleToPercent } from './tool';
2
- import { IWinChartProps } from './type';
3
- import * as echarts from 'echarts';
4
-
5
- /**
6
- * 漏斗图
7
- * @param winChartProps
8
- * @returns
9
- */
10
- export const getFunnelOpt = (
11
- winChartProps: IWinChartProps,
12
- ): echarts.EChartsOption => {
13
- const data =
14
- dataDescOrder(winChartProps.data)?.map((item) => ({
15
- value: item.value ?? 0,
16
- name: item.type,
17
- })) ?? [];
18
-
19
- const seriesConfig: echarts.FunnelSeriesOption = {
20
- type: 'funnel',
21
- minSize: '20%',
22
- left: 10,
23
- top: 24,
24
- width: '76%',
25
- sort: 'descending',
26
- data,
27
- };
28
-
29
- return {
30
- tooltip: {
31
- trigger: 'item',
32
- },
33
- legend: {
34
- bottom: 0,
35
- type: 'scroll',
36
- },
37
- series: [
38
- {
39
- ...seriesConfig,
40
- label: {
41
- show: true,
42
- position: 'outer',
43
- formatter: '{c}',
44
- },
45
- },
46
- {
47
- ...seriesConfig,
48
- emphasis: {
49
- label: {
50
- fontSize: 20,
51
- },
52
- },
53
- label: {
54
- show: true,
55
- position: 'inner',
56
- color: '#fff',
57
- formatter: (params) => {
58
- const currentIndex = params.dataIndex;
59
- if (currentIndex === 0) {
60
- return '100%';
61
- }
62
- const prevValue = data[currentIndex - 1].value;
63
-
64
- return handleToPercent((params.value as number) / prevValue);
65
- },
66
- },
67
- },
68
- ],
69
- };
70
- };
@@ -1,53 +0,0 @@
1
- import { IWinChartProps } from './type';
2
- import { arrDeduplication, getAxisOpt } from './tool';
3
- import * as echarts from 'echarts';
4
-
5
- /**
6
- * 折线图
7
- * @param winChartProps
8
- * @returns
9
- */
10
- export const getLineOpt = (
11
- winChartProps: IWinChartProps,
12
- ): echarts.EChartsOption => {
13
- const typeList = arrDeduplication<string>(
14
- winChartProps.data?.map((item) => item.type!),
15
- );
16
-
17
- return {
18
- tooltip: {
19
- trigger: 'axis',
20
- axisPointer: {
21
- type: 'cross',
22
- label: {
23
- backgroundColor: '#999',
24
- },
25
- },
26
- },
27
- legend: {
28
- bottom: 0,
29
- type: 'scroll',
30
- },
31
- xAxis: getAxisOpt(winChartProps),
32
- yAxis: {
33
- min: winChartProps.yStart?.[0],
34
- },
35
- series: typeList.map((name) => {
36
- return {
37
- name,
38
- type: 'line',
39
- smooth: false,
40
- lineStyle: {
41
- width: 2,
42
- },
43
- showSymbol: true,
44
- emphasis: {
45
- focus: 'series',
46
- },
47
- data: winChartProps.data
48
- ?.filter((item) => item.type === name)
49
- .map((item) => item.value),
50
- };
51
- }),
52
- };
53
- };
@@ -1,124 +0,0 @@
1
- import { arraySum, dataDescOrder, handleToPercent } from './tool';
2
- import { ICharInfo, IWinChartProps } from './type';
3
-
4
- /**
5
- * 饼图
6
- * @param winChartProps
7
- * @returns
8
- */
9
- export const getPieOpt = (
10
- winChartProps: IWinChartProps,
11
- ): echarts.EChartsOption => {
12
- const total = arraySum(winChartProps.data?.map((item) => item.value));
13
-
14
- return {
15
- tooltip: {
16
- trigger: 'item',
17
- },
18
- legend: {
19
- bottom: 0,
20
- type: 'scroll',
21
- },
22
- series: [
23
- {
24
- top: -30,
25
- type: 'pie',
26
- radius: '50%',
27
- data: dataDescOrder(winChartProps.data)?.map((item) => ({
28
- value: item.value,
29
- name: winChartProps.reserveValueWithLabelType
30
- ? item.label
31
- : item.type,
32
- })),
33
- label: {
34
- show: true,
35
- fontSize: 12, // 字体大小
36
- color: 'rgba(0, 0, 0, 0.7)', // 字体颜色
37
- position: 'outside', // 标签位置,可选项有 'inside'、'outside'、'center' 等
38
- formatter: (data: any) => {
39
- return handleToPercent(data.value / total);
40
- },
41
- },
42
- emphasis: {
43
- itemStyle: {
44
- shadowBlur: 10,
45
- shadowOffsetX: 0,
46
- shadowColor: 'rgba(0, 0, 0, 0.5)',
47
- },
48
- },
49
- },
50
- ],
51
- };
52
- };
53
-
54
- /**
55
- * 环图
56
- * @param winChartProps
57
- * @returns
58
- */
59
- export const getPieCycleOpt = (
60
- winChartProps: IWinChartProps,
61
- ): echarts.EChartsOption => {
62
- const total = arraySum(winChartProps.data?.map((item) => item.value));
63
-
64
- return {
65
- tooltip: {
66
- trigger: 'item',
67
- },
68
- legend: {
69
- bottom: 0,
70
- type: 'scroll',
71
- },
72
- series: [
73
- {
74
- top: -30,
75
- type: 'pie',
76
- radius: ['60%', '48%'],
77
- data: dataDescOrder(winChartProps.data)?.map((item) => ({
78
- value: item.value,
79
- name: item.type,
80
- })),
81
- label: {
82
- show: true,
83
- fontSize: 12, // 字体大小
84
- color: 'rgba(0, 0, 0, 0.7)', // 字体颜色
85
- position: 'outside', // 标签位置,可选项有 'inside'、'outside'、'center' 等
86
- formatter: (data: any) => {
87
- return handleToPercent(data.value / total);
88
- },
89
- },
90
- emphasis: {
91
- itemStyle: {
92
- shadowBlur: 10,
93
- shadowOffsetX: 0,
94
- shadowColor: 'rgba(0, 0, 0, 0.5)',
95
- },
96
- },
97
- },
98
- ],
99
- graphic: [
100
- {
101
- type: 'text',
102
- left: 'center',
103
- top: 76,
104
- style: {
105
- text: Number(total.toFixed(2)).toString(),
106
- fill: 'rgba(0, 0, 0, .7)', // 文字颜色
107
- fontSize: 28, // 文字大小
108
- fontWeight: 'bold', // 文字粗细
109
- },
110
- },
111
- {
112
- type: 'text',
113
- left: 'center',
114
- top: 112,
115
- style: {
116
- text: '总计',
117
- fill: '#828B9E', // 文字颜色
118
- fontSize: 12, // 文字大小
119
- fontWeight: 'bold', // 文字粗细
120
- },
121
- },
122
- ],
123
- };
124
- };
@@ -1,87 +0,0 @@
1
- import { rgba } from 'polished';
2
- import { COLOR_LIST } from './const';
3
- import { arrDeduplication } from './tool';
4
- import { IWinChartProps } from './type';
5
-
6
- /**
7
- * 雷达图
8
- * @param winChartProps
9
- * @returns
10
- */
11
- export const getRadarOpt = (
12
- winChartProps: IWinChartProps,
13
- ): echarts.EChartsOption => {
14
- const typeList = arrDeduplication<string>(
15
- winChartProps.data?.map((item) =>
16
- winChartProps.reserveValueWithLabelType ? item.label : item.type!,
17
- ),
18
- );
19
-
20
- return {
21
- tooltip: {
22
- trigger: 'item',
23
- },
24
- legend: {
25
- bottom: 0,
26
- type: 'scroll',
27
- },
28
- radar: {
29
- shape: 'circle',
30
- radius: '60%',
31
- indicator: arrDeduplication(
32
- winChartProps.data?.map((item) =>
33
- winChartProps.reserveValueWithLabelType ? item.type : item.label,
34
- ),
35
- ).map((name) => ({ name })),
36
- axisName: {
37
- color: '#5d677a',
38
- },
39
- splitArea: {
40
- areaStyle: {
41
- color: ['transparent'],
42
- },
43
- },
44
- axisLine: {
45
- lineStyle: {
46
- color: 'rgba(226, 229, 235, .3)',
47
- },
48
- },
49
- splitLine: {
50
- lineStyle: {
51
- color: '#e2e5eb',
52
- type: 'dashed',
53
- dashOffset: 1.5,
54
- },
55
- },
56
- },
57
- series: [
58
- {
59
- type: 'radar',
60
- data: typeList.map((name, index) => ({
61
- name,
62
- value: winChartProps.data
63
- ?.filter((item) =>
64
- winChartProps.reserveValueWithLabelType
65
- ? item.label
66
- : item.type! === name,
67
- )
68
- .map((item) => item.value),
69
- areaStyle: {
70
- color: rgba(COLOR_LIST[index], 0.2),
71
- },
72
- label: {
73
- show: winChartProps.reserveValueWithLabelType,
74
- formatter: (params) => {
75
- return params.value?.toString();
76
- },
77
- },
78
- })),
79
- emphasis: {
80
- lineStyle: {
81
- width: 4,
82
- },
83
- },
84
- },
85
- ],
86
- };
87
- };
@@ -1,163 +0,0 @@
1
- import { ICharInfo, IWinChartProps } from './type';
2
-
3
- /**
4
- * 数据转百分比
5
- * @param value
6
- * @param num
7
- */
8
- export const handleToPercent = (value: unknown, num = 2) =>
9
- typeof value === 'number' ? `${Number((value * 100).toFixed(num))}%` : '-%';
10
-
11
- /**
12
- * 数组去重
13
- * @param data
14
- * @returns
15
- */
16
- export function arrDeduplication<T>(data?: T[]) {
17
- if (Array.isArray(data)) {
18
- return [...new Set(data)];
19
- }
20
-
21
- return [];
22
- }
23
-
24
- /**
25
- * 数组求和
26
- * @param list
27
- */
28
- export const arraySum = (list?: number[]) => {
29
- if (Array.isArray(list) && list.length !== 0) {
30
- return list.reduce((a, b) => {
31
- const temp = Number(b);
32
- return a + (!Object.is(temp, NaN) ? temp : 0);
33
- }, 0);
34
- }
35
- return 0;
36
- };
37
-
38
- /**
39
- * 判断是否为一个有效数组(有值,并且长度大于 0)
40
- * @param data
41
- * @returns
42
- */
43
- export const checkEntityArr = (data: unknown) =>
44
- Array.isArray(data) && data.length > 0;
45
-
46
- /**
47
- * 处理数据降序
48
- * @param data
49
- * @returns
50
- */
51
- export const dataDescOrder = (data?: ICharInfo[]) => {
52
- if (Array.isArray(data)) {
53
- return data.sort((a, b) => b.value - a.value);
54
- }
55
-
56
- return data;
57
- };
58
-
59
- /**
60
- * 获取 X 轴配置
61
- * @param winChartProps
62
- * @returns
63
- */
64
- export const getAxisOpt = (
65
- winChartProps: IWinChartProps,
66
- ): echarts.XAXisComponentOption => {
67
- return {
68
- boundaryGap: true,
69
- axisTick: {
70
- alignWithLabel: true,
71
- },
72
- data: arrDeduplication(winChartProps.data?.map((item) => item.label)),
73
- axisLabel: {
74
- rotate: winChartProps.xAxisLabelRotate,
75
- formatter: (name: string) => {
76
- const configLength = winChartProps.xAxisLabelLength;
77
- if (typeof configLength === 'number' && name.length > configLength) {
78
- return `${name.slice(0, configLength)}...`;
79
- }
80
-
81
- return name;
82
- },
83
- },
84
- };
85
- };
86
-
87
- /**
88
- * 根据 value 排序
89
- * @param arr
90
- * @param order
91
- * @returns
92
- */
93
- export const sortArray = (arr: ICharInfo[], order: 'asc' | 'desc') => {
94
- if (order === 'asc') {
95
- // 升序
96
- arr.sort((a, b) => {
97
- return a.value - b.value;
98
- });
99
- } else if (order === 'desc') {
100
- // 降序
101
- arr.sort((a, b) => {
102
- return b.value - a.value;
103
- });
104
- }
105
-
106
- return arr;
107
- };
108
-
109
- /**
110
- * 根据 label 排序
111
- * @param arr
112
- * @param sortedLabels
113
- * @returns
114
- */
115
- export const sortArrayByLabel = (arr: ICharInfo[], sortedLabels: string[]) => {
116
- arr.sort((a, b) => {
117
- const indexA = sortedLabels.indexOf(a.label);
118
- const indexB = sortedLabels.indexOf(b.label);
119
- return indexA - indexB;
120
- });
121
-
122
- return arr;
123
- };
124
-
125
- /**
126
- * 处理数据排序
127
- * @param winChartProps
128
- * @returns
129
- */
130
- export const handleSort = (winChartProps: IWinChartProps) => {
131
- const { data, extraData, sort } = winChartProps;
132
- if (data && sort) {
133
- // 1. 整体排序
134
- const sortedData = sortArray([...data], sort);
135
- const sortedLabels = arrDeduplication(sortedData.map((item) => item.label));
136
-
137
- // 2. 根据标签二次排序
138
- const finalSortData = sortArrayByLabel(sortedData, sortedLabels);
139
- const finalSortedExtraData = sortArrayByLabel(
140
- [...(extraData ?? [])],
141
- sortedLabels,
142
- );
143
-
144
- return {
145
- ...winChartProps,
146
- data: finalSortData,
147
- extraData: finalSortedExtraData,
148
- };
149
- }
150
-
151
- return winChartProps;
152
- };
153
-
154
- export function debounce(func: Function, delay: number): Function {
155
- let timer: NodeJS.Timeout;
156
-
157
- return function (...args: any[]) {
158
- clearTimeout(timer);
159
- timer = setTimeout(() => {
160
- func.apply(globalThis, args);
161
- }, delay);
162
- };
163
- }