@cloudbase/weda-ui 0.2.16 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/README.md +41 -169
  2. package/package.json +23 -11
  3. package/src/configs/components/calendar.json +4 -1
  4. package/src/configs/components/chart/bar.json +724 -0
  5. package/src/configs/components/chart/line.json +679 -0
  6. package/src/configs/components/chart/pie.json +497 -0
  7. package/src/configs/components/chart/statisticsCard.json +61 -13
  8. package/src/configs/components/container.json +7 -2
  9. package/src/configs/components/dataView.json +21 -6
  10. package/src/configs/components/form/checkbox.json +97 -5
  11. package/src/configs/components/form/radio.json +96 -4
  12. package/src/configs/components/form/select.json +245 -11
  13. package/src/configs/components/graphicCard.json +84 -73
  14. package/src/configs/components/image.json +7 -2
  15. package/src/configs/components/link.json +19 -3
  16. package/src/configs/components/listView.json +65 -18
  17. package/src/configs/components/lottery.json +151 -0
  18. package/src/configs/components/modal.json +37 -5
  19. package/src/configs/components/navLayout.json +87 -75
  20. package/src/configs/components/navigationBar.json +59 -0
  21. package/src/configs/components/richtextview.json +4 -1
  22. package/src/configs/components/scrollVeiw.json +74 -22
  23. package/src/configs/components/swiper.json +4 -1
  24. package/src/configs/components/tabs.json +51 -8
  25. package/src/configs/components/text.json +33 -25
  26. package/src/configs/components/wxOpenApi/phone.json +141 -0
  27. package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
  28. package/src/configs/components/wxOpenApi/share.json +167 -0
  29. package/src/configs/components/wxOpenApi/userInfo.json +174 -0
  30. package/src/configs/index.js +20 -0
  31. package/src/index.js +2 -0
  32. package/src/mp/components/button/index.wxml +1 -2
  33. package/src/mp/components/chart/bar/index.js +258 -0
  34. package/src/mp/components/chart/bar/index.json +6 -0
  35. package/src/mp/components/chart/bar/index.wxml +3 -0
  36. package/src/mp/components/chart/bar/index.wxss +9 -0
  37. package/src/mp/components/chart/common/config/bar.js +50 -0
  38. package/src/mp/components/chart/common/config/global.js +16 -0
  39. package/src/mp/components/chart/common/config/line.js +48 -0
  40. package/src/mp/components/chart/common/config/pie.js +36 -0
  41. package/src/mp/components/chart/common/core/eChartBar.js +263 -0
  42. package/src/mp/components/chart/common/core/eChartBase.js +375 -0
  43. package/src/mp/components/chart/common/core/eChartLine.js +229 -0
  44. package/src/mp/components/chart/common/core/eChartPie.js +166 -0
  45. package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
  46. package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
  47. package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
  48. package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
  49. package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
  50. package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
  51. package/src/mp/components/chart/line/index.js +247 -0
  52. package/src/mp/components/chart/line/index.json +6 -0
  53. package/src/mp/components/chart/line/index.wxml +3 -0
  54. package/src/mp/components/chart/line/index.wxss +9 -0
  55. package/src/mp/components/chart/pie/index.js +182 -0
  56. package/src/mp/components/chart/pie/index.json +6 -0
  57. package/src/mp/components/chart/pie/index.wxml +4 -0
  58. package/src/mp/components/chart/pie/index.wxss +9 -0
  59. package/src/mp/components/chart/statisticsCard/index.js +33 -6
  60. package/src/mp/components/form/checkbox/index.js +41 -2
  61. package/src/mp/components/form/checkbox/index.wxml +1 -1
  62. package/src/mp/components/form/form/index.wxml +1 -2
  63. package/src/mp/components/form/input/index.js +1 -1
  64. package/src/mp/components/form/location/index.js +43 -2
  65. package/src/mp/components/form/radio/index.js +38 -0
  66. package/src/mp/components/form/select/index.js +348 -40
  67. package/src/mp/components/form/select/index.wxml +21 -6
  68. package/src/mp/components/form/select/region/index.js +101 -0
  69. package/src/mp/components/form/textarea/index.wxml +6 -5
  70. package/src/mp/components/form/uploader/index.js +76 -44
  71. package/src/mp/components/form/uploader/index.wxml +15 -3
  72. package/src/mp/components/form/uploaderFile/index.js +61 -29
  73. package/src/mp/components/graphicCard/index.js +26 -28
  74. package/src/mp/components/listView/index.js +52 -64
  75. package/src/mp/components/listView/index.wxml +2 -2
  76. package/src/mp/components/listView/index.wxss +5 -0
  77. package/src/mp/components/lottery/index.js +270 -0
  78. package/src/mp/components/lottery/index.json +4 -0
  79. package/src/mp/components/lottery/index.wxml +43 -0
  80. package/src/mp/components/lottery/index.wxss +317 -0
  81. package/src/mp/components/navLayout/index.js +3 -3
  82. package/src/mp/components/navigationBar/index.js +193 -0
  83. package/src/mp/components/navigationBar/index.json +6 -0
  84. package/src/mp/components/navigationBar/index.wxml +88 -0
  85. package/src/mp/components/navigationBar/index.wxss +1257 -0
  86. package/src/mp/components/tabs/index.js +7 -2
  87. package/src/mp/components/tabs/index.wxml +2 -1
  88. package/src/mp/components/text/index.js +0 -25
  89. package/src/mp/components/text/index.wxml +3 -3
  90. package/src/mp/components/wxOpenApi/phone/index.js +117 -0
  91. package/src/mp/components/wxOpenApi/phone/index.json +4 -0
  92. package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
  93. package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
  94. package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
  95. package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
  96. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
  97. package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
  98. package/src/mp/components/wxOpenApi/share/index.js +117 -0
  99. package/src/mp/components/wxOpenApi/share/index.json +4 -0
  100. package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
  101. package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
  102. package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
  103. package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
  104. package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
  105. package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
  106. package/src/mp/index.json +10 -1
  107. package/src/mp/style/weda-ui.wxss +2 -0
  108. package/src/mp/utils/constant.js +15 -0
  109. package/src/mp/utils/destr.js +48 -0
  110. package/src/mp/utils/lodash.js +2 -0
  111. package/src/mp/utils/platform.js +25 -0
  112. package/src/mp/utils/tcb.js +44 -0
  113. package/src/setupTests.js +2 -1
  114. package/src/web/components/button/index.css +8 -1
  115. package/src/web/components/button/index.tsx +3 -2
  116. package/src/web/components/chart/bar/index.tsx +140 -0
  117. package/src/web/components/chart/common/config/bar.js +49 -0
  118. package/src/web/components/chart/common/config/global.js +16 -0
  119. package/src/web/components/chart/common/config/line.js +50 -0
  120. package/src/web/components/chart/common/config/pie.js +37 -0
  121. package/src/web/components/chart/common/core/eChartBar.js +265 -0
  122. package/src/web/components/chart/common/core/eChartBase.ts +383 -0
  123. package/src/web/components/chart/common/core/eChartLine.js +231 -0
  124. package/src/web/components/chart/common/core/eChartPie.js +170 -0
  125. package/src/web/components/chart/common/core/type.ts +34 -0
  126. package/src/web/components/chart/common/echart.css +106 -0
  127. package/src/web/components/chart/common/echarts.ts +33 -0
  128. package/src/web/components/chart/common/useChart.tsx +69 -0
  129. package/src/web/components/chart/line/index.tsx +136 -0
  130. package/src/web/components/chart/pie/index.tsx +99 -0
  131. package/src/web/components/chart/statisticsCard/index.tsx +29 -8
  132. package/src/web/components/form/checkbox/index.tsx +61 -23
  133. package/src/web/components/form/formcell/index.tsx +10 -5
  134. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +3 -3
  135. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +2 -2
  136. package/src/web/components/form/radio/index.tsx +90 -53
  137. package/src/web/components/form/select/h5.tsx +371 -72
  138. package/src/web/components/form/select/index.css +10 -0
  139. package/src/web/components/form/select/index.tsx +392 -145
  140. package/src/web/components/form/select/region/index.ts +122 -31
  141. package/src/web/components/form/select/time.jsx +90 -0
  142. package/src/web/components/form/select/year.tsx +170 -0
  143. package/src/web/components/form/tips/index.css +4 -0
  144. package/src/web/components/form/tips/index.tsx +4 -3
  145. package/src/web/components/form/uploader/uploader.h5.tsx +28 -19
  146. package/src/web/components/form/uploader/uploader.pc.tsx +17 -20
  147. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +48 -44
  148. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +28 -26
  149. package/src/web/components/graphicCard/index.css +1 -5
  150. package/src/web/components/graphicCard/index.tsx +4 -3
  151. package/src/web/components/image/image.tsx +1 -1
  152. package/src/web/components/image/index.tsx +1 -1
  153. package/src/web/components/index.js +13 -2
  154. package/src/web/components/link/index.tsx +6 -3
  155. package/src/web/components/listView/index.css +4 -0
  156. package/src/web/components/listView/index.tsx +10 -18
  157. package/src/web/components/lottery/index.css +327 -0
  158. package/src/web/components/lottery/index.tsx +567 -0
  159. package/src/web/components/lottery/lotteryUtil.ts +130 -0
  160. package/src/web/components/modal/index.tsx +3 -1
  161. package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
  162. package/src/web/components/navigationBar/common.tsx +198 -0
  163. package/src/web/components/navigationBar/h5Menu.tsx +179 -0
  164. package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
  165. package/src/web/components/navigationBar/index.css +762 -0
  166. package/src/web/components/navigationBar/index.tsx +231 -0
  167. package/src/web/components/navigationBar/type.d.ts +111 -0
  168. package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
  169. package/src/web/components/phone/index.css +0 -0
  170. package/src/web/components/phone/index.tsx +22 -0
  171. package/src/web/components/phoneCode/index.css +0 -0
  172. package/src/web/components/phoneCode/index.tsx +22 -0
  173. package/src/web/components/richTextView/index.tsx +3 -5
  174. package/src/web/components/share/index.css +0 -0
  175. package/src/web/components/share/index.tsx +38 -0
  176. package/src/web/components/tabs/index.tsx +2 -0
  177. package/src/web/components/tabs/tabs.h5.tsx +43 -33
  178. package/src/web/components/tabs/tabs.pc.tsx +23 -10
  179. package/src/web/components/text/index.tsx +6 -14
  180. package/src/web/components/userInfo/index.css +0 -0
  181. package/src/web/components/userInfo/index.tsx +30 -0
  182. package/src/web/utils/{constant.js → constant.ts} +17 -2
  183. package/src/web/utils/lodash.ts +2 -0
  184. package/src/web/utils/platform.js +10 -1
  185. package/src/web/utils/tcb.js +20 -6
  186. package/src/web/weda-ui.css +2 -0
  187. package/CHANGELOG.md +0 -240
  188. package/src/.DS_Store +0 -0
  189. package/src/configs/.DS_Store +0 -0
  190. package/src/mp/.gitignore +0 -10
  191. package/src/web/.DS_Store +0 -0
  192. package/src/web/components/form/select/region/cities.ts +0 -2410
  193. package/src/web/components/form/select/region/provinces.ts +0 -240
  194. package/src/web/components/form/select/region/regions.ts +0 -20645
@@ -0,0 +1,231 @@
1
+ import EchartBase from './eChartBase';
2
+ import getConfig from '../config/line';
3
+ /**
4
+ * 折线图表
5
+ * @author loonglong
6
+ **/
7
+ class EchartLine extends EchartBase {
8
+ constructor() {
9
+ super();
10
+ const config = getConfig();
11
+ this.config = { ...this.config, ...config };
12
+ }
13
+ async setSourceData({
14
+ dataSource,
15
+ filterData,
16
+ xField,
17
+ xStatistics,
18
+ xIsCountEmpty,
19
+ yField,
20
+ groupKey,
21
+ groupKeyTimeSpan,
22
+ }) {
23
+ const { name = '', type = '', methodName = '' } = dataSource;
24
+ if (name !== '') {
25
+ const params = this.createWhere({
26
+ filterData,
27
+ xField,
28
+ xStatistics,
29
+ xIsCountEmpty,
30
+ yField,
31
+ groupKey,
32
+ groupKeyTimeSpan,
33
+ });
34
+ const arrSourData = await this.getSourceData(
35
+ name,
36
+ methodName,
37
+ type,
38
+ params,
39
+ );
40
+ // 获取 x 轴数据
41
+
42
+ const sortedXAxisData = this.sortXAxisData(arrSourData, xField.format);
43
+ const arrXaxisData = this.setXaxis(sortedXAxisData, xField.format);
44
+ const arrXisCountEmptyIndex = []; // 记录空值的key
45
+ if (Object.keys(groupKey ?? {}).length === 0) {
46
+ const numLine = sortedXAxisData[0].YLabels.length;
47
+ if (numLine > 0) {
48
+ for (let j = 0; j < numLine; j++) {
49
+ this.config.series[j] = {
50
+ type: 'line',
51
+ smooth: true,
52
+ name: '',
53
+ connectNulls: true,
54
+ showSymbol: true,
55
+ label: {
56
+ show: true,
57
+ },
58
+ data: [],
59
+ };
60
+ sortedXAxisData.forEach((itemSource,index) => {
61
+ this.config.series[j].name = itemSource.YLabels[j].Cn_Name;
62
+ if ((itemSource.YLabels[j].Value === undefined || itemSource.YLabels[j].Value === null) && !xIsCountEmpty) {
63
+ arrXisCountEmptyIndex.push(index);
64
+ } else {
65
+ const value = itemSource.YLabels[j].Value ? itemSource.YLabels[j].Value : 0;
66
+ this.config.series[j].data.push(value);
67
+ }
68
+ });
69
+ }
70
+ }
71
+ // 处理显示空值问题
72
+ this.setEmptyValue(xIsCountEmpty);
73
+ } else if (groupKey) {
74
+ // 如果是分组,则这里需要特殊处理
75
+ // 按groupKey分组存放数据值
76
+ const objGroupKey = {}; // {'分组字段':[{value:'统计的值', dimensionality:'维度名', name:'统计的数值字段名'}]}
77
+ sortedXAxisData.forEach((itemSourData) => {
78
+ itemSourData.YLabels.forEach((yLabel) => {
79
+ if (!objGroupKey[yLabel.Group_Name]) {
80
+ objGroupKey[yLabel.Group_Name] = [];
81
+ }
82
+ objGroupKey[yLabel.Group_Name].push({
83
+ value: yLabel.Value,
84
+ dimensionality: itemSourData.XLabel.Value,
85
+ name: yLabel.Cn_Name,
86
+ });
87
+ });
88
+ });
89
+
90
+ // 组装图表需要的数据
91
+ const groupNames = Object.keys(objGroupKey);
92
+ this.config.series = groupNames.map((groupKey) => {
93
+ // groupKey分组字段中文名
94
+ const serie = {
95
+ name: groupKey,
96
+ connectNulls: true,
97
+ data: this.getSeriesDataGroup(
98
+ arrXaxisData,
99
+ objGroupKey[groupKey],
100
+ ),
101
+ type: 'line',
102
+ smooth: true,
103
+ showSymbol: true, // 是否显示线条上数据标签
104
+ label: {
105
+ show: true, // 显示线条上的数据
106
+ },
107
+ };
108
+ return serie;
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
+ );
119
+ }
120
+ }
121
+ }
122
+ setChartType({ chartType }) {
123
+ this.config.series.length > 0
124
+ && this.config.series.forEach((itemSeries) => {
125
+ itemSeries.smooth = chartType !== 'line';
126
+ });
127
+ }
128
+
129
+ // 显示图表上的数据标签 单位,标签,小数位数,后缀
130
+ setIsSeriesShowSymbol({
131
+ isSeriesShowSymbol,
132
+ isUnit,
133
+ unit,
134
+ decimalDigits,
135
+ suffix
136
+ }) {
137
+ decimalDigits = decimalDigits < 0 ? 0 : decimalDigits;
138
+ this.config.series.length > 0
139
+ && this.config.series.forEach((itemSeries) => {
140
+ itemSeries.showSymbol = isSeriesShowSymbol;
141
+ itemSeries.label.show = isSeriesShowSymbol;
142
+ if (isUnit) {
143
+ itemSeries.label.formatter = (params) => {
144
+ const objNewValue = this.getValueByUnit(params.value, unit);
145
+ return (
146
+ `${objNewValue.toFixed(decimalDigits)}${suffix}`
147
+ );
148
+ };
149
+ }
150
+ });
151
+ if (isUnit) {
152
+ this.config.yAxis.axisLabel.formatter = (value) => {
153
+ const objNewValue = this.getValueByUnit(value, unit);
154
+ return `${objNewValue.toFixed(decimalDigits)}${suffix}`;
155
+ };
156
+ } else {
157
+ this.config.yAxis.axisLabel.formatter = null;
158
+ }
159
+ }
160
+ async setOptions({
161
+ chartType,
162
+ isTitle,
163
+ title,
164
+ titleLocation,
165
+ dataSource,
166
+ filterData,
167
+ xField,
168
+ xStatistics,
169
+ groupKey,
170
+ groupKeyTimeSpan,
171
+ xIsCountEmpty,
172
+ yField,
173
+ isLegend,
174
+ legend,
175
+ legend2,
176
+ isXaxisName,
177
+ xAxisName,
178
+ isXaxisAxisLabelShow,
179
+ isXaxisAxisTickShow,
180
+ isXaxisAxisLabelRotate,
181
+ isYAxisSplitlineLinestyleWidth,
182
+ yAxisSplitlineLinestyleType,
183
+ yAxisMax,
184
+ yAxisMin,
185
+ isYAxisName,
186
+ yAxisName,
187
+ isSeriesShowSymbol,
188
+ isYAxisShow,
189
+ isUnit,
190
+ unit,
191
+ decimalDigits,
192
+ suffix
193
+ }) {
194
+ if (dataSource) {
195
+ await this.setSourceData({
196
+ dataSource,
197
+ filterData,
198
+ xField,
199
+ xStatistics,
200
+ xIsCountEmpty,
201
+ yField,
202
+ groupKey,
203
+ groupKeyTimeSpan,
204
+ });
205
+ }
206
+ legend = document.body.clientWidth < 1024 ? legend : legend2;
207
+ this.setChartType({ chartType });
208
+ this.setTitle({ isTitle, title, titleLocation });
209
+ this.setLegend({ isLegend, legend });
210
+ this.setIsXaxisAxisLabelShow({ isXaxisAxisLabelShow });
211
+ this.setIsXaxisName({ isXaxisName, xAxisName });
212
+ this.setIsXaxisAxisTickShow({ isXaxisAxisTickShow });
213
+ this.setIsXaxisAxisLabelRotate({ isXaxisAxisLabelRotate, xStatistics });
214
+ this.setIsYAxisSplitlineLinestyleWidth({
215
+ isYAxisSplitlineLinestyleWidth,
216
+ yAxisSplitlineLinestyleType,
217
+ });
218
+ this.setYAxisMaxMin({ yAxisMax, yAxisMin });
219
+ this.setIsYAxisName({ isYAxisName, yAxisName });
220
+ this.setIsYAxisShow({ isYAxisShow });
221
+ this.setIsSeriesShowSymbol({
222
+ isSeriesShowSymbol,
223
+ isUnit,
224
+ unit,
225
+ decimalDigits,
226
+ suffix
227
+ });
228
+ }
229
+ }
230
+
231
+ export default EchartLine;
@@ -0,0 +1,170 @@
1
+ import EchartBase from './eChartBase';
2
+ import getConfig from '../config/pie';
3
+ /**
4
+ * 饼状图表
5
+ * @author loonglong
6
+ **/
7
+ class EchartPie extends EchartBase {
8
+ constructor() {
9
+ super();
10
+ const config = getConfig();
11
+ this.config = { ...this.config, ...config };
12
+ }
13
+ async setSourceData({
14
+ dataSource,
15
+ filterData,
16
+ setColor,
17
+ xField,
18
+ xStatistics,
19
+ xIsCountEmpty,
20
+ yField,
21
+ }) {
22
+ const { name = '', type = '', methodName = '' } = dataSource;
23
+ if (name !== '') {
24
+ const params = this.createWhere({
25
+ filterData,
26
+ xField,
27
+ xStatistics,
28
+ xIsCountEmpty,
29
+ yField,
30
+ });
31
+ const arrSourData = await this.getSourceData(
32
+ name,
33
+ methodName,
34
+ type,
35
+ params,
36
+ );
37
+ // 获取 x 轴数据
38
+ if (arrSourData.length >= 0) {
39
+ const numPie = arrSourData[0].YLabels.length;
40
+ if (numPie > 0) {
41
+ const arrData = [];
42
+ let i = 0;
43
+ arrSourData.forEach((itemSource) => {
44
+ const numc = setColor ? setColor.length : 0;
45
+ const strColor = numc > 0 ? { color: setColor[i % numc] } : {};
46
+ arrData.push({
47
+ value: itemSource.YLabels[0].Value,
48
+ name: itemSource.XLabel.Value,
49
+ tooltip: {},
50
+ itemStyle: strColor,
51
+ });
52
+ i = i + 1;
53
+ });
54
+ this.config.series[0].data = arrData;
55
+ }
56
+ } else {
57
+ // this.config['series'][0].data = [];
58
+ }
59
+ }
60
+ }
61
+ setChartType({ chartType }) {
62
+ this.config.series.length > 0
63
+ && this.config.series.forEach((itemSeries) => {
64
+ if (chartType === 'pie') {
65
+ itemSeries.radius = '70%';
66
+ } else {
67
+ // @ts-ignore
68
+ itemSeries.radius = ['40%', '70%'];
69
+ }
70
+ });
71
+ }
72
+
73
+ // 显示图表上的数据标签 单位,标签,小数位数,后缀
74
+ setIsSeriesShowSymbol({
75
+ isSeriesShowSymbol,
76
+ isPercent,
77
+ isUnit,
78
+ unit,
79
+ decimalDigits,
80
+ suffix
81
+ }) {
82
+ decimalDigits = decimalDigits < 0 ? 0 : decimalDigits;
83
+ let show = false;
84
+ let position = 'inner';
85
+ let formatter = null;
86
+
87
+ if (isSeriesShowSymbol || isPercent || isUnit) {
88
+ formatter = '';
89
+ }
90
+ this.config.series[0].label.show = show;
91
+ this.config.series[0].label.position = position;
92
+ if (formatter === null) {
93
+ this.config.series[0].label.normal = null;
94
+ } else {
95
+ this.config.series[0].label.normal.formatter = (objValue) => {
96
+ let reData = '';
97
+ if (isSeriesShowSymbol) { // 显示数值
98
+ reData = objValue.value;
99
+ }
100
+ if (isUnit) { // 显示单位
101
+ if (unit) {
102
+ const objNewValue = this.getValueByUnit(objValue.value, unit);
103
+ reData = `${objNewValue.toFixed(decimalDigits)}${suffix}`;
104
+ } else {
105
+ reData = `${objValue.value.toFixed(decimalDigits)}`;
106
+ }
107
+ this.config.series[0].data.forEach((itemData) => {
108
+ itemData.tooltip.formatter = (objVal) => {
109
+ const objItemData = this.getValueByUnit(objVal.value, unit);
110
+ return `${objItemData.toFixed(decimalDigits)}${suffix}`;
111
+ };
112
+ });
113
+ }
114
+ if (isPercent) { // 显示百分比
115
+ reData = `${reData}(${objValue.percent}%)`;
116
+ }
117
+ return reData;
118
+ };
119
+ }
120
+ }
121
+ async setOptions({
122
+ chartType,
123
+ isTitle,
124
+ title,
125
+ titleLocation,
126
+ dataSource,
127
+ filterData,
128
+ setColor,
129
+ xField,
130
+ xStatistics,
131
+ xIsCountEmpty,
132
+ yField,
133
+ isLegend,
134
+ legend,
135
+ legend2,
136
+ isSeriesShowSymbol,
137
+ isPercent,
138
+ isUnit,
139
+ unit,
140
+ decimalDigits,
141
+ suffix
142
+ }) {
143
+ legend = document.body.clientWidth < 1024 ? legend : legend2;
144
+ if (dataSource) {
145
+ await this.setSourceData({
146
+ dataSource,
147
+ filterData,
148
+ setColor,
149
+ xField,
150
+ xStatistics,
151
+ xIsCountEmpty,
152
+ yField,
153
+ });
154
+ }
155
+
156
+ this.setChartType({ chartType });
157
+ this.setTitle({ isTitle, title, titleLocation });
158
+ this.setLegend({ isLegend, legend });
159
+ this.setIsSeriesShowSymbol({
160
+ isSeriesShowSymbol,
161
+ isPercent,
162
+ isUnit,
163
+ unit,
164
+ decimalDigits,
165
+ suffix
166
+ });
167
+ }
168
+ }
169
+
170
+ export default EchartPie;
@@ -0,0 +1,34 @@
1
+ export interface DataSource {
2
+ name:string, // 数据源名
3
+ type:string, // 数据源类型
4
+ subType:string, // 数据源子类型
5
+ provider?:string, // 内置连接器类型
6
+ methodName:string // 数据源方法名
7
+ }
8
+ export interface ObjSource {
9
+ dataSourceName:string, // 数据源名
10
+ dataSourceType:string, // 数据源类型
11
+ dataSourceMethodName:string // 数据源方法名
12
+ }
13
+ export interface Xfield {
14
+ format:string,
15
+ type:string,
16
+ title:string,
17
+ name:string,
18
+ }
19
+ enum CountType {
20
+ 'count',
21
+ 'sum',
22
+ 'avg',
23
+ 'max',
24
+ 'min'
25
+ }
26
+ export interface YfieldOne {
27
+ key:string,
28
+ operationType:CountType,
29
+ title?:string,
30
+ }
31
+ export interface Yfield {
32
+ groupKey?:string,
33
+ numValue?:Array<YfieldOne>,
34
+ }
@@ -0,0 +1,106 @@
1
+ .weda-ui-echart .set_bottom {
2
+ padding: 4px 0;
3
+ background: #fff;
4
+ margin: 0;
5
+ }
6
+ .weda-ui-echart .pc_set_title {
7
+ height: 48px;
8
+ line-height: 48px;
9
+ font-size: 16px;
10
+ padding-left: 24px;
11
+ }
12
+ .weda-ui-echart .mobile_set_title {
13
+ height: 24px;
14
+ line-height: 24px;
15
+ font-size: 12px;
16
+ padding-left: 12px;
17
+ }
18
+ .weda-ui-echart .echart-light-box {
19
+ position: relative;
20
+ background-color: #F4F5F6;
21
+ }
22
+ .weda-ui-echart .echart-light-body {
23
+ background-color: #ffffff;
24
+ }
25
+ .weda-ui-echart .echart-dark-box {
26
+ position: relative;
27
+ background-color: #4B5D6C;
28
+ }
29
+ .weda-ui-echart .echart-dark-body {
30
+ background-color: #1D1F24;
31
+ margin: 6px;
32
+ }
33
+ .weda-ui-echart .btn-grounp {
34
+ position: absolute;
35
+ top: 60px;
36
+ left: 58px;
37
+ z-index: 999;
38
+ background: transparent;
39
+ }
40
+ .weda-ui-echart button {
41
+ text-transform: none;
42
+ }
43
+ .weda-ui-echart .ant-btn,
44
+ .weda-ui-echart .ant-btn:active,
45
+ .weda-ui-echart .ant-btn:focus {
46
+ outline: 0;
47
+ }
48
+ .weda-ui-echart .ant-btn {
49
+ margin-right: 8px;
50
+ margin-bottom: 12px;
51
+ line-height: 1.499;
52
+ display: inline-block;
53
+ font-weight: 400;
54
+ text-align: center;
55
+ touch-action: manipulation;
56
+ cursor: pointer;
57
+ background-image: none;
58
+ border: 1px solid transparent;
59
+ white-space: nowrap;
60
+ padding: 0 23px;
61
+ font-size: 14px;
62
+ border-radius: 4px;
63
+ height: 36px;
64
+ -webkit-user-select: none;
65
+ -moz-user-select: none;
66
+ -ms-user-select: none;
67
+ user-select: none;
68
+ transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
69
+ position: relative;
70
+ color: #4B5D6C;
71
+ background-color: #fff;
72
+ border-color: #CCD2D8;
73
+ }
74
+ .weda-ui-echart .button,
75
+ .weda-ui-echart html [type="button"],
76
+ .weda-ui-echart [type="reset"],
77
+ .weda-ui-echart [type="submit"] {
78
+ -webkit-appearance: button;
79
+ }
80
+ .weda-ui-echart .ant-btn-primary {
81
+ color: #fff;
82
+ background-color: #4A62E7;
83
+ border-color: #4A62E7;
84
+ }
85
+ .weda-ui-echart .ant-btn:not([disabled]):hover {
86
+ text-decoration: none;
87
+ }
88
+ .weda-ui-echart .ant-btn:hover,
89
+ .weda-ui-echart .ant-btn:focus,
90
+ .weda-ui-echart .ant-btn:active,
91
+ .weda-ui-echart .ant-btn.active {
92
+ background: #fff;
93
+ text-decoration: none;
94
+ }
95
+ .weda-ui-echart .ant-btn:hover,
96
+ .weda-ui-echart .ant-btn:focus {
97
+ color: #4A62E7;
98
+ background-color: #fff;
99
+ border-color: #4A62E7;
100
+ }
101
+ .weda-ui-echart .ant-btn-primary:hover,
102
+ .weda-ui-echart .ant-btn-primary:focus {
103
+ color: #fff;
104
+ background-color: #5f78ff;
105
+ border-color: #5f78ff;
106
+ }
@@ -0,0 +1,33 @@
1
+ // 引入 echarts 核心模块,核心模块提供了 echarts 使用必须要的接口。
2
+ import * as echarts from 'echarts/core';
3
+ // 引入图表,图表后缀都为 Chart
4
+ import { BarChart, LineChart, PieChart } from 'echarts/charts';
5
+ //组件,组件后缀都为 Component
6
+ import {
7
+ TitleComponent,
8
+ TooltipComponent,
9
+ LegendComponent,
10
+ GridComponent
11
+ } from 'echarts/components';
12
+ // 标签自动布局,全局过渡动画等特性
13
+ import { LabelLayout, UniversalTransition } from 'echarts/features';
14
+ // 引入 Canvas 渲染器,注意引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
15
+ import { CanvasRenderer } from 'echarts/renderers';
16
+
17
+ // 注册必须的组件
18
+ echarts.use([
19
+ TitleComponent,
20
+ TooltipComponent,
21
+ GridComponent,
22
+ LegendComponent,
23
+ LabelLayout,
24
+ UniversalTransition,
25
+ CanvasRenderer,
26
+ BarChart,
27
+ LineChart,
28
+ PieChart
29
+ ]);
30
+
31
+ export {
32
+ echarts
33
+ };
@@ -0,0 +1,69 @@
1
+ import { useAsync, useDeepCompareEffect, useEventListener, useIsMounted, useMountEffect } from "@react-hookz/web";
2
+ import { MutableRefObject, RefObject, useCallback, useEffect, useMemo, useRef } from "react";
3
+ import { IEchartModalBase } from "./core/eChartBase";
4
+ import { echarts } from "./echarts";
5
+
6
+ export function useChart(ref: RefObject<HTMLElement> | MutableRefObject<HTMLElement>) {
7
+ const chartRef = useRef<echarts.ECharts>();
8
+ const isMounted = useIsMounted();
9
+ useMountEffect(() => {
10
+
11
+ if(!ref.current || !isMounted) {
12
+ return;
13
+ }
14
+
15
+ const echartDom = ref.current;
16
+ const chart = echarts.init(echartDom);
17
+ chartRef.current = chart;
18
+ return () => {
19
+ chart.dispose();
20
+ chartRef.current = null;
21
+ };
22
+ });
23
+
24
+ useEventListener(window, 'resize', () => {
25
+ chartRef.current && chartRef.current.resize();
26
+ });
27
+
28
+ return chartRef.current;
29
+ }
30
+
31
+
32
+ /**
33
+ * @deprecated The method should not be used
34
+ */
35
+ export function useWedaChart(domRef, ModalClass: IEchartModalBase, options: echarts.EChartsCoreOption) {
36
+ const chart = useChart(domRef);
37
+ const getOptions = async() => {
38
+ const chartModal = new ModalClass();
39
+ let finalOptions: any = await chartModal.setOptions(options);
40
+ if(!finalOptions) {
41
+ finalOptions = chartModal.getOptions() as any;
42
+ }
43
+ return finalOptions;
44
+ };
45
+ const [state, actions] = useAsync(getOptions);
46
+
47
+ useMountEffect(() => {
48
+ actions.execute();
49
+ });
50
+ useDeepCompareEffect(() => {
51
+ actions.execute();
52
+ }, [
53
+ // options 变化,包含所有配置项,包括纯前端的配置项变化都会触发setOptions里发请求,但改不动了
54
+ options,
55
+ actions]);
56
+ useEffect(() => {
57
+ if(state.status === 'success' && chart) {
58
+ console.log(ModalClass.name, options, state.result, window.location.href);
59
+ chart.setOption(
60
+ state.result,
61
+ true // noMerge 全刷
62
+ );
63
+ } else {
64
+ if(state.status === 'error') {
65
+ console.error(state.error);
66
+ }
67
+ }
68
+ }, [state]);
69
+ }