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,83 @@
|
|
|
1
|
+
import { IStyleProps } from '@/types';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { css, styled } from 'styled-components';
|
|
4
|
+
import { UnitWrapper } from 'src/components/win-wrappers/card-wrapper';
|
|
5
|
+
import { useHalfScreenDispatch } from '@/hooks/useHalfScreenState';
|
|
6
|
+
|
|
7
|
+
interface IProps extends IStyleProps {
|
|
8
|
+
label: string;
|
|
9
|
+
value: ReactNode;
|
|
10
|
+
unit: string;
|
|
11
|
+
extraLabel?: string;
|
|
12
|
+
extraValue?: ReactNode;
|
|
13
|
+
extraValueColor?: string;
|
|
14
|
+
jumpUrl?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const IndicatorInfo = ({
|
|
18
|
+
label,
|
|
19
|
+
value,
|
|
20
|
+
unit,
|
|
21
|
+
extraLabel,
|
|
22
|
+
extraValue,
|
|
23
|
+
extraValueColor,
|
|
24
|
+
jumpUrl,
|
|
25
|
+
...args
|
|
26
|
+
}: Partial<IProps>) => {
|
|
27
|
+
const halfScreenDispatch = useHalfScreenDispatch();
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div {...args}>
|
|
31
|
+
<LabelWrapper>
|
|
32
|
+
<div
|
|
33
|
+
data-value
|
|
34
|
+
onClick={() => {
|
|
35
|
+
halfScreenDispatch.setState({
|
|
36
|
+
show: true,
|
|
37
|
+
src: jumpUrl,
|
|
38
|
+
title: '指标详情',
|
|
39
|
+
});
|
|
40
|
+
}}
|
|
41
|
+
style={{
|
|
42
|
+
...(!!jumpUrl && {
|
|
43
|
+
cursor: 'pointer',
|
|
44
|
+
}),
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
{value}
|
|
48
|
+
</div>
|
|
49
|
+
{!!unit && <UnitWrapper>({unit})</UnitWrapper>}
|
|
50
|
+
</LabelWrapper>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const LabelWrapper = styled.div<{ unit?: string }>`
|
|
56
|
+
line-height: 1;
|
|
57
|
+
margin-bottom: 0.08rem;
|
|
58
|
+
|
|
59
|
+
[data-label] {
|
|
60
|
+
width: 106px;
|
|
61
|
+
font-size: 0.32rem;
|
|
62
|
+
font-weight: 600;
|
|
63
|
+
margin-bottom: 0.08rem;
|
|
64
|
+
display: flex;
|
|
65
|
+
|
|
66
|
+
${(props) =>
|
|
67
|
+
!!props.unit &&
|
|
68
|
+
css`
|
|
69
|
+
&::after {
|
|
70
|
+
content: '(${props.unit})';
|
|
71
|
+
display: inline-block;
|
|
72
|
+
color: #6d7a90;
|
|
73
|
+
}
|
|
74
|
+
`}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[data-value] {
|
|
78
|
+
font-size: 0.56rem;
|
|
79
|
+
font-weight: 700;
|
|
80
|
+
color: #000;
|
|
81
|
+
margin-bottom: 0.08rem;
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IListItem } from '@/types';
|
|
2
|
+
import { CnSelect } from '@cainiaofe/cn-ui-m';
|
|
3
|
+
import { css, styled } from 'styled-components';
|
|
4
|
+
|
|
5
|
+
export const IndicatorSelectDecoration = styled(CnSelect).attrs({
|
|
6
|
+
size: 'small',
|
|
7
|
+
showSearch: true,
|
|
8
|
+
style: {
|
|
9
|
+
width: '2rem',
|
|
10
|
+
},
|
|
11
|
+
})<{ dataSource?: IListItem[]; $right?: boolean }>`
|
|
12
|
+
.cn-ui-m-selectdrawer-content {
|
|
13
|
+
padding-left: 0;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
|
|
16
|
+
div {
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
text-overflow: ellipsis;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
${(props) =>
|
|
24
|
+
props.$right &&
|
|
25
|
+
css`
|
|
26
|
+
transform: translateY(-0.08rem);
|
|
27
|
+
`}
|
|
28
|
+
`;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { IndicatorService } from 'src/services/IndicatorService';
|
|
2
|
+
import { IIndicatorCardConfig } from '@/types';
|
|
3
|
+
import { IndicatorArea } from './components/IndicatorArea';
|
|
4
|
+
import { RequestWrapper } from '../win-wrappers/request-wrapper';
|
|
5
|
+
import {
|
|
6
|
+
CardTitleWrapperMobile,
|
|
7
|
+
CardWrapperMobile,
|
|
8
|
+
} from '../win-wrappers/card-wrapper';
|
|
9
|
+
import { WinCardChartType } from 'src/types/enum';
|
|
10
|
+
import { INDICATOR_CONFIG_BASE_URL } from '../../utils/const';
|
|
11
|
+
import { Indicator } from './components/Indicator';
|
|
12
|
+
import { CnBox } from '@cainiaofe/cn-ui';
|
|
13
|
+
import { IndicatorSelectDecoration } from './components/SelectDecoration';
|
|
14
|
+
import { getListLabel, unitList } from 'src/utils';
|
|
15
|
+
import { useContext, useEffect, useRef, useState } from 'react';
|
|
16
|
+
import { HoverView } from '../hover-view';
|
|
17
|
+
import { useCardOptionList } from 'src/hooks/useCardOptionList';
|
|
18
|
+
import { VisionUserConfigContext } from '../VisionUserConfigContext';
|
|
19
|
+
import { ChartContent } from './components/ChartContent';
|
|
20
|
+
import { WinChartType } from 'src/components/win-chart';
|
|
21
|
+
import { useInViewport } from 'ahooks';
|
|
22
|
+
|
|
23
|
+
interface IProps {
|
|
24
|
+
id: number;
|
|
25
|
+
config?: IIndicatorCardConfig;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const WidCardMobile = ({ id, config }: IProps) => {
|
|
29
|
+
if (config) {
|
|
30
|
+
return <ShowCard configData={config} />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<RequestWrapper
|
|
35
|
+
requestData={{ url: `${INDICATOR_CONFIG_BASE_URL}?id=${id}` }}
|
|
36
|
+
service={IndicatorService.getConfigInfo}
|
|
37
|
+
style={{
|
|
38
|
+
width: '100%',
|
|
39
|
+
height: '100%',
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
{(configData) => {
|
|
43
|
+
return <ShowCard configData={configData} />;
|
|
44
|
+
}}
|
|
45
|
+
</RequestWrapper>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const ShowCard = ({ configData }: { configData: IIndicatorCardConfig }) => {
|
|
50
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
51
|
+
const [inViewport] = useInViewport(ref);
|
|
52
|
+
const [shouldInit, setShouldInit] = useState(false);
|
|
53
|
+
const orgLevelList = useCardOptionList(
|
|
54
|
+
shouldInit && configData.commonConfig.orgLevel ? configData.id : undefined,
|
|
55
|
+
);
|
|
56
|
+
const [curOrgLevelValue, setCurOrgLevelValue] = useState<string>();
|
|
57
|
+
const isSingleIndicator = configData.chartType === WinCardChartType.INDICATOR;
|
|
58
|
+
const hasOrgLevel = !!configData.commonConfig.orgLevel;
|
|
59
|
+
const isCommonTitle = ![WinCardChartType.CUSTOM_CARD].includes(
|
|
60
|
+
configData.chartType,
|
|
61
|
+
);
|
|
62
|
+
const visionUserConfig = useContext(VisionUserConfigContext);
|
|
63
|
+
const hasInitOrgLevelRef = useRef(false);
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (inViewport) {
|
|
67
|
+
setShouldInit(true);
|
|
68
|
+
}
|
|
69
|
+
}, [inViewport]);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (orgLevelList.length !== 0 && visionUserConfig) {
|
|
73
|
+
const configOrgLevelVal =
|
|
74
|
+
visionUserConfig[configData.commonConfig.orgLevel];
|
|
75
|
+
const valueInList = orgLevelList
|
|
76
|
+
.map((item) => item.value)
|
|
77
|
+
.includes(configOrgLevelVal);
|
|
78
|
+
|
|
79
|
+
if (!hasInitOrgLevelRef.current) {
|
|
80
|
+
// 第一次赋值
|
|
81
|
+
setCurOrgLevelValue(
|
|
82
|
+
valueInList ? configOrgLevelVal : orgLevelList[0].value,
|
|
83
|
+
);
|
|
84
|
+
hasInitOrgLevelRef.current = true;
|
|
85
|
+
} else {
|
|
86
|
+
// 用户配置切换赋值
|
|
87
|
+
if (valueInList) {
|
|
88
|
+
setCurOrgLevelValue(configOrgLevelVal);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, [configData.commonConfig.orgLevel, orgLevelList, visionUserConfig]);
|
|
93
|
+
|
|
94
|
+
// 单位
|
|
95
|
+
const unit = getListLabel(unitList, configData.indicatorConfig[0]?.unit);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<CardWrapperMobile ref={ref}>
|
|
99
|
+
<CnBox direction="row" justify="space-between">
|
|
100
|
+
{isCommonTitle ? (
|
|
101
|
+
<CardTitleWrapperMobile
|
|
102
|
+
data-card-id={configData.id}
|
|
103
|
+
style={{
|
|
104
|
+
maxWidth: isSingleIndicator || !hasOrgLevel ? '80%' : '45%',
|
|
105
|
+
position: 'relative',
|
|
106
|
+
...([
|
|
107
|
+
WinCardChartType.INDICATOR,
|
|
108
|
+
WinCardChartType.INDICATOR_AREA,
|
|
109
|
+
].includes(configData.chartType) && {
|
|
110
|
+
fontSize: '0.24rem',
|
|
111
|
+
fontWeight: 500,
|
|
112
|
+
}),
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
<HoverView content={configData.name} />
|
|
116
|
+
</CardTitleWrapperMobile>
|
|
117
|
+
) : (
|
|
118
|
+
<div />
|
|
119
|
+
)}
|
|
120
|
+
<CnBox spacing={16} direction="row" align="center">
|
|
121
|
+
{hasOrgLevel && !isSingleIndicator && (
|
|
122
|
+
<IndicatorSelectDecoration
|
|
123
|
+
$right
|
|
124
|
+
value={curOrgLevelValue}
|
|
125
|
+
dataSource={orgLevelList}
|
|
126
|
+
onChange={setCurOrgLevelValue}
|
|
127
|
+
/>
|
|
128
|
+
)}
|
|
129
|
+
</CnBox>
|
|
130
|
+
</CnBox>
|
|
131
|
+
{getShowContent({
|
|
132
|
+
configData,
|
|
133
|
+
hasOrgLevel,
|
|
134
|
+
orgLevelVal: curOrgLevelValue,
|
|
135
|
+
unit,
|
|
136
|
+
})}
|
|
137
|
+
{isSingleIndicator && (
|
|
138
|
+
<div style={{ height: 32 }}>
|
|
139
|
+
{hasOrgLevel && (
|
|
140
|
+
<IndicatorSelectDecoration
|
|
141
|
+
value={curOrgLevelValue}
|
|
142
|
+
dataSource={orgLevelList}
|
|
143
|
+
onChange={setCurOrgLevelValue}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
</CardWrapperMobile>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const getShowContent = ({
|
|
153
|
+
configData,
|
|
154
|
+
hasOrgLevel,
|
|
155
|
+
orgLevelVal,
|
|
156
|
+
unit,
|
|
157
|
+
}: {
|
|
158
|
+
configData: IIndicatorCardConfig;
|
|
159
|
+
orgLevelVal?: string;
|
|
160
|
+
unit?: string;
|
|
161
|
+
hasOrgLevel: boolean;
|
|
162
|
+
}) => {
|
|
163
|
+
const data = {
|
|
164
|
+
configData,
|
|
165
|
+
orgLevelVal,
|
|
166
|
+
unit,
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
if (hasOrgLevel && !orgLevelVal) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
switch (configData.chartType) {
|
|
174
|
+
case WinCardChartType.INDICATOR:
|
|
175
|
+
return <Indicator {...data} />;
|
|
176
|
+
|
|
177
|
+
case WinCardChartType.INDICATOR_AREA:
|
|
178
|
+
return <IndicatorArea {...data} />;
|
|
179
|
+
|
|
180
|
+
case WinCardChartType.DUAL_LINE_BAR_CHART:
|
|
181
|
+
return (
|
|
182
|
+
<ChartContent winChartType={WinChartType.DUAL_LINE_BAR} {...data} />
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
case WinCardChartType.AREA_CHART:
|
|
186
|
+
return <ChartContent winChartType={WinChartType.AREA} {...data} />;
|
|
187
|
+
|
|
188
|
+
case WinCardChartType.LINE_CHART:
|
|
189
|
+
return <ChartContent winChartType={WinChartType.LINE} {...data} />;
|
|
190
|
+
|
|
191
|
+
case WinCardChartType.COLUMN_CHART:
|
|
192
|
+
return <ChartContent winChartType={WinChartType.COLUMN} {...data} />;
|
|
193
|
+
|
|
194
|
+
case WinCardChartType.STACK_COLUMN_CHART:
|
|
195
|
+
return (
|
|
196
|
+
<ChartContent winChartType={WinChartType.STACK_COLUMN} {...data} />
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
case WinCardChartType.FUNNEL_CHART:
|
|
200
|
+
return <ChartContent winChartType={WinChartType.FUNNEL} {...data} />;
|
|
201
|
+
|
|
202
|
+
case WinCardChartType.BAR_CHART:
|
|
203
|
+
return <ChartContent winChartType={WinChartType.BAR} {...data} />;
|
|
204
|
+
|
|
205
|
+
case WinCardChartType.PIE_CHART:
|
|
206
|
+
return <ChartContent winChartType={WinChartType.PIE} {...data} />;
|
|
207
|
+
|
|
208
|
+
case WinCardChartType.PIE_CHART_RESERVE:
|
|
209
|
+
return (
|
|
210
|
+
<ChartContent
|
|
211
|
+
reserveValueWithLabelType
|
|
212
|
+
winChartType={WinChartType.PIE}
|
|
213
|
+
{...data}
|
|
214
|
+
/>
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
case WinCardChartType.RADAR_CHART:
|
|
218
|
+
return <ChartContent winChartType={WinChartType.RADAR} {...data} />;
|
|
219
|
+
|
|
220
|
+
case WinCardChartType.RADAR_CHART_RESERVE:
|
|
221
|
+
return (
|
|
222
|
+
<ChartContent
|
|
223
|
+
reserveValueWithLabelType
|
|
224
|
+
winChartType={WinChartType.RADAR}
|
|
225
|
+
{...data}
|
|
226
|
+
/>
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
case WinCardChartType.CYCLE_CHART:
|
|
230
|
+
return <ChartContent winChartType={WinChartType.CYCLE} {...data} />;
|
|
231
|
+
|
|
232
|
+
default:
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IIndicatorCardConfig } from '@/types';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface IContentProps {
|
|
5
|
+
configData: IIndicatorCardConfig;
|
|
6
|
+
theme?: string;
|
|
7
|
+
orgLevelVal?: string;
|
|
8
|
+
unit?: string;
|
|
9
|
+
extraCondition?: {
|
|
10
|
+
[p: string]: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ChartWrapper } from './components/chart-wrapper';
|
|
2
|
+
import { IWinChartProps } from './utils/type';
|
|
3
|
+
import { useRef, useEffect, useState } from 'react';
|
|
4
|
+
import { getEChartOptions } from './utils/getChartOptions';
|
|
5
|
+
import * as echarts from 'echarts';
|
|
6
|
+
import { commonOpt } from './utils/const';
|
|
7
|
+
import { debounce } from './utils/tool';
|
|
8
|
+
import light from './theme/win-light.json';
|
|
9
|
+
import dark from './theme/win-dark.json';
|
|
10
|
+
import deepMerge from 'deepmerge';
|
|
11
|
+
|
|
12
|
+
export * from './utils/const';
|
|
13
|
+
export * from './utils/type';
|
|
14
|
+
|
|
15
|
+
echarts.registerTheme('light', deepMerge(light, commonOpt));
|
|
16
|
+
echarts.registerTheme('dark', deepMerge(dark, commonOpt));
|
|
17
|
+
|
|
18
|
+
export const WinChart = ({
|
|
19
|
+
className,
|
|
20
|
+
style,
|
|
21
|
+
extraOption,
|
|
22
|
+
theme = 'light',
|
|
23
|
+
...args
|
|
24
|
+
}: IWinChartProps) => {
|
|
25
|
+
const boxRef = useRef<HTMLDivElement>(null);
|
|
26
|
+
const [eChart, setEChart] = useState<echarts.ECharts>();
|
|
27
|
+
const argsStr = JSON.stringify(args);
|
|
28
|
+
const extraOptionStr = JSON.stringify(extraOption ?? {});
|
|
29
|
+
|
|
30
|
+
// 生成实例
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const eChart = echarts.init(boxRef.current, theme);
|
|
33
|
+
setEChart(eChart);
|
|
34
|
+
|
|
35
|
+
// 监听窗口变化
|
|
36
|
+
const resize = debounce(eChart.resize, 500);
|
|
37
|
+
globalThis.addEventListener('resize', () => {
|
|
38
|
+
resize();
|
|
39
|
+
});
|
|
40
|
+
}, [theme]);
|
|
41
|
+
|
|
42
|
+
// 设置配置
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (eChart) {
|
|
45
|
+
eChart.setOption(
|
|
46
|
+
deepMerge(
|
|
47
|
+
getEChartOptions(JSON.parse(argsStr)),
|
|
48
|
+
JSON.parse(extraOptionStr),
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
eChart.resize();
|
|
54
|
+
}, 500);
|
|
55
|
+
}
|
|
56
|
+
}, [argsStr, eChart, extraOptionStr]);
|
|
57
|
+
|
|
58
|
+
return <ChartWrapper ref={boxRef} className={className} style={style} />;
|
|
59
|
+
};
|