@cloudbase/weda-ui 2.0.10 → 2.0.26
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/README.md +1 -0
- package/package.json +47 -36
- package/src/configs/components/button.json +60 -13
- package/src/configs/components/calendar.json +3 -3
- package/src/configs/components/carousel.json +57 -47
- package/src/configs/components/chart/bar.json +4 -13
- package/src/configs/components/chart/line.json +4 -13
- package/src/configs/components/chart/pie.json +3 -10
- package/src/configs/components/chart/statisticsCard.json +1 -4
- package/src/configs/components/container.json +1 -3
- package/src/configs/components/dataView.json +7 -15
- package/src/configs/components/drawer.json +24 -6
- package/src/configs/components/form/form.json +19 -0
- package/src/configs/components/form/input.json +20 -5
- package/src/configs/components/form/location.json +51 -48
- package/src/configs/components/form/radio.json +1 -3
- package/src/configs/components/form/richText.json +14 -14
- package/src/configs/components/form/select.json +62 -82
- package/src/configs/components/form/textarea.json +14 -1
- package/src/configs/components/form/uploader.json +64 -64
- package/src/configs/components/form/uploaderFile.json +1 -2
- package/src/configs/components/graphicCard.json +44 -45
- package/src/configs/components/image.json +44 -40
- package/src/configs/components/link.json +5 -10
- package/src/configs/components/listView.json +2 -8
- package/src/configs/components/lottery.json +7 -3
- package/src/configs/components/modal.json +26 -21
- package/src/configs/components/navLayout.json +68 -68
- package/src/configs/components/navigationBar.json +4 -1
- package/src/configs/components/richtextview.json +1 -1
- package/src/configs/components/scrollVeiw.json +14 -42
- package/src/configs/components/swiper.json +9 -9
- package/src/configs/components/wedaVideo.json +89 -0
- package/src/configs/components/wxOpenApi/phone.json +7 -21
- package/src/configs/components/wxOpenApi/phoneCode.json +7 -19
- package/src/configs/components/wxOpenApi/share.json +14 -24
- package/src/configs/components/wxOpenApi/userInfo.json +9 -27
- package/src/configs/index.js +2 -0
- package/src/mp/components/button/index.js +1 -1
- package/src/mp/components/button/index.wxml +19 -19
- package/src/mp/components/calendar/index.js +68 -38
- package/src/mp/components/calendar/index.json +3 -2
- package/src/mp/components/calendar/index.wxml +5 -7
- package/src/mp/components/calendar/index.wxss +17 -16
- package/src/mp/components/carousel/index.json +1 -1
- package/src/mp/components/carousel/index.wxml +2 -2
- package/src/mp/components/chart/bar/index.js +1 -2
- package/src/mp/components/chart/bar/index.wxml +1 -1
- package/src/mp/components/chart/common/config/bar.js +1 -1
- package/src/mp/components/chart/common/core/eChartBar.js +29 -34
- package/src/mp/components/chart/common/core/eChartBase.js +46 -32
- package/src/mp/components/chart/common/core/eChartLine.js +34 -40
- package/src/mp/components/chart/common/core/eChartPie.js +12 -9
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +1 -1
- package/src/mp/components/chart/ec-canvas/wx-canvas.js +24 -22
- package/src/mp/components/chart/line/index.js +2 -2
- package/src/mp/components/chart/line/index.wxml +1 -1
- package/src/mp/components/chart/pie/index.js +1 -1
- package/src/mp/components/chart/pie/index.wxml +1 -2
- package/src/mp/components/chart/statisticsCard/index.wxss +7 -10
- package/src/mp/components/dataView/index.wxml +2 -14
- package/src/mp/components/form/checkbox/index.js +15 -7
- package/src/mp/components/form/checkbox/index.wxml +13 -25
- package/src/mp/components/form/form/index.wxml +3 -3
- package/src/mp/components/form/formcell/index.wxml +9 -9
- package/src/mp/components/form/formcell/index.wxss +6 -1
- package/src/mp/components/form/input/index.js +4 -4
- package/src/mp/components/form/input/index.wxml +24 -31
- package/src/mp/components/form/input/index.wxss +9 -3
- package/src/mp/components/form/location/components/mapChoose/index.json +1 -1
- package/src/mp/components/form/location/components/mapChoose/index.wxml +6 -6
- package/src/mp/components/form/location/index.js +7 -1
- package/src/mp/components/form/location/index.json +1 -1
- package/src/mp/components/form/location/index.wxml +6 -10
- package/src/mp/components/form/radio/index.js +14 -6
- package/src/mp/components/form/radio/index.wxml +12 -24
- package/src/mp/components/form/select/index.js +157 -98
- package/src/mp/components/form/select/index.wxml +11 -39
- package/src/mp/components/form/select/index.wxss +10 -1
- package/src/mp/components/form/select/region/index.js +18 -12
- package/src/mp/components/form/switch/index.wxml +11 -18
- package/src/mp/components/form/textarea/index.js +6 -0
- package/src/mp/components/form/textarea/index.wxml +2 -17
- package/src/mp/components/form/textarea/index.wxss +5 -0
- package/src/mp/components/form/tips/index.wxml +1 -3
- package/src/mp/components/form/uploader/index.js +1 -1
- package/src/mp/components/form/uploader/index.wxml +3 -20
- package/src/mp/components/form/uploader/weui-uploader.js +210 -200
- package/src/mp/components/form/uploader/weui-uploader.json +6 -6
- package/src/mp/components/form/uploader/weui-uploader.wxml +38 -38
- package/src/mp/components/form/uploaderFile/index.js +5 -4
- package/src/mp/components/form/uploaderFile/index.wxml +40 -41
- package/src/mp/components/graphicCard/index.js +35 -35
- package/src/mp/components/graphicCard/index.wxml +2 -6
- package/src/mp/components/graphicCard/index.wxss +6 -6
- package/src/mp/components/image/index.wxml +9 -20
- package/src/mp/components/image/index.wxss +3 -1
- package/src/mp/components/listView/index.wxml +5 -7
- package/src/mp/components/listView/index.wxss +2 -2
- package/src/mp/components/lottery/index.wxml +1 -3
- package/src/mp/components/lottery/index.wxss +31 -25
- package/src/mp/components/navLayout/index.js +9 -12
- package/src/mp/components/navLayout/index.wxml +2 -4
- package/src/mp/components/navLayout/index.wxss +10 -10
- package/src/mp/components/navigationBar/index.json +1 -2
- package/src/mp/components/navigationBar/index.wxml +43 -51
- package/src/mp/components/navigationBar/index.wxss +10 -10
- package/src/mp/components/richText/index.wxml +1 -1
- package/src/mp/components/richText/index.wxss +7 -5
- package/src/mp/components/swiper/index.wxml +1 -9
- package/src/mp/components/tabs/index.js +14 -10
- package/src/mp/components/tabs/index.json +1 -1
- package/src/mp/components/tabs/index.wxml +3 -21
- package/src/mp/components/tabs/index.wxss +1 -2
- package/src/mp/components/text/index.wxml +1 -6
- package/src/mp/components/text/index.wxss +1 -1
- package/src/mp/components/wedaVideo/index.js +86 -0
- package/src/mp/components/wedaVideo/index.json +4 -0
- package/src/mp/components/wedaVideo/index.wxml +4 -0
- package/src/mp/components/wedaVideo/index.wxss +20 -0
- package/src/mp/components/wxOpenApi/phone/index.js +1 -9
- package/src/mp/components/wxOpenApi/phone/index.wxml +3 -14
- package/src/mp/components/wxOpenApi/phoneCode/index.json +1 -1
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +3 -14
- package/src/mp/components/wxOpenApi/share/index.wxml +3 -14
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +3 -13
- package/src/mp/index.json +1 -0
- package/src/mp/style/weda-ui.wxss +24 -9
- package/src/mp/utils/deepEqual.js +37 -37
- package/src/mp/utils/destr.js +41 -40
- package/src/mp/utils/dr_square_point.js +10 -6
- package/src/setupTests.js +13 -13
- package/src/web/actions/showModal/index.tsx +5 -4
- package/src/web/components/button/index.tsx +44 -40
- package/src/web/components/calendar/index.css +99 -65
- package/src/web/components/carousel/index.tsx +1 -1
- package/src/web/components/chart/common/config/bar.js +1 -1
- package/src/web/components/chart/common/core/eChartBar.js +28 -34
- package/src/web/components/chart/common/core/eChartBase.ts +55 -42
- package/src/web/components/chart/common/core/eChartLine.js +34 -40
- package/src/web/components/chart/common/core/eChartPie.js +12 -9
- package/src/web/components/chart/common/core/type.ts +23 -23
- package/src/web/components/chart/common/echart.css +12 -12
- package/src/web/components/chart/common/echarts.ts +3 -5
- package/src/web/components/chart/common/useChart.tsx +34 -16
- package/src/web/components/chart/statisticsCard/index.css +9 -8
- package/src/web/components/container/index.tsx +3 -4
- package/src/web/components/drawer/index.tsx +15 -4
- package/src/web/components/form/checkbox/index.tsx +32 -31
- package/src/web/components/form/enumSelect/NormalSelect.tsx +0 -2
- package/src/web/components/form/form/index.css +3 -6
- package/src/web/components/form/form/index.tsx +7 -6
- package/src/web/components/form/formcell/index.css +11 -18
- package/src/web/components/form/formcell/index.tsx +3 -7
- package/src/web/components/form/input/index.css +8 -4
- package/src/web/components/form/input/index.tsx +61 -53
- package/src/web/components/form/location/common/mapChoose.css +13 -11
- package/src/web/components/form/location/common/selectModal.jsx +2 -11
- package/src/web/components/form/location/common/useLocationInfo.js +4 -0
- package/src/web/components/form/location/components/LocationH5/index.css +19 -20
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +11 -1
- package/src/web/components/form/location/components/LocationPC/Header.jsx +0 -13
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +14 -5
- package/src/web/components/form/radio/index.tsx +32 -26
- package/src/web/components/form/renderDecorator.tsx +23 -26
- package/src/web/components/form/select/h5.tsx +155 -104
- package/src/web/components/form/select/index.css +9 -3
- package/src/web/components/form/select/index.tsx +76 -49
- package/src/web/components/form/select/region/index.ts +101 -80
- package/src/web/components/form/select/year.tsx +2 -0
- package/src/web/components/form/switch/index.tsx +40 -40
- package/src/web/components/form/textarea/index.css +4 -0
- package/src/web/components/form/textarea/index.tsx +39 -26
- package/src/web/components/form/types.d.ts +10 -10
- package/src/web/components/form/uploader/index.css +10 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +29 -26
- package/src/web/components/form/uploader/uploader.pc.tsx +3 -6
- package/src/web/components/form/uploaderFile/index.css +24 -23
- package/src/web/components/form/uploaderFile/index.jsx +0 -5
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +24 -15
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +21 -13
- package/src/web/components/graphicCard/index.css +6 -6
- package/src/web/components/image/image.tsx +2 -2
- package/src/web/components/image/index.css +9 -7
- package/src/web/components/image/index.tsx +29 -12
- package/src/web/components/index.js +1 -0
- package/src/web/components/link/index.tsx +13 -13
- package/src/web/components/listView/index.css +8 -8
- package/src/web/components/lottery/index.css +43 -37
- package/src/web/components/lottery/index.tsx +3 -3
- package/src/web/components/modal/index.tsx +34 -34
- package/src/web/components/navLayout/index.css +25 -25
- package/src/web/components/navLayout/index.tsx +1 -1
- package/src/web/components/navigationBar/index.css +26 -26
- package/src/web/components/navigationBar/index.tsx +2 -2
- package/src/web/components/picker/datePicker.tsx +3 -3
- package/src/web/components/picker/picker.tsx +3 -3
- package/src/web/components/picker/timePicker.tsx +1 -1
- package/src/web/components/richText/index.jsx +41 -46
- package/src/web/components/richTextView/index.css +7 -3
- package/src/web/components/richTextView/index.tsx +4 -6
- package/src/web/components/scrollView/index.tsx +2 -2
- package/src/web/components/slot/index.tsx +3 -4
- package/src/web/components/swiper/index.css +1 -1
- package/src/web/components/swiper/index.tsx +33 -15
- package/src/web/components/tabs/index.css +2 -3
- package/src/web/components/tabs/index.tsx +6 -6
- package/src/web/components/tabs/tabs.h5.tsx +17 -12
- package/src/web/components/tabs/tabs.pc.tsx +45 -34
- package/src/web/components/text/index.css +1 -1
- package/src/web/components/text/index.tsx +13 -14
- package/src/web/components/wedaVideo/index.css +42 -0
- package/src/web/components/wedaVideo/index.tsx +208 -0
- package/src/web/utils/constant.ts +2 -1
- package/src/web/utils/isObjectEqual.js +2 -1
- package/src/web/utils/loading-fallback.tsx +2 -2
- package/src/web/utils/lodash.ts +1 -1
- package/src/web/utils/platform.js +13 -0
- package/src/web/utils/useSetState.ts +6 -2
- package/src/web/weda-ui.css +23 -8
- package/src/docs/common/format.tsx +0 -112
- package/src/docs/common/tableView.css +0 -164
- package/src/docs/common/tableView.tsx +0 -273
- package/src/docs/compsdocs/chart/Bar.mdx +0 -159
- package/src/docs/compsdocs/chart/Line.mdx +0 -100
- package/src/docs/compsdocs/chart/Pie.mdx +0 -83
- package/src/docs/compsdocs/chart/_category_.json +0 -1
- package/src/docs/compsdocs/chart/statisticsCard.mdx +0 -51
- package/src/docs/compsdocs/database/DataView.mdx +0 -33
- package/src/docs/compsdocs/database/ListView.mdx +0 -33
- package/src/docs/compsdocs/database/_category_.json +0 -1
- package/src/docs/compsdocs/form/Form.mdx +0 -35
- package/src/docs/compsdocs/form/FormCheckbox.mdx +0 -35
- package/src/docs/compsdocs/form/FormDate.mdx +0 -30
- package/src/docs/compsdocs/form/FormEmail.mdx +0 -30
- package/src/docs/compsdocs/form/FormImageUploader.mdx +0 -31
- package/src/docs/compsdocs/form/FormInput.mdx +0 -30
- package/src/docs/compsdocs/form/FormLocation.mdx +0 -64
- package/src/docs/compsdocs/form/FormPhone.mdx +0 -30
- package/src/docs/compsdocs/form/FormRadio.mdx +0 -35
- package/src/docs/compsdocs/form/FormRegion.mdx +0 -30
- package/src/docs/compsdocs/form/FormSelect.mdx +0 -36
- package/src/docs/compsdocs/form/FormSwitch.mdx +0 -30
- package/src/docs/compsdocs/form/FormTextarea.mdx +0 -30
- package/src/docs/compsdocs/form/FormTime.mdx +0 -30
- package/src/docs/compsdocs/form/FormUploadFile.mdx +0 -30
- package/src/docs/compsdocs/form/FormUrl.mdx +0 -30
- package/src/docs/compsdocs/form/_category_.json +0 -1
- package/src/docs/compsdocs/grid/Card.mdx +0 -32
- package/src/docs/compsdocs/grid/Container.mdx +0 -42
- package/src/docs/compsdocs/grid/Footer.mdx +0 -31
- package/src/docs/compsdocs/grid/GridLayout.mdx +0 -32
- package/src/docs/compsdocs/grid/Header.mdx +0 -31
- package/src/docs/compsdocs/grid/Layout.mdx +0 -25
- package/src/docs/compsdocs/grid/List.mdx +0 -31
- package/src/docs/compsdocs/grid/ScrollView.mdx +0 -37
- package/src/docs/compsdocs/grid/Swiper.mdx +0 -58
- package/src/docs/compsdocs/grid/_category_.json +0 -1
- package/src/docs/compsdocs/media/Icon.mdx +0 -31
- package/src/docs/compsdocs/media/Image.mdx +0 -55
- package/src/docs/compsdocs/media/_category_.json +0 -1
- package/src/docs/compsdocs/model/ModelCreate.mdx +0 -20
- package/src/docs/compsdocs/model/ModelDetail.mdx +0 -20
- package/src/docs/compsdocs/model/ModelTable.mdx +0 -24
- package/src/docs/compsdocs/model/ModelUpdate.mdx +0 -21
- package/src/docs/compsdocs/model/PageLayout.mdx +0 -21
- package/src/docs/compsdocs/model/_category_.json +0 -1
- package/src/docs/compsdocs/navmenu/Classification.mdx +0 -38
- package/src/docs/compsdocs/navmenu/NavBar.mdx +0 -43
- package/src/docs/compsdocs/navmenu/NavLayout.mdx +0 -30
- package/src/docs/compsdocs/navmenu/TabBar.mdx +0 -43
- package/src/docs/compsdocs/navmenu/TabBarItem.mdx +0 -29
- package/src/docs/compsdocs/navmenu/_category_.json +0 -1
- package/src/docs/compsdocs/senior/Lottery.mdx +0 -48
- package/src/docs/compsdocs/senior/Modal.mdx +0 -58
- package/src/docs/compsdocs/senior/SlotMachine.mdx +0 -52
- package/src/docs/compsdocs/senior/_category_.json +0 -1
- package/src/docs/compsdocs/show/Calendar.mdx +0 -29
- package/src/docs/compsdocs/show/Divider.mdx +0 -31
- package/src/docs/compsdocs/show/GraphicCard.mdx +0 -30
- package/src/docs/compsdocs/show/Item.mdx +0 -32
- package/src/docs/compsdocs/show/ItemList.mdx +0 -47
- package/src/docs/compsdocs/show/Media.mdx +0 -25
- package/src/docs/compsdocs/show/StatusTip.mdx +0 -25
- package/src/docs/compsdocs/show/Swiper.mdx +0 -33
- package/src/docs/compsdocs/show/Tabs.mdx +0 -38
- package/src/docs/compsdocs/show/_category_.json +0 -1
- package/src/docs/compsdocs/show/button.mdx +0 -25
- package/src/docs/compsdocs/text/Link.mdx +0 -43
- package/src/docs/compsdocs/text/RichTextView.mdx +0 -36
- package/src/docs/compsdocs/text/Text.mdx +0 -31
- package/src/docs/compsdocs/text/Title.mdx +0 -32
- package/src/docs/compsdocs/text/_category_.json +0 -1
- package/src/docs/compsdocs/wxOpen/Phone.mdx +0 -60
- package/src/docs/compsdocs/wxOpen/Share.mdx +0 -46
- package/src/docs/compsdocs/wxOpen/UserInfo.mdx +0 -60
- package/src/docs/compsdocs/wxOpen/_category_.json +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { callDataSource, callWedaApi } from '../../../../utils/tcb';
|
|
2
2
|
import getConfig from '../config/global';
|
|
3
3
|
|
|
4
|
-
export type IEchartModalBase = typeof EchartBase
|
|
4
|
+
export type IEchartModalBase = typeof EchartBase;
|
|
5
5
|
export abstract class AbstractEchartBaseModal {
|
|
6
6
|
abstract setOptions(options: any): Promise<void>;
|
|
7
7
|
abstract getOptions(option: any): Promise<void>;
|
|
@@ -11,18 +11,18 @@ type IReturnData = {
|
|
|
11
11
|
value: {
|
|
12
12
|
Key: string;
|
|
13
13
|
OperationType: 'count' | 'sum' | 'avg' | 'max' | 'min';
|
|
14
|
-
}[]
|
|
15
|
-
where: []
|
|
14
|
+
}[];
|
|
15
|
+
where: [];
|
|
16
16
|
dimension: {
|
|
17
17
|
TimeSpan?: string;
|
|
18
18
|
Key?: string;
|
|
19
19
|
IsCountEmpty?: boolean;
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
21
|
group: {
|
|
22
22
|
TimeSpan?: string;
|
|
23
23
|
Key?: string;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* 图表处理基类
|
|
@@ -39,7 +39,6 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
39
39
|
|
|
40
40
|
public async setOptions(options: any): Promise<void> {}
|
|
41
41
|
|
|
42
|
-
|
|
43
42
|
/** 获取所有配置好的图表数据 */
|
|
44
43
|
public getOptions() {
|
|
45
44
|
return this.config;
|
|
@@ -52,8 +51,8 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
52
51
|
xStatistics,
|
|
53
52
|
xIsCountEmpty,
|
|
54
53
|
yField,
|
|
55
|
-
groupKey=
|
|
56
|
-
groupKeyTimeSpan='',
|
|
54
|
+
groupKey = {} as Record<string, any>,
|
|
55
|
+
groupKeyTimeSpan = '',
|
|
57
56
|
}) {
|
|
58
57
|
const objReturnData: IReturnData = {
|
|
59
58
|
value: [],
|
|
@@ -61,28 +60,29 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
61
60
|
dimension: {},
|
|
62
61
|
group: {},
|
|
63
62
|
};
|
|
64
|
-
if (filterData && filterData.length > 0) {
|
|
63
|
+
if (filterData && filterData.length > 0) {
|
|
64
|
+
// 协议转化,把首字母改成大写
|
|
65
65
|
objReturnData.where = filterData.map((val) => {
|
|
66
66
|
let arrLogicData = val.logicData;
|
|
67
67
|
if (val.logicData && val.logicData.length > 0) {
|
|
68
|
-
arrLogicData = val.logicData.map((mval)=>{
|
|
68
|
+
arrLogicData = val.logicData.map((mval) => {
|
|
69
69
|
return {
|
|
70
70
|
Key: mval.key,
|
|
71
71
|
Rel: mval.rel,
|
|
72
72
|
Value: mval.value,
|
|
73
73
|
Logic: mval.logic,
|
|
74
74
|
Extra: {
|
|
75
|
-
Type:mval?.extra?.type,
|
|
76
|
-
Format:mval?.extra?.format,
|
|
77
|
-
IsExpression:mval?.extra?.isExpression,
|
|
75
|
+
Type: mval?.extra?.type,
|
|
76
|
+
Format: mval?.extra?.format,
|
|
77
|
+
IsExpression: mval?.extra?.isExpression,
|
|
78
78
|
},
|
|
79
|
-
ValueType:mval.valueType,
|
|
80
|
-
Expression:mval.expression
|
|
79
|
+
ValueType: mval.valueType,
|
|
80
|
+
Expression: mval.expression,
|
|
81
81
|
};
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
return {
|
|
85
|
-
GroupLogic:val.groupLogic,
|
|
85
|
+
GroupLogic: val.groupLogic,
|
|
86
86
|
LogicData: arrLogicData,
|
|
87
87
|
};
|
|
88
88
|
});
|
|
@@ -121,7 +121,7 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
121
121
|
sourceName = '',
|
|
122
122
|
methods = '',
|
|
123
123
|
dataSourceType = '',
|
|
124
|
-
params
|
|
124
|
+
params
|
|
125
125
|
) {
|
|
126
126
|
try {
|
|
127
127
|
if (dataSourceType === 'database') {
|
|
@@ -157,20 +157,20 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
157
157
|
this.config.title.right = null;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
protected setLegend({ isLegend, legend= 'top'}) {
|
|
160
|
+
protected setLegend({ isLegend, legend = 'top' }) {
|
|
161
161
|
this.config.legend.show = isLegend;
|
|
162
162
|
switch (legend) {
|
|
163
|
-
case 'top'
|
|
163
|
+
case 'top':
|
|
164
164
|
this.config.legend.orient = 'horizontal';
|
|
165
165
|
this.config.legend.x = 'center';
|
|
166
166
|
this.config.legend.top = '6%';
|
|
167
167
|
break;
|
|
168
|
-
case 'left'
|
|
168
|
+
case 'left':
|
|
169
169
|
this.config.legend.orient = 'vertical';
|
|
170
170
|
this.config.legend.top = '30%';
|
|
171
171
|
this.config.legend.left = '1%';
|
|
172
172
|
break;
|
|
173
|
-
case 'right'
|
|
173
|
+
case 'right':
|
|
174
174
|
this.config.legend.orient = 'vertical';
|
|
175
175
|
this.config.legend.top = '30%';
|
|
176
176
|
this.config.legend.right = '6%';
|
|
@@ -194,11 +194,11 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
194
194
|
sortedXAxisData.forEach((itemSource) => {
|
|
195
195
|
let value = itemSource.XLabel.Value;
|
|
196
196
|
if (formatType === 'datetime') {
|
|
197
|
-
value =
|
|
197
|
+
value = this.formatTime(itemSource.XLabel.Value, 'dt');
|
|
198
198
|
} else if (formatType === 'date') {
|
|
199
|
-
value =
|
|
199
|
+
value = this.formatTime(itemSource.XLabel.Value, 'd');
|
|
200
200
|
} else if (formatType === 'time') {
|
|
201
|
-
value =
|
|
201
|
+
value = this.formatTime(itemSource.XLabel.Value, 't');
|
|
202
202
|
}
|
|
203
203
|
xAxisData.push(value);
|
|
204
204
|
});
|
|
@@ -208,16 +208,19 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
208
208
|
}
|
|
209
209
|
protected sortXAxisData(arrData, formatType = ''): Array<any> {
|
|
210
210
|
let xFields = [...arrData];
|
|
211
|
-
if(['datetime', 'date', 'time'].includes(formatType)) {
|
|
211
|
+
if (['datetime', 'date', 'time'].includes(formatType)) {
|
|
212
212
|
xFields.sort((a, b) => {
|
|
213
|
-
if(a.XLabel.Value && b.XLabel.Value
|
|
214
|
-
return
|
|
213
|
+
if (a.XLabel.Value && b.XLabel.Value) {
|
|
214
|
+
return (
|
|
215
|
+
new Date(a.XLabel.Value).getTime() -
|
|
216
|
+
new Date(b.XLabel.Value).getTime()
|
|
217
|
+
);
|
|
215
218
|
}
|
|
216
219
|
// 产品需求空值放最后
|
|
217
|
-
if(!a.XLabel.Value) {
|
|
220
|
+
if (!a.XLabel.Value) {
|
|
218
221
|
return 1;
|
|
219
222
|
}
|
|
220
|
-
if(!b.XLabel.Value) {
|
|
223
|
+
if (!b.XLabel.Value) {
|
|
221
224
|
return -1;
|
|
222
225
|
}
|
|
223
226
|
});
|
|
@@ -232,16 +235,17 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
232
235
|
* @param { string } timeType 需要格式化的类型 dt:日期时间,d:日期,t:时间
|
|
233
236
|
* @returns { string } 格式化结果
|
|
234
237
|
*/
|
|
235
|
-
private formatTime(time, timeType='dt') {
|
|
236
|
-
if(typeof time === 'undefined' || time === null) {
|
|
238
|
+
private formatTime(time, timeType = 'dt') {
|
|
239
|
+
if (typeof time === 'undefined' || time === null) {
|
|
237
240
|
return '空';
|
|
238
241
|
}
|
|
239
|
-
if (typeof
|
|
242
|
+
if (typeof time === 'string') {
|
|
243
|
+
// 如果是字符串,代表后台返回的就是格式化的时间格式,则这里不再做格式化处理
|
|
240
244
|
return time;
|
|
241
245
|
}
|
|
242
246
|
const date = new Date(time + 8 * 3600 * 1000);
|
|
243
247
|
let startNum = 0;
|
|
244
|
-
let endNum =
|
|
248
|
+
let endNum = 19;
|
|
245
249
|
if (timeType === 'd') {
|
|
246
250
|
startNum = 0;
|
|
247
251
|
endNum = 10;
|
|
@@ -301,13 +305,18 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
301
305
|
this.config.xAxis.name = isXaxisName ? xAxisName : '';
|
|
302
306
|
}
|
|
303
307
|
// 显示X轴刻度线
|
|
304
|
-
|
|
305
|
-
this.config.xAxis.axisTick = {show:isXaxisAxisTickShow};
|
|
308
|
+
protected setIsXaxisAxisTickShow({ isXaxisAxisTickShow }) {
|
|
309
|
+
this.config.xAxis.axisTick = { show: isXaxisAxisTickShow };
|
|
306
310
|
}
|
|
307
311
|
// X 轴文字倾斜
|
|
308
|
-
protected setIsXaxisAxisLabelRotate({
|
|
312
|
+
protected setIsXaxisAxisLabelRotate({
|
|
313
|
+
isXaxisAxisLabelRotate,
|
|
314
|
+
xStatistics,
|
|
315
|
+
angle = 30,
|
|
316
|
+
}) {
|
|
309
317
|
this.config.xAxis.axisLabel.rotate = isXaxisAxisLabelRotate ? angle : 0;
|
|
310
|
-
if (isXaxisAxisLabelRotate || xStatistics) {
|
|
318
|
+
if (isXaxisAxisLabelRotate || xStatistics) {
|
|
319
|
+
// 如果X轴是时间类型,自动斜30度展示
|
|
311
320
|
this.config.xAxis.axisLabel.rotate = angle;
|
|
312
321
|
} else {
|
|
313
322
|
this.config.xAxis.axisLabel.rotate = 0;
|
|
@@ -319,8 +328,10 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
319
328
|
isYAxisSplitlineLinestyleWidth,
|
|
320
329
|
yAxisSplitlineLinestyleType,
|
|
321
330
|
}) {
|
|
322
|
-
this.config.yAxis.splitLine = {lineStyle:{}};
|
|
323
|
-
this.config.yAxis.splitLine.lineStyle.width = isYAxisSplitlineLinestyleWidth
|
|
331
|
+
this.config.yAxis.splitLine = { lineStyle: {} };
|
|
332
|
+
this.config.yAxis.splitLine.lineStyle.width = isYAxisSplitlineLinestyleWidth
|
|
333
|
+
? 1
|
|
334
|
+
: 0;
|
|
324
335
|
this.config.yAxis.splitLine.lineStyle.type = yAxisSplitlineLinestyleType;
|
|
325
336
|
}
|
|
326
337
|
// 显示 Y 轴刻度 最大值,最小值
|
|
@@ -344,7 +355,9 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
344
355
|
*/
|
|
345
356
|
protected setEmptyValue(xIsCountEmpty) {
|
|
346
357
|
if (!xIsCountEmpty) {
|
|
347
|
-
const nonEmpty = this.config.xAxis.data.filter(
|
|
358
|
+
const nonEmpty = this.config.xAxis.data.filter(
|
|
359
|
+
(item) => item !== undefined && item !== null
|
|
360
|
+
);
|
|
348
361
|
this.config.xAxis.data = nonEmpty;
|
|
349
362
|
}
|
|
350
363
|
}
|
|
@@ -357,7 +370,7 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
357
370
|
private removeEmpty(arrXAxis) {
|
|
358
371
|
const arrNewxAxis = [];
|
|
359
372
|
if (arrXAxis.length > 0) {
|
|
360
|
-
for(let i = 0; i < arrXAxis.length; i++) {
|
|
373
|
+
for (let i = 0; i < arrXAxis.length; i++) {
|
|
361
374
|
if (arrXAxis[i]) {
|
|
362
375
|
arrNewxAxis.push(arrXAxis[i]);
|
|
363
376
|
}
|
|
@@ -35,7 +35,7 @@ class EchartLine extends EchartBase {
|
|
|
35
35
|
name,
|
|
36
36
|
methodName,
|
|
37
37
|
type,
|
|
38
|
-
params
|
|
38
|
+
params
|
|
39
39
|
);
|
|
40
40
|
// 获取 x 轴数据
|
|
41
41
|
|
|
@@ -57,12 +57,18 @@ class EchartLine extends EchartBase {
|
|
|
57
57
|
},
|
|
58
58
|
data: [],
|
|
59
59
|
};
|
|
60
|
-
sortedXAxisData.forEach((itemSource,index) => {
|
|
60
|
+
sortedXAxisData.forEach((itemSource, index) => {
|
|
61
61
|
this.config.series[j].name = itemSource.YLabels[j].Cn_Name;
|
|
62
|
-
if (
|
|
62
|
+
if (
|
|
63
|
+
(itemSource.YLabels[j].Value === undefined ||
|
|
64
|
+
itemSource.YLabels[j].Value === null) &&
|
|
65
|
+
!xIsCountEmpty
|
|
66
|
+
) {
|
|
63
67
|
arrXisCountEmptyIndex.push(index);
|
|
64
68
|
} else {
|
|
65
|
-
const value = itemSource.YLabels[j].Value
|
|
69
|
+
const value = itemSource.YLabels[j].Value
|
|
70
|
+
? itemSource.YLabels[j].Value
|
|
71
|
+
: 0;
|
|
66
72
|
this.config.series[j].data.push(value);
|
|
67
73
|
}
|
|
68
74
|
});
|
|
@@ -90,38 +96,28 @@ class EchartLine extends EchartBase {
|
|
|
90
96
|
// 组装图表需要的数据
|
|
91
97
|
const groupNames = Object.keys(objGroupKey);
|
|
92
98
|
this.config.series = groupNames.map((groupKey) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
this.config.tooltip.formatter = params => (
|
|
111
|
-
`${params.data.dimensionality
|
|
112
|
-
}\r\n${
|
|
113
|
-
params.data.name
|
|
114
|
-
}\r\n${
|
|
115
|
-
params.seriesName
|
|
116
|
-
}:${
|
|
117
|
-
params.value}`
|
|
118
|
-
);
|
|
99
|
+
// groupKey分组字段中文名
|
|
100
|
+
const serie = {
|
|
101
|
+
name: groupKey,
|
|
102
|
+
connectNulls: true,
|
|
103
|
+
data: this.getSeriesDataGroup(arrXaxisData, objGroupKey[groupKey]),
|
|
104
|
+
type: 'line',
|
|
105
|
+
smooth: true,
|
|
106
|
+
showSymbol: true, // 是否显示线条上数据标签
|
|
107
|
+
label: {
|
|
108
|
+
show: true, // 显示线条上的数据
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
return serie;
|
|
112
|
+
});
|
|
113
|
+
this.config.tooltip.formatter = (params) =>
|
|
114
|
+
`${params.data.dimensionality}\r\n${params.data.name}\r\n${params.seriesName}:${params.value}`;
|
|
119
115
|
}
|
|
120
116
|
}
|
|
121
117
|
}
|
|
122
118
|
setChartType({ chartType }) {
|
|
123
|
-
this.config.series.length > 0
|
|
124
|
-
|
|
119
|
+
this.config.series.length > 0 &&
|
|
120
|
+
this.config.series.forEach((itemSeries) => {
|
|
125
121
|
itemSeries.smooth = chartType !== 'line';
|
|
126
122
|
});
|
|
127
123
|
}
|
|
@@ -132,19 +128,17 @@ class EchartLine extends EchartBase {
|
|
|
132
128
|
isUnit,
|
|
133
129
|
unit,
|
|
134
130
|
decimalDigits,
|
|
135
|
-
suffix
|
|
131
|
+
suffix,
|
|
136
132
|
}) {
|
|
137
133
|
decimalDigits = decimalDigits < 0 ? 0 : decimalDigits;
|
|
138
|
-
this.config.series.length > 0
|
|
139
|
-
|
|
134
|
+
this.config.series.length > 0 &&
|
|
135
|
+
this.config.series.forEach((itemSeries) => {
|
|
140
136
|
itemSeries.showSymbol = isSeriesShowSymbol;
|
|
141
137
|
itemSeries.label.show = isSeriesShowSymbol;
|
|
142
138
|
if (isUnit) {
|
|
143
139
|
itemSeries.label.formatter = (params) => {
|
|
144
140
|
const objNewValue = this.getValueByUnit(params.value, unit);
|
|
145
|
-
return (
|
|
146
|
-
`${objNewValue.toFixed(decimalDigits)}${suffix}`
|
|
147
|
-
);
|
|
141
|
+
return `${objNewValue.toFixed(decimalDigits)}${suffix}`;
|
|
148
142
|
};
|
|
149
143
|
}
|
|
150
144
|
});
|
|
@@ -189,7 +183,7 @@ class EchartLine extends EchartBase {
|
|
|
189
183
|
isUnit,
|
|
190
184
|
unit,
|
|
191
185
|
decimalDigits,
|
|
192
|
-
suffix
|
|
186
|
+
suffix,
|
|
193
187
|
}) {
|
|
194
188
|
if (dataSource) {
|
|
195
189
|
await this.setSourceData({
|
|
@@ -223,7 +217,7 @@ class EchartLine extends EchartBase {
|
|
|
223
217
|
isUnit,
|
|
224
218
|
unit,
|
|
225
219
|
decimalDigits,
|
|
226
|
-
suffix
|
|
220
|
+
suffix,
|
|
227
221
|
});
|
|
228
222
|
}
|
|
229
223
|
}
|
|
@@ -32,7 +32,7 @@ class EchartPie extends EchartBase {
|
|
|
32
32
|
name,
|
|
33
33
|
methodName,
|
|
34
34
|
type,
|
|
35
|
-
params
|
|
35
|
+
params
|
|
36
36
|
);
|
|
37
37
|
// 获取 x 轴数据
|
|
38
38
|
if (arrSourData.length >= 0) {
|
|
@@ -59,8 +59,8 @@ class EchartPie extends EchartBase {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
setChartType({ chartType }) {
|
|
62
|
-
this.config.series.length > 0
|
|
63
|
-
|
|
62
|
+
this.config.series.length > 0 &&
|
|
63
|
+
this.config.series.forEach((itemSeries) => {
|
|
64
64
|
if (chartType === 'pie') {
|
|
65
65
|
itemSeries.radius = '70%';
|
|
66
66
|
} else {
|
|
@@ -77,7 +77,7 @@ class EchartPie extends EchartBase {
|
|
|
77
77
|
isUnit,
|
|
78
78
|
unit,
|
|
79
79
|
decimalDigits,
|
|
80
|
-
suffix
|
|
80
|
+
suffix,
|
|
81
81
|
}) {
|
|
82
82
|
decimalDigits = decimalDigits < 0 ? 0 : decimalDigits;
|
|
83
83
|
let show = false;
|
|
@@ -94,10 +94,12 @@ class EchartPie extends EchartBase {
|
|
|
94
94
|
} else {
|
|
95
95
|
this.config.series[0].label.normal.formatter = (objValue) => {
|
|
96
96
|
let reData = '';
|
|
97
|
-
if (isSeriesShowSymbol) {
|
|
97
|
+
if (isSeriesShowSymbol) {
|
|
98
|
+
// 显示数值
|
|
98
99
|
reData = objValue.value;
|
|
99
100
|
}
|
|
100
|
-
if (isUnit) {
|
|
101
|
+
if (isUnit) {
|
|
102
|
+
// 显示单位
|
|
101
103
|
if (unit) {
|
|
102
104
|
const objNewValue = this.getValueByUnit(objValue.value, unit);
|
|
103
105
|
reData = `${objNewValue.toFixed(decimalDigits)}${suffix}`;
|
|
@@ -111,7 +113,8 @@ class EchartPie extends EchartBase {
|
|
|
111
113
|
};
|
|
112
114
|
});
|
|
113
115
|
}
|
|
114
|
-
if (isPercent) {
|
|
116
|
+
if (isPercent) {
|
|
117
|
+
// 显示百分比
|
|
115
118
|
reData = `${reData}(${objValue.percent}%)`;
|
|
116
119
|
}
|
|
117
120
|
return reData;
|
|
@@ -138,7 +141,7 @@ class EchartPie extends EchartBase {
|
|
|
138
141
|
isUnit,
|
|
139
142
|
unit,
|
|
140
143
|
decimalDigits,
|
|
141
|
-
suffix
|
|
144
|
+
suffix,
|
|
142
145
|
}) {
|
|
143
146
|
legend = document.body.clientWidth < 1024 ? legend : legend2;
|
|
144
147
|
if (dataSource) {
|
|
@@ -162,7 +165,7 @@ class EchartPie extends EchartBase {
|
|
|
162
165
|
isUnit,
|
|
163
166
|
unit,
|
|
164
167
|
decimalDigits,
|
|
165
|
-
suffix
|
|
168
|
+
suffix,
|
|
166
169
|
});
|
|
167
170
|
}
|
|
168
171
|
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
export interface DataSource {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
name: string; // 数据源名
|
|
3
|
+
type: string; // 数据源类型
|
|
4
|
+
subType: string; // 数据源子类型
|
|
5
|
+
provider?: string; // 内置连接器类型
|
|
6
|
+
methodName: string; // 数据源方法名
|
|
7
7
|
}
|
|
8
8
|
export interface ObjSource {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
dataSourceName: string; // 数据源名
|
|
10
|
+
dataSourceType: string; // 数据源类型
|
|
11
|
+
dataSourceMethodName: string; // 数据源方法名
|
|
12
12
|
}
|
|
13
13
|
export interface Xfield {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
format: string;
|
|
15
|
+
type: string;
|
|
16
|
+
title: string;
|
|
17
|
+
name: string;
|
|
18
18
|
}
|
|
19
19
|
enum CountType {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
'count',
|
|
21
|
+
'sum',
|
|
22
|
+
'avg',
|
|
23
|
+
'max',
|
|
24
|
+
'min',
|
|
25
25
|
}
|
|
26
26
|
export interface YfieldOne {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
key: string;
|
|
28
|
+
operationType: CountType;
|
|
29
|
+
title?: string;
|
|
30
30
|
}
|
|
31
31
|
export interface Yfield {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
32
|
+
groupKey?: string;
|
|
33
|
+
numValue?: Array<YfieldOne>;
|
|
34
|
+
}
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
}
|
|
18
18
|
.weda-ui-echart .echart-light-box {
|
|
19
19
|
position: relative;
|
|
20
|
-
background-color: #
|
|
20
|
+
background-color: #f4f5f6;
|
|
21
21
|
}
|
|
22
22
|
.weda-ui-echart .echart-light-body {
|
|
23
23
|
background-color: #ffffff;
|
|
24
24
|
}
|
|
25
25
|
.weda-ui-echart .echart-dark-box {
|
|
26
26
|
position: relative;
|
|
27
|
-
background-color: #
|
|
27
|
+
background-color: #4b5d6c;
|
|
28
28
|
}
|
|
29
29
|
.weda-ui-echart .echart-dark-body {
|
|
30
|
-
background-color: #
|
|
30
|
+
background-color: #1d1f24;
|
|
31
31
|
margin: 6px;
|
|
32
32
|
}
|
|
33
33
|
.weda-ui-echart .btn-grounp {
|
|
@@ -67,20 +67,20 @@
|
|
|
67
67
|
user-select: none;
|
|
68
68
|
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
69
69
|
position: relative;
|
|
70
|
-
color: #
|
|
70
|
+
color: #4b5d6c;
|
|
71
71
|
background-color: #fff;
|
|
72
|
-
border-color: #
|
|
72
|
+
border-color: #ccd2d8;
|
|
73
73
|
}
|
|
74
74
|
.weda-ui-echart .button,
|
|
75
|
-
.weda-ui-echart html [type=
|
|
76
|
-
.weda-ui-echart [type=
|
|
77
|
-
.weda-ui-echart [type=
|
|
75
|
+
.weda-ui-echart html [type='button'],
|
|
76
|
+
.weda-ui-echart [type='reset'],
|
|
77
|
+
.weda-ui-echart [type='submit'] {
|
|
78
78
|
-webkit-appearance: button;
|
|
79
79
|
}
|
|
80
80
|
.weda-ui-echart .ant-btn-primary {
|
|
81
81
|
color: #fff;
|
|
82
|
-
background-color: #
|
|
83
|
-
border-color: #
|
|
82
|
+
background-color: #4a62e7;
|
|
83
|
+
border-color: #4a62e7;
|
|
84
84
|
}
|
|
85
85
|
.weda-ui-echart .ant-btn:not([disabled]):hover {
|
|
86
86
|
text-decoration: none;
|
|
@@ -94,9 +94,9 @@
|
|
|
94
94
|
}
|
|
95
95
|
.weda-ui-echart .ant-btn:hover,
|
|
96
96
|
.weda-ui-echart .ant-btn:focus {
|
|
97
|
-
color: #
|
|
97
|
+
color: #4a62e7;
|
|
98
98
|
background-color: #fff;
|
|
99
|
-
border-color: #
|
|
99
|
+
border-color: #4a62e7;
|
|
100
100
|
}
|
|
101
101
|
.weda-ui-echart .ant-btn-primary:hover,
|
|
102
102
|
.weda-ui-echart .ant-btn-primary:focus {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
TitleComponent,
|
|
8
8
|
TooltipComponent,
|
|
9
9
|
LegendComponent,
|
|
10
|
-
GridComponent
|
|
10
|
+
GridComponent,
|
|
11
11
|
} from 'echarts/components';
|
|
12
12
|
// 标签自动布局,全局过渡动画等特性
|
|
13
13
|
import { LabelLayout, UniversalTransition } from 'echarts/features';
|
|
@@ -25,9 +25,7 @@ echarts.use([
|
|
|
25
25
|
CanvasRenderer,
|
|
26
26
|
BarChart,
|
|
27
27
|
LineChart,
|
|
28
|
-
PieChart
|
|
28
|
+
PieChart,
|
|
29
29
|
]);
|
|
30
30
|
|
|
31
|
-
export {
|
|
32
|
-
echarts
|
|
33
|
-
};
|
|
31
|
+
export { echarts };
|
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
useAsync,
|
|
3
|
+
useDeepCompareEffect,
|
|
4
|
+
useEventListener,
|
|
5
|
+
useIsMounted,
|
|
6
|
+
useMountEffect,
|
|
7
|
+
} from '@react-hookz/web';
|
|
8
|
+
import {
|
|
9
|
+
MutableRefObject,
|
|
10
|
+
RefObject,
|
|
11
|
+
useCallback,
|
|
12
|
+
useEffect,
|
|
13
|
+
useMemo,
|
|
14
|
+
useRef,
|
|
15
|
+
} from 'react';
|
|
16
|
+
import { IEchartModalBase } from './core/eChartBase';
|
|
17
|
+
import { echarts } from './echarts';
|
|
5
18
|
|
|
6
|
-
export function useChart(
|
|
19
|
+
export function useChart(
|
|
20
|
+
ref: RefObject<HTMLElement> | MutableRefObject<HTMLElement>
|
|
21
|
+
) {
|
|
7
22
|
const chartRef = useRef<echarts.ECharts>();
|
|
8
23
|
const isMounted = useIsMounted();
|
|
9
24
|
useMountEffect(() => {
|
|
10
|
-
|
|
11
|
-
if(!ref.current || !isMounted) {
|
|
25
|
+
if (!ref.current || !isMounted) {
|
|
12
26
|
return;
|
|
13
27
|
}
|
|
14
28
|
|
|
@@ -28,16 +42,19 @@ export function useChart(ref: RefObject<HTMLElement> | MutableRefObject<HTMLElem
|
|
|
28
42
|
return chartRef.current;
|
|
29
43
|
}
|
|
30
44
|
|
|
31
|
-
|
|
32
45
|
/**
|
|
33
46
|
* @deprecated The method should not be used
|
|
34
47
|
*/
|
|
35
|
-
export function useWedaChart(
|
|
48
|
+
export function useWedaChart(
|
|
49
|
+
domRef,
|
|
50
|
+
ModalClass: IEchartModalBase,
|
|
51
|
+
options: echarts.EChartsCoreOption
|
|
52
|
+
) {
|
|
36
53
|
const chart = useChart(domRef);
|
|
37
|
-
const getOptions = async() => {
|
|
54
|
+
const getOptions = async () => {
|
|
38
55
|
const chartModal = new ModalClass();
|
|
39
56
|
let finalOptions: any = await chartModal.setOptions(options);
|
|
40
|
-
if(!finalOptions) {
|
|
57
|
+
if (!finalOptions) {
|
|
41
58
|
finalOptions = chartModal.getOptions() as any;
|
|
42
59
|
}
|
|
43
60
|
return finalOptions;
|
|
@@ -50,18 +67,19 @@ export function useWedaChart(domRef, ModalClass: IEchartModalBase, options: echa
|
|
|
50
67
|
useDeepCompareEffect(() => {
|
|
51
68
|
actions.execute();
|
|
52
69
|
}, [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
70
|
+
// options 变化,包含所有配置项,包括纯前端的配置项变化都会触发setOptions里发请求,但改不动了
|
|
71
|
+
options,
|
|
72
|
+
actions,
|
|
73
|
+
]);
|
|
56
74
|
useEffect(() => {
|
|
57
|
-
if(state.status === 'success' && chart) {
|
|
75
|
+
if (state.status === 'success' && chart) {
|
|
58
76
|
console.log(ModalClass.name, options, state.result, window.location.href);
|
|
59
77
|
chart.setOption(
|
|
60
78
|
state.result,
|
|
61
79
|
true // noMerge 全刷
|
|
62
80
|
);
|
|
63
81
|
} else {
|
|
64
|
-
if(state.status === 'error') {
|
|
82
|
+
if (state.status === 'error') {
|
|
65
83
|
console.error(state.error);
|
|
66
84
|
}
|
|
67
85
|
}
|