win-chart 1.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.
- package/.eslintrc.json +3 -0
- package/.prettierrc.json +5 -0
- package/README.md +0 -0
- package/localhost-key.pem +28 -0
- package/localhost.pem +25 -0
- package/package.json +65 -0
- package/rsbuild.config.ts +48 -0
- package/src/api/README.md +15 -0
- package/src/api/index.js +5 -0
- package/src/api/layout/index.js +32 -0
- package/src/api/request.ts +87 -0
- package/src/api/url-map/index.js +10 -0
- package/src/api/user/index.js +12 -0
- package/src/components/FilterContext.tsx +6 -0
- package/src/components/GlobalStyle.tsx +25 -0
- package/src/components/HalfScreenBrowser.tsx +95 -0
- package/src/components/ImgBox.tsx +19 -0
- package/src/components/JumpBtn.tsx +38 -0
- package/src/components/MCardWrapper.tsx +33 -0
- package/src/components/NoContent/index.tsx +85 -0
- package/src/components/ResponsiveReactGridLayout.tsx +218 -0
- package/src/components/SliderDecoration.tsx +27 -0
- package/src/components/VisionUserConfigContext.ts +6 -0
- package/src/components/WinMenu/README.md +11 -0
- package/src/components/WinMenu/WinHeader.tsx +5 -0
- package/src/components/WinMenu/components/ExtraBox.tsx +61 -0
- package/src/components/WinMenu/components/FullMenuBox.tsx +80 -0
- package/src/components/WinMenu/components/FullMenuContainer.tsx +50 -0
- package/src/components/WinMenu/components/FullMenuItem.tsx +128 -0
- package/src/components/WinMenu/components/LangSwitch.tsx +84 -0
- package/src/components/WinMenu/components/LogoBox.tsx +29 -0
- package/src/components/WinMenu/components/PinDialog.tsx +72 -0
- package/src/components/WinMenu/components/PinnedMenuBox.tsx +183 -0
- package/src/components/WinMenu/components/UserBox.tsx +83 -0
- package/src/components/WinMenu/hooks/useUserInfo.ts +21 -0
- package/src/components/WinMenu/hooks/useUserMenu.ts +35 -0
- package/src/components/WinMenu/index.tsx +100 -0
- package/src/components/WinMenu/services/WinService.ts +79 -0
- package/src/components/WinMenu/services/request.ts +53 -0
- package/src/components/WinMenu/utils/const.ts +80 -0
- package/src/components/WinMenu/utils/enum.ts +19 -0
- package/src/components/WinMenu/utils/interface.ts +61 -0
- package/src/components/WinMenu/utils/map.ts +39 -0
- package/src/components/WinMenu/utils/tool.ts +142 -0
- package/src/components/WinMenu/utils/type.ts +1 -0
- package/src/components/hover-view.tsx +48 -0
- package/src/components/icon.tsx +44 -0
- package/src/components/indicator-remark.tsx +25 -0
- package/src/components/none-content.tsx +93 -0
- package/src/components/panel-tab.tsx +150 -0
- package/src/components/panel-title-tab.tsx +60 -0
- package/src/components/win-card/components/ChartContent.tsx +47 -0
- package/src/components/win-card/components/Indicator.tsx +42 -0
- package/src/components/win-card/components/IndicatorArea.tsx +63 -0
- package/src/components/win-card/components/IndicatorInfo.tsx +78 -0
- package/src/components/win-card/components/MatterContent.tsx +121 -0
- package/src/components/win-card/components/MatterList.tsx +141 -0
- package/src/components/win-card/components/NoticeContent.tsx +73 -0
- package/src/components/win-card/components/NoticeList.tsx +68 -0
- package/src/components/win-card/components/SelectDecoration.tsx +34 -0
- package/src/components/win-card/components/WinRankContent.tsx +102 -0
- package/src/components/win-card/index.tsx +298 -0
- package/src/components/win-card/utils/interface.ts +12 -0
- package/src/components/win-card/utils/tool.ts +11 -0
- package/src/components/win-card-mobile/components/ChartContent.tsx +47 -0
- package/src/components/win-card-mobile/components/DualLineBar.tsx +61 -0
- package/src/components/win-card-mobile/components/Indicator.tsx +42 -0
- package/src/components/win-card-mobile/components/IndicatorArea.tsx +65 -0
- package/src/components/win-card-mobile/components/IndicatorInfo.tsx +83 -0
- package/src/components/win-card-mobile/components/SelectDecoration.tsx +28 -0
- package/src/components/win-card-mobile/index.tsx +235 -0
- package/src/components/win-card-mobile/utils/interface.ts +12 -0
- package/src/components/win-card-mobile/utils/tool.ts +9 -0
- package/src/components/win-chart/components/chart-wrapper.tsx +5 -0
- package/src/components/win-chart/index.tsx +59 -0
- package/src/components/win-chart/theme/win-dark.json +372 -0
- package/src/components/win-chart/theme/win-light.json +372 -0
- package/src/components/win-chart/utils/const.ts +37 -0
- package/src/components/win-chart/utils/getAreaSpec.ts +150 -0
- package/src/components/win-chart/utils/getBarSpec.ts +60 -0
- package/src/components/win-chart/utils/getChartOptions.ts +59 -0
- package/src/components/win-chart/utils/getColumnSpec.ts +112 -0
- package/src/components/win-chart/utils/getDualSpec.ts +79 -0
- package/src/components/win-chart/utils/getFunnelSpec.ts +70 -0
- package/src/components/win-chart/utils/getLineSpec.ts +53 -0
- package/src/components/win-chart/utils/getPieSpec.ts +124 -0
- package/src/components/win-chart/utils/getRadarSpec.ts +87 -0
- package/src/components/win-chart/utils/tool.ts +163 -0
- package/src/components/win-chart/utils/type.ts +96 -0
- package/src/components/win-icon/index.tsx +97 -0
- package/src/components/win-v/components/EmptyBox.tsx +9 -0
- package/src/components/win-v/components/VDialog.tsx +173 -0
- package/src/components/win-v/components/VDialogBtn.tsx +119 -0
- package/src/components/win-v/components/VDialogMsg.tsx +325 -0
- package/src/components/win-v/components/VInput.tsx +15 -0
- package/src/components/win-v/components/VRemindMsgList.tsx +303 -0
- package/src/components/win-v/components/VRobot.tsx +97 -0
- package/src/components/win-v/hooks/useVDialogCore.ts +102 -0
- package/src/components/win-v/hooks/useVDialogOperate.ts +132 -0
- package/src/components/win-v/hooks/useVDialogState.ts +52 -0
- package/src/components/win-v/hooks/useVRemindMsgShow.ts +15 -0
- package/src/components/win-v/index.tsx +205 -0
- package/src/components/win-wrappers/card-wrapper.tsx +103 -0
- package/src/components/win-wrappers/dot-wrapper.tsx +18 -0
- package/src/components/win-wrappers/iframe-wrapper.tsx +7 -0
- package/src/components/win-wrappers/request-wrapper.tsx +190 -0
- package/src/global.d.ts +53 -0
- package/src/hooks/useCardOptionList.ts +23 -0
- package/src/hooks/useCostFiltersDicList.ts +22 -0
- package/src/hooks/useFbiUrl.ts +22 -0
- package/src/hooks/useHalfScreenState.ts +50 -0
- package/src/hooks/useHasIntersected.ts +36 -0
- package/src/hooks/useIndicatorCardInfo.ts +26 -0
- package/src/hooks/useIndicatorCardQueryList.ts +22 -0
- package/src/hooks/useIndicatorClassifyList.ts +25 -0
- package/src/hooks/useIndicatorDetailsDateList.ts +22 -0
- package/src/hooks/useIndicatorDetailsInfo.ts +49 -0
- package/src/hooks/useIndicatorDetailsTrend.ts +25 -0
- package/src/hooks/useIndicatorDicList.ts +22 -0
- package/src/hooks/useIndicatorLabelList.ts +20 -0
- package/src/hooks/useIndicatorList.ts +24 -0
- package/src/hooks/useIndicatorRangeList.ts +20 -0
- package/src/hooks/useIndicatorTypeList.ts +20 -0
- package/src/hooks/useIndicatorUnitList.ts +21 -0
- package/src/hooks/useListenQuery.ts +29 -0
- package/src/hooks/useMobile.ts +58 -0
- package/src/hooks/useNotice.ts +42 -0
- package/src/hooks/useOrgLevelList.ts +23 -0
- package/src/hooks/usePageSelection.ts +121 -0
- package/src/hooks/usePageState.ts +22 -0
- package/src/hooks/usePendingList.ts +27 -0
- package/src/hooks/usePortalPageInfo.ts +43 -0
- package/src/hooks/useRefreshByLocationChange.ts +16 -0
- package/src/hooks/useReportIndicatorList.ts +21 -0
- package/src/hooks/useReportInfo.ts +45 -0
- package/src/hooks/useReportPersonList.ts +21 -0
- package/src/hooks/useScriptLoader.ts +22 -0
- package/src/hooks/useUnreadMsgList.ts +26 -0
- package/src/hooks/useUserAvatar.ts +23 -0
- package/src/hooks/useVReportInfo.ts +50 -0
- package/src/hooks/useVisionUserConfig.ts +25 -0
- package/src/hooks/useWorkbenchOptions.ts +63 -0
- package/src/index.tsx +20 -0
- package/src/services/CardService.ts +91 -0
- package/src/services/CommonService.ts +23 -0
- package/src/services/CostService.ts +56 -0
- package/src/services/DialogService.ts +74 -0
- package/src/services/IndicatorService.ts +406 -0
- package/src/services/PageService.ts +204 -0
- package/src/services/ReportService.ts +335 -0
- package/src/services/WorkbenchService.ts +411 -0
- package/src/styles/README.md +12 -0
- package/src/styles/index.scss +9 -0
- package/src/styles/mixins/index.scss +25 -0
- package/src/styles/next-cover.scss +4 -0
- package/src/styles/normalize.scss +27 -0
- package/src/styles/utilities/index.scss +5 -0
- package/src/styles/vars/index.scss +17 -0
- package/src/types/enum-workbench.ts +29 -0
- package/src/types/enum.ts +156 -0
- package/src/types/index.ts +19 -0
- package/src/types/indicator.ts +299 -0
- package/src/types/interface.ts +303 -0
- package/src/types/portal.ts +211 -0
- package/src/types/report.ts +28 -0
- package/src/types/type.ts +11 -0
- package/src/types/user.ts +28 -0
- package/src/utils/README.md +4 -0
- package/src/utils/arms.ts +59 -0
- package/src/utils/arr.ts +123 -0
- package/src/utils/const-workbench.ts +9 -0
- package/src/utils/const.ts +18 -0
- package/src/utils/index.ts +18 -0
- package/src/utils/init.ts +5 -0
- package/src/utils/map-workbench.ts +66 -0
- package/src/utils/map.ts +377 -0
- package/src/utils/number.ts +101 -0
- package/src/utils/page.ts +81 -0
- package/src/utils/str.ts +26 -0
- package/src/utils/tools.ts +44 -0
- package/src/utils/tree.ts +145 -0
- package/src/utils/url.ts +40 -0
- package/src/utils/util.ts +99 -0
- package/src/utils/workbench.ts +25 -0
- package/tsconfig.json +33 -0
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
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
|
+
}
|