@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.
Files changed (297) hide show
  1. package/README.md +1 -0
  2. package/package.json +47 -36
  3. package/src/configs/components/button.json +60 -13
  4. package/src/configs/components/calendar.json +3 -3
  5. package/src/configs/components/carousel.json +57 -47
  6. package/src/configs/components/chart/bar.json +4 -13
  7. package/src/configs/components/chart/line.json +4 -13
  8. package/src/configs/components/chart/pie.json +3 -10
  9. package/src/configs/components/chart/statisticsCard.json +1 -4
  10. package/src/configs/components/container.json +1 -3
  11. package/src/configs/components/dataView.json +7 -15
  12. package/src/configs/components/drawer.json +24 -6
  13. package/src/configs/components/form/form.json +19 -0
  14. package/src/configs/components/form/input.json +20 -5
  15. package/src/configs/components/form/location.json +51 -48
  16. package/src/configs/components/form/radio.json +1 -3
  17. package/src/configs/components/form/richText.json +14 -14
  18. package/src/configs/components/form/select.json +62 -82
  19. package/src/configs/components/form/textarea.json +14 -1
  20. package/src/configs/components/form/uploader.json +64 -64
  21. package/src/configs/components/form/uploaderFile.json +1 -2
  22. package/src/configs/components/graphicCard.json +44 -45
  23. package/src/configs/components/image.json +44 -40
  24. package/src/configs/components/link.json +5 -10
  25. package/src/configs/components/listView.json +2 -8
  26. package/src/configs/components/lottery.json +7 -3
  27. package/src/configs/components/modal.json +26 -21
  28. package/src/configs/components/navLayout.json +68 -68
  29. package/src/configs/components/navigationBar.json +4 -1
  30. package/src/configs/components/richtextview.json +1 -1
  31. package/src/configs/components/scrollVeiw.json +14 -42
  32. package/src/configs/components/swiper.json +9 -9
  33. package/src/configs/components/wedaVideo.json +89 -0
  34. package/src/configs/components/wxOpenApi/phone.json +7 -21
  35. package/src/configs/components/wxOpenApi/phoneCode.json +7 -19
  36. package/src/configs/components/wxOpenApi/share.json +14 -24
  37. package/src/configs/components/wxOpenApi/userInfo.json +9 -27
  38. package/src/configs/index.js +2 -0
  39. package/src/mp/components/button/index.js +1 -1
  40. package/src/mp/components/button/index.wxml +19 -19
  41. package/src/mp/components/calendar/index.js +68 -38
  42. package/src/mp/components/calendar/index.json +3 -2
  43. package/src/mp/components/calendar/index.wxml +5 -7
  44. package/src/mp/components/calendar/index.wxss +17 -16
  45. package/src/mp/components/carousel/index.json +1 -1
  46. package/src/mp/components/carousel/index.wxml +2 -2
  47. package/src/mp/components/chart/bar/index.js +1 -2
  48. package/src/mp/components/chart/bar/index.wxml +1 -1
  49. package/src/mp/components/chart/common/config/bar.js +1 -1
  50. package/src/mp/components/chart/common/core/eChartBar.js +29 -34
  51. package/src/mp/components/chart/common/core/eChartBase.js +46 -32
  52. package/src/mp/components/chart/common/core/eChartLine.js +34 -40
  53. package/src/mp/components/chart/common/core/eChartPie.js +12 -9
  54. package/src/mp/components/chart/ec-canvas/ec-canvas.json +1 -1
  55. package/src/mp/components/chart/ec-canvas/wx-canvas.js +24 -22
  56. package/src/mp/components/chart/line/index.js +2 -2
  57. package/src/mp/components/chart/line/index.wxml +1 -1
  58. package/src/mp/components/chart/pie/index.js +1 -1
  59. package/src/mp/components/chart/pie/index.wxml +1 -2
  60. package/src/mp/components/chart/statisticsCard/index.wxss +7 -10
  61. package/src/mp/components/dataView/index.wxml +2 -14
  62. package/src/mp/components/form/checkbox/index.js +15 -7
  63. package/src/mp/components/form/checkbox/index.wxml +13 -25
  64. package/src/mp/components/form/form/index.wxml +3 -3
  65. package/src/mp/components/form/formcell/index.wxml +9 -9
  66. package/src/mp/components/form/formcell/index.wxss +6 -1
  67. package/src/mp/components/form/input/index.js +4 -4
  68. package/src/mp/components/form/input/index.wxml +24 -31
  69. package/src/mp/components/form/input/index.wxss +9 -3
  70. package/src/mp/components/form/location/components/mapChoose/index.json +1 -1
  71. package/src/mp/components/form/location/components/mapChoose/index.wxml +6 -6
  72. package/src/mp/components/form/location/index.js +7 -1
  73. package/src/mp/components/form/location/index.json +1 -1
  74. package/src/mp/components/form/location/index.wxml +6 -10
  75. package/src/mp/components/form/radio/index.js +14 -6
  76. package/src/mp/components/form/radio/index.wxml +12 -24
  77. package/src/mp/components/form/select/index.js +157 -98
  78. package/src/mp/components/form/select/index.wxml +11 -39
  79. package/src/mp/components/form/select/index.wxss +10 -1
  80. package/src/mp/components/form/select/region/index.js +18 -12
  81. package/src/mp/components/form/switch/index.wxml +11 -18
  82. package/src/mp/components/form/textarea/index.js +6 -0
  83. package/src/mp/components/form/textarea/index.wxml +2 -17
  84. package/src/mp/components/form/textarea/index.wxss +5 -0
  85. package/src/mp/components/form/tips/index.wxml +1 -3
  86. package/src/mp/components/form/uploader/index.js +1 -1
  87. package/src/mp/components/form/uploader/index.wxml +3 -20
  88. package/src/mp/components/form/uploader/weui-uploader.js +210 -200
  89. package/src/mp/components/form/uploader/weui-uploader.json +6 -6
  90. package/src/mp/components/form/uploader/weui-uploader.wxml +38 -38
  91. package/src/mp/components/form/uploaderFile/index.js +5 -4
  92. package/src/mp/components/form/uploaderFile/index.wxml +40 -41
  93. package/src/mp/components/graphicCard/index.js +35 -35
  94. package/src/mp/components/graphicCard/index.wxml +2 -6
  95. package/src/mp/components/graphicCard/index.wxss +6 -6
  96. package/src/mp/components/image/index.wxml +9 -20
  97. package/src/mp/components/image/index.wxss +3 -1
  98. package/src/mp/components/listView/index.wxml +5 -7
  99. package/src/mp/components/listView/index.wxss +2 -2
  100. package/src/mp/components/lottery/index.wxml +1 -3
  101. package/src/mp/components/lottery/index.wxss +31 -25
  102. package/src/mp/components/navLayout/index.js +9 -12
  103. package/src/mp/components/navLayout/index.wxml +2 -4
  104. package/src/mp/components/navLayout/index.wxss +10 -10
  105. package/src/mp/components/navigationBar/index.json +1 -2
  106. package/src/mp/components/navigationBar/index.wxml +43 -51
  107. package/src/mp/components/navigationBar/index.wxss +10 -10
  108. package/src/mp/components/richText/index.wxml +1 -1
  109. package/src/mp/components/richText/index.wxss +7 -5
  110. package/src/mp/components/swiper/index.wxml +1 -9
  111. package/src/mp/components/tabs/index.js +14 -10
  112. package/src/mp/components/tabs/index.json +1 -1
  113. package/src/mp/components/tabs/index.wxml +3 -21
  114. package/src/mp/components/tabs/index.wxss +1 -2
  115. package/src/mp/components/text/index.wxml +1 -6
  116. package/src/mp/components/text/index.wxss +1 -1
  117. package/src/mp/components/wedaVideo/index.js +86 -0
  118. package/src/mp/components/wedaVideo/index.json +4 -0
  119. package/src/mp/components/wedaVideo/index.wxml +4 -0
  120. package/src/mp/components/wedaVideo/index.wxss +20 -0
  121. package/src/mp/components/wxOpenApi/phone/index.js +1 -9
  122. package/src/mp/components/wxOpenApi/phone/index.wxml +3 -14
  123. package/src/mp/components/wxOpenApi/phoneCode/index.json +1 -1
  124. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +3 -14
  125. package/src/mp/components/wxOpenApi/share/index.wxml +3 -14
  126. package/src/mp/components/wxOpenApi/userInfo/index.wxml +3 -13
  127. package/src/mp/index.json +1 -0
  128. package/src/mp/style/weda-ui.wxss +24 -9
  129. package/src/mp/utils/deepEqual.js +37 -37
  130. package/src/mp/utils/destr.js +41 -40
  131. package/src/mp/utils/dr_square_point.js +10 -6
  132. package/src/setupTests.js +13 -13
  133. package/src/web/actions/showModal/index.tsx +5 -4
  134. package/src/web/components/button/index.tsx +44 -40
  135. package/src/web/components/calendar/index.css +99 -65
  136. package/src/web/components/carousel/index.tsx +1 -1
  137. package/src/web/components/chart/common/config/bar.js +1 -1
  138. package/src/web/components/chart/common/core/eChartBar.js +28 -34
  139. package/src/web/components/chart/common/core/eChartBase.ts +55 -42
  140. package/src/web/components/chart/common/core/eChartLine.js +34 -40
  141. package/src/web/components/chart/common/core/eChartPie.js +12 -9
  142. package/src/web/components/chart/common/core/type.ts +23 -23
  143. package/src/web/components/chart/common/echart.css +12 -12
  144. package/src/web/components/chart/common/echarts.ts +3 -5
  145. package/src/web/components/chart/common/useChart.tsx +34 -16
  146. package/src/web/components/chart/statisticsCard/index.css +9 -8
  147. package/src/web/components/container/index.tsx +3 -4
  148. package/src/web/components/drawer/index.tsx +15 -4
  149. package/src/web/components/form/checkbox/index.tsx +32 -31
  150. package/src/web/components/form/enumSelect/NormalSelect.tsx +0 -2
  151. package/src/web/components/form/form/index.css +3 -6
  152. package/src/web/components/form/form/index.tsx +7 -6
  153. package/src/web/components/form/formcell/index.css +11 -18
  154. package/src/web/components/form/formcell/index.tsx +3 -7
  155. package/src/web/components/form/input/index.css +8 -4
  156. package/src/web/components/form/input/index.tsx +61 -53
  157. package/src/web/components/form/location/common/mapChoose.css +13 -11
  158. package/src/web/components/form/location/common/selectModal.jsx +2 -11
  159. package/src/web/components/form/location/common/useLocationInfo.js +4 -0
  160. package/src/web/components/form/location/components/LocationH5/index.css +19 -20
  161. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +11 -1
  162. package/src/web/components/form/location/components/LocationPC/Header.jsx +0 -13
  163. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +14 -5
  164. package/src/web/components/form/radio/index.tsx +32 -26
  165. package/src/web/components/form/renderDecorator.tsx +23 -26
  166. package/src/web/components/form/select/h5.tsx +155 -104
  167. package/src/web/components/form/select/index.css +9 -3
  168. package/src/web/components/form/select/index.tsx +76 -49
  169. package/src/web/components/form/select/region/index.ts +101 -80
  170. package/src/web/components/form/select/year.tsx +2 -0
  171. package/src/web/components/form/switch/index.tsx +40 -40
  172. package/src/web/components/form/textarea/index.css +4 -0
  173. package/src/web/components/form/textarea/index.tsx +39 -26
  174. package/src/web/components/form/types.d.ts +10 -10
  175. package/src/web/components/form/uploader/index.css +10 -0
  176. package/src/web/components/form/uploader/uploader.h5.tsx +29 -26
  177. package/src/web/components/form/uploader/uploader.pc.tsx +3 -6
  178. package/src/web/components/form/uploaderFile/index.css +24 -23
  179. package/src/web/components/form/uploaderFile/index.jsx +0 -5
  180. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +24 -15
  181. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +21 -13
  182. package/src/web/components/graphicCard/index.css +6 -6
  183. package/src/web/components/image/image.tsx +2 -2
  184. package/src/web/components/image/index.css +9 -7
  185. package/src/web/components/image/index.tsx +29 -12
  186. package/src/web/components/index.js +1 -0
  187. package/src/web/components/link/index.tsx +13 -13
  188. package/src/web/components/listView/index.css +8 -8
  189. package/src/web/components/lottery/index.css +43 -37
  190. package/src/web/components/lottery/index.tsx +3 -3
  191. package/src/web/components/modal/index.tsx +34 -34
  192. package/src/web/components/navLayout/index.css +25 -25
  193. package/src/web/components/navLayout/index.tsx +1 -1
  194. package/src/web/components/navigationBar/index.css +26 -26
  195. package/src/web/components/navigationBar/index.tsx +2 -2
  196. package/src/web/components/picker/datePicker.tsx +3 -3
  197. package/src/web/components/picker/picker.tsx +3 -3
  198. package/src/web/components/picker/timePicker.tsx +1 -1
  199. package/src/web/components/richText/index.jsx +41 -46
  200. package/src/web/components/richTextView/index.css +7 -3
  201. package/src/web/components/richTextView/index.tsx +4 -6
  202. package/src/web/components/scrollView/index.tsx +2 -2
  203. package/src/web/components/slot/index.tsx +3 -4
  204. package/src/web/components/swiper/index.css +1 -1
  205. package/src/web/components/swiper/index.tsx +33 -15
  206. package/src/web/components/tabs/index.css +2 -3
  207. package/src/web/components/tabs/index.tsx +6 -6
  208. package/src/web/components/tabs/tabs.h5.tsx +17 -12
  209. package/src/web/components/tabs/tabs.pc.tsx +45 -34
  210. package/src/web/components/text/index.css +1 -1
  211. package/src/web/components/text/index.tsx +13 -14
  212. package/src/web/components/wedaVideo/index.css +42 -0
  213. package/src/web/components/wedaVideo/index.tsx +208 -0
  214. package/src/web/utils/constant.ts +2 -1
  215. package/src/web/utils/isObjectEqual.js +2 -1
  216. package/src/web/utils/loading-fallback.tsx +2 -2
  217. package/src/web/utils/lodash.ts +1 -1
  218. package/src/web/utils/platform.js +13 -0
  219. package/src/web/utils/useSetState.ts +6 -2
  220. package/src/web/weda-ui.css +23 -8
  221. package/src/docs/common/format.tsx +0 -112
  222. package/src/docs/common/tableView.css +0 -164
  223. package/src/docs/common/tableView.tsx +0 -273
  224. package/src/docs/compsdocs/chart/Bar.mdx +0 -159
  225. package/src/docs/compsdocs/chart/Line.mdx +0 -100
  226. package/src/docs/compsdocs/chart/Pie.mdx +0 -83
  227. package/src/docs/compsdocs/chart/_category_.json +0 -1
  228. package/src/docs/compsdocs/chart/statisticsCard.mdx +0 -51
  229. package/src/docs/compsdocs/database/DataView.mdx +0 -33
  230. package/src/docs/compsdocs/database/ListView.mdx +0 -33
  231. package/src/docs/compsdocs/database/_category_.json +0 -1
  232. package/src/docs/compsdocs/form/Form.mdx +0 -35
  233. package/src/docs/compsdocs/form/FormCheckbox.mdx +0 -35
  234. package/src/docs/compsdocs/form/FormDate.mdx +0 -30
  235. package/src/docs/compsdocs/form/FormEmail.mdx +0 -30
  236. package/src/docs/compsdocs/form/FormImageUploader.mdx +0 -31
  237. package/src/docs/compsdocs/form/FormInput.mdx +0 -30
  238. package/src/docs/compsdocs/form/FormLocation.mdx +0 -64
  239. package/src/docs/compsdocs/form/FormPhone.mdx +0 -30
  240. package/src/docs/compsdocs/form/FormRadio.mdx +0 -35
  241. package/src/docs/compsdocs/form/FormRegion.mdx +0 -30
  242. package/src/docs/compsdocs/form/FormSelect.mdx +0 -36
  243. package/src/docs/compsdocs/form/FormSwitch.mdx +0 -30
  244. package/src/docs/compsdocs/form/FormTextarea.mdx +0 -30
  245. package/src/docs/compsdocs/form/FormTime.mdx +0 -30
  246. package/src/docs/compsdocs/form/FormUploadFile.mdx +0 -30
  247. package/src/docs/compsdocs/form/FormUrl.mdx +0 -30
  248. package/src/docs/compsdocs/form/_category_.json +0 -1
  249. package/src/docs/compsdocs/grid/Card.mdx +0 -32
  250. package/src/docs/compsdocs/grid/Container.mdx +0 -42
  251. package/src/docs/compsdocs/grid/Footer.mdx +0 -31
  252. package/src/docs/compsdocs/grid/GridLayout.mdx +0 -32
  253. package/src/docs/compsdocs/grid/Header.mdx +0 -31
  254. package/src/docs/compsdocs/grid/Layout.mdx +0 -25
  255. package/src/docs/compsdocs/grid/List.mdx +0 -31
  256. package/src/docs/compsdocs/grid/ScrollView.mdx +0 -37
  257. package/src/docs/compsdocs/grid/Swiper.mdx +0 -58
  258. package/src/docs/compsdocs/grid/_category_.json +0 -1
  259. package/src/docs/compsdocs/media/Icon.mdx +0 -31
  260. package/src/docs/compsdocs/media/Image.mdx +0 -55
  261. package/src/docs/compsdocs/media/_category_.json +0 -1
  262. package/src/docs/compsdocs/model/ModelCreate.mdx +0 -20
  263. package/src/docs/compsdocs/model/ModelDetail.mdx +0 -20
  264. package/src/docs/compsdocs/model/ModelTable.mdx +0 -24
  265. package/src/docs/compsdocs/model/ModelUpdate.mdx +0 -21
  266. package/src/docs/compsdocs/model/PageLayout.mdx +0 -21
  267. package/src/docs/compsdocs/model/_category_.json +0 -1
  268. package/src/docs/compsdocs/navmenu/Classification.mdx +0 -38
  269. package/src/docs/compsdocs/navmenu/NavBar.mdx +0 -43
  270. package/src/docs/compsdocs/navmenu/NavLayout.mdx +0 -30
  271. package/src/docs/compsdocs/navmenu/TabBar.mdx +0 -43
  272. package/src/docs/compsdocs/navmenu/TabBarItem.mdx +0 -29
  273. package/src/docs/compsdocs/navmenu/_category_.json +0 -1
  274. package/src/docs/compsdocs/senior/Lottery.mdx +0 -48
  275. package/src/docs/compsdocs/senior/Modal.mdx +0 -58
  276. package/src/docs/compsdocs/senior/SlotMachine.mdx +0 -52
  277. package/src/docs/compsdocs/senior/_category_.json +0 -1
  278. package/src/docs/compsdocs/show/Calendar.mdx +0 -29
  279. package/src/docs/compsdocs/show/Divider.mdx +0 -31
  280. package/src/docs/compsdocs/show/GraphicCard.mdx +0 -30
  281. package/src/docs/compsdocs/show/Item.mdx +0 -32
  282. package/src/docs/compsdocs/show/ItemList.mdx +0 -47
  283. package/src/docs/compsdocs/show/Media.mdx +0 -25
  284. package/src/docs/compsdocs/show/StatusTip.mdx +0 -25
  285. package/src/docs/compsdocs/show/Swiper.mdx +0 -33
  286. package/src/docs/compsdocs/show/Tabs.mdx +0 -38
  287. package/src/docs/compsdocs/show/_category_.json +0 -1
  288. package/src/docs/compsdocs/show/button.mdx +0 -25
  289. package/src/docs/compsdocs/text/Link.mdx +0 -43
  290. package/src/docs/compsdocs/text/RichTextView.mdx +0 -36
  291. package/src/docs/compsdocs/text/Text.mdx +0 -31
  292. package/src/docs/compsdocs/text/Title.mdx +0 -32
  293. package/src/docs/compsdocs/text/_category_.json +0 -1
  294. package/src/docs/compsdocs/wxOpen/Phone.mdx +0 -60
  295. package/src/docs/compsdocs/wxOpen/Share.mdx +0 -46
  296. package/src/docs/compsdocs/wxOpen/UserInfo.mdx +0 -60
  297. package/src/docs/compsdocs/wxOpen/_category_.json +0 -4
@@ -37,13 +37,14 @@ class EchartBar extends EchartBase {
37
37
  name,
38
38
  methodName,
39
39
  type,
40
- params,
40
+ params
41
41
  );
42
42
  // 获取 x 轴数据
43
43
  const sortedXAxisData = this.sortXAxisData(arrSourData, xField.format);
44
44
  const arrXaxisData = this.setXaxis(sortedXAxisData, xField.format);
45
45
  const arrXisCountEmptyIndex = []; // 记录空值的key
46
- if (Object.keys(groupKey ?? {}).length === 0) { // 没有分组
46
+ if (Object.keys(groupKey ?? {}).length === 0) {
47
+ // 没有分组
47
48
  const numLine = arrSourData[0].YLabels.length;
48
49
  if (numLine > 0) {
49
50
  for (let j = 0; j < numLine; j++) {
@@ -58,16 +59,21 @@ class EchartBar extends EchartBase {
58
59
  stack: isPile ? 'pile' : null,
59
60
  data: [],
60
61
  };
61
- sortedXAxisData.forEach((itemSource,index) => {
62
+ sortedXAxisData.forEach((itemSource, index) => {
62
63
  this.config.series[j].name = itemSource.YLabels[j].Cn_Name;
63
- if ((!itemSource.YLabels[j].Value === undefined || itemSource.YLabels[j].Value === null) && !xIsCountEmpty) {
64
+ if (
65
+ (!itemSource.YLabels[j].Value === undefined ||
66
+ itemSource.YLabels[j].Value === null) &&
67
+ !xIsCountEmpty
68
+ ) {
64
69
  arrXisCountEmptyIndex.push(index);
65
70
  } else {
66
- const value = itemSource.YLabels[j].Value ? itemSource.YLabels[j].Value : 0;
71
+ const value = itemSource.YLabels[j].Value
72
+ ? itemSource.YLabels[j].Value
73
+ : 0;
67
74
  this.config.series[j].data.push(value);
68
75
  }
69
76
  });
70
-
71
77
  }
72
78
  }
73
79
  // 处理显示空值问题
@@ -103,23 +109,13 @@ class EchartBar extends EchartBase {
103
109
  label: {
104
110
  show: true,
105
111
  },
106
- data: this.getSeriesDataGroup(
107
- arrXaxisData,
108
- objGroupKey[groupKey],
109
- ),
112
+ data: this.getSeriesDataGroup(arrXaxisData, objGroupKey[groupKey]),
110
113
  stack: isPile ? 'pile' : null,
111
114
  };
112
115
  return serie;
113
116
  });
114
- this.config.tooltip.formatter = params => (
115
- `${params.data.dimensionality
116
- }\r\n${
117
- params.data.name
118
- }\r\n${
119
- params.seriesName
120
- }:${
121
- params.value}`
122
- );
117
+ this.config.tooltip.formatter = (params) =>
118
+ `${params.data.dimensionality}\r\n${params.data.name}\r\n${params.seriesName}:${params.value}`;
123
119
  }
124
120
  console.log('sourData处理后数据bar:', this.config.series);
125
121
  }
@@ -140,19 +136,17 @@ class EchartBar extends EchartBase {
140
136
  isUnit,
141
137
  unit,
142
138
  decimalDigits,
143
- suffix
139
+ suffix,
144
140
  }) {
145
141
  decimalDigits = Math.max(0, decimalDigits);
146
- this.config.series.length > 0
147
- && this.config.series.forEach((itemSeries) => {
142
+ this.config.series.length > 0 &&
143
+ this.config.series.forEach((itemSeries) => {
148
144
  itemSeries.showSymbol = isSeriesShowSymbol;
149
145
  itemSeries.label.show = isSeriesShowSymbol;
150
146
  if (isUnit) {
151
147
  itemSeries.label.formatter = (params) => {
152
148
  const objNewValue = this.getValueByUnit(params.value, unit);
153
- return (
154
- `${objNewValue.toFixed(decimalDigits)}${suffix}`
155
- );
149
+ return `${objNewValue.toFixed(decimalDigits)}${suffix}`;
156
150
  };
157
151
  }
158
152
  });
@@ -166,17 +160,18 @@ class EchartBar extends EchartBase {
166
160
  }
167
161
  }
168
162
  // 设置柱状图X,Y倒转
169
- setDirectionType({directionType}) {
163
+ setDirectionType({ directionType }) {
170
164
  let temAxis = {};
171
- if (directionType === 'crosswise') { // 横向
165
+ if (directionType === 'crosswise') {
166
+ // 横向
172
167
  temAxis = this.config.xAxis;
173
168
  // @ts-ignore
174
169
  this.config.xAxis = this.config.yAxis;
175
170
  // @ts-ignore
176
171
  this.config.yAxis = temAxis;
177
- this.config.yAxis.inverse = true;
178
-
179
- } else { // 纵向
172
+ this.config.yAxis.inverse = true;
173
+ } else {
174
+ // 纵向
180
175
  if (this.config.yAxis.inverse) {
181
176
  temAxis = this.config.yAxis;
182
177
  // @ts-ignore
@@ -220,7 +215,7 @@ class EchartBar extends EchartBase {
220
215
  isUnit,
221
216
  unit,
222
217
  decimalDigits,
223
- suffix
218
+ suffix,
224
219
  }) {
225
220
  if (dataSource) {
226
221
  await this.setSourceData({
@@ -241,7 +236,7 @@ class EchartBar extends EchartBase {
241
236
  this.setIsXaxisAxisLabelShow({ isXaxisAxisLabelShow });
242
237
  this.setIsXaxisName({ isXaxisName, xAxisName });
243
238
  this.setIsXaxisAxisTickShow({ isXaxisAxisTickShow });
244
- this.setIsXaxisAxisLabelRotate({ isXaxisAxisLabelRotate, xStatistics});
239
+ this.setIsXaxisAxisLabelRotate({ isXaxisAxisLabelRotate, xStatistics });
245
240
  this.setIsYAxisSplitlineLinestyleWidth({
246
241
  isYAxisSplitlineLinestyleWidth,
247
242
  yAxisSplitlineLinestyleType,
@@ -254,9 +249,9 @@ class EchartBar extends EchartBase {
254
249
  isUnit,
255
250
  unit,
256
251
  decimalDigits,
257
- suffix
252
+ suffix,
258
253
  });
259
- this.setDirectionType({directionType});
254
+ this.setDirectionType({ directionType });
260
255
  }
261
256
  }
262
257
 
@@ -1,5 +1,5 @@
1
1
  import getConfig from '../config/global';
2
- import {callWedaApi, callDataSource} from '../../../../utils/tcb';
2
+ import { callWedaApi, callDataSource } from '../../../../utils/tcb';
3
3
  /**
4
4
  * 图表处理基类
5
5
  * @author loonglong
@@ -30,28 +30,29 @@ class EchartBase {
30
30
  dimension: {},
31
31
  group: {},
32
32
  };
33
- if (filterData && filterData.length > 0) { // 协议转化,把首字母改成大写
33
+ if (filterData && filterData.length > 0) {
34
+ // 协议转化,把首字母改成大写
34
35
  objReturnData.where = filterData.map((val) => {
35
36
  let arrLogicData = val.logicData;
36
37
  if (val.logicData && val.logicData.length > 0) {
37
- arrLogicData = val.logicData.map((mval)=>{
38
+ arrLogicData = val.logicData.map((mval) => {
38
39
  return {
39
40
  Key: mval.key,
40
41
  Rel: mval.rel,
41
42
  Value: mval.value,
42
43
  Logic: mval.logic,
43
44
  Extra: {
44
- Type:mval?.extra?.type,
45
- Format:mval?.extra?.format,
46
- IsExpression:mval.extra.isExpression,
45
+ Type: mval?.extra?.type,
46
+ Format: mval?.extra?.format,
47
+ IsExpression: mval.extra.isExpression,
47
48
  },
48
- ValueType:mval.valueType,
49
- Expression:mval.expression
49
+ ValueType: mval.valueType,
50
+ Expression: mval.expression,
50
51
  };
51
52
  });
52
53
  }
53
54
  return {
54
- GroupLogic:val.groupLogic,
55
+ GroupLogic: val.groupLogic,
55
56
  LogicData: arrLogicData,
56
57
  };
57
58
  });
@@ -149,20 +150,20 @@ class EchartBase {
149
150
  break;
150
151
  }
151
152
  }
152
- setLegend({ isLegend, legend= 'top'}) {
153
+ setLegend({ isLegend, legend = 'top' }) {
153
154
  this.config.legend.show = isLegend;
154
155
  switch (legend) {
155
- case 'top' :
156
+ case 'top':
156
157
  this.config.legend.orient = 'horizontal';
157
158
  this.config.legend.x = 'center';
158
159
  this.config.legend.top = '6%';
159
160
  break;
160
- case 'left' :
161
+ case 'left':
161
162
  this.config.legend.orient = 'vertical';
162
163
  this.config.legend.top = '30%';
163
164
  this.config.legend.left = '1%';
164
165
  break;
165
- case 'right' :
166
+ case 'right':
166
167
  this.config.legend.orient = 'vertical';
167
168
  this.config.legend.top = '30%';
168
169
  this.config.legend.right = '-6%';
@@ -186,11 +187,11 @@ class EchartBase {
186
187
  sortedXAxisData.forEach((itemSource) => {
187
188
  let value = itemSource.XLabel.Value;
188
189
  if (formatType === 'datetime') {
189
- value = this.formatTime(itemSource.XLabel.Value, 'dt');
190
+ value = this.formatTime(itemSource.XLabel.Value, 'dt');
190
191
  } else if (formatType === 'date') {
191
- value = this.formatTime(itemSource.XLabel.Value, 'd');
192
+ value = this.formatTime(itemSource.XLabel.Value, 'd');
192
193
  } else if (formatType === 'time') {
193
- value = this.formatTime(itemSource.XLabel.Value, 't');
194
+ value = this.formatTime(itemSource.XLabel.Value, 't');
194
195
  }
195
196
  xAxisData.push(value);
196
197
  });
@@ -201,16 +202,19 @@ class EchartBase {
201
202
 
202
203
  sortXAxisData(arrData, formatType = '') {
203
204
  let xFields = [...arrData];
204
- if(['datetime', 'date', 'time'].includes(formatType)) {
205
+ if (['datetime', 'date', 'time'].includes(formatType)) {
205
206
  xFields.sort((a, b) => {
206
- if(a.XLabel.Value && b.XLabel.Value ) {
207
- return new Date(a.XLabel.Value).getTime() - new Date(b.XLabel.Value).getTime();
207
+ if (a.XLabel.Value && b.XLabel.Value) {
208
+ return (
209
+ new Date(a.XLabel.Value).getTime() -
210
+ new Date(b.XLabel.Value).getTime()
211
+ );
208
212
  }
209
213
  // 产品需求空值放最后
210
- if(!a.XLabel.Value) {
214
+ if (!a.XLabel.Value) {
211
215
  return 1;
212
216
  }
213
- if(!b.XLabel.Value) {
217
+ if (!b.XLabel.Value) {
214
218
  return -1;
215
219
  }
216
220
  });
@@ -224,16 +228,17 @@ class EchartBase {
224
228
  * @param { string } timeType 需要格式化的类型 dt:日期时间,d:日期,t:时间
225
229
  * @returns { string } 格式化结果
226
230
  */
227
- formatTime(time, timeType='dt') {
228
- if(typeof time === 'undefined' || time === null) {
231
+ formatTime(time, timeType = 'dt') {
232
+ if (typeof time === 'undefined' || time === null) {
229
233
  return '空';
230
234
  }
231
- if (typeof(time) === 'string') { // 如果是字符串,代表后台返回的就是格式化的时间格式,则这里不再做格式化处理
235
+ if (typeof time === 'string') {
236
+ // 如果是字符串,代表后台返回的就是格式化的时间格式,则这里不再做格式化处理
232
237
  return time;
233
238
  }
234
239
  const date = new Date(time + 8 * 3600 * 1000);
235
240
  let startNum = 0;
236
- let endNum = 19;
241
+ let endNum = 19;
237
242
  if (timeType === 'd') {
238
243
  startNum = 0;
239
244
  endNum = 10;
@@ -293,13 +298,18 @@ class EchartBase {
293
298
  }
294
299
  // 显示X轴刻度线
295
300
  setIsXaxisAxisTickShow({ isXaxisAxisTickShow }) {
296
- this.config.xAxis.axisTick = { show : isXaxisAxisTickShow };
301
+ this.config.xAxis.axisTick = { show: isXaxisAxisTickShow };
297
302
  }
298
303
  // X 轴文字倾斜
299
304
  // X 轴文字倾斜
300
- setIsXaxisAxisLabelRotate({ isXaxisAxisLabelRotate, xStatistics, angle = 30}) {
305
+ setIsXaxisAxisLabelRotate({
306
+ isXaxisAxisLabelRotate,
307
+ xStatistics,
308
+ angle = 30,
309
+ }) {
301
310
  this.config.xAxis.axisLabel.rotate = isXaxisAxisLabelRotate ? angle : 0;
302
- if (isXaxisAxisLabelRotate || xStatistics) { // 如果X轴是时间类型,自动斜30度展示
311
+ if (isXaxisAxisLabelRotate || xStatistics) {
312
+ // 如果X轴是时间类型,自动斜30度展示
303
313
  this.config.xAxis.axisLabel.rotate = angle;
304
314
  } else {
305
315
  this.config.xAxis.axisLabel.rotate = 0;
@@ -311,8 +321,10 @@ class EchartBase {
311
321
  isYAxisSplitlineLinestyleWidth,
312
322
  yAxisSplitlineLinestyleType,
313
323
  }) {
314
- this.config.yAxis.splitLine = {lineStyle:{}};
315
- this.config.yAxis.splitLine.lineStyle.width = isYAxisSplitlineLinestyleWidth ? 1 : 0;
324
+ this.config.yAxis.splitLine = { lineStyle: {} };
325
+ this.config.yAxis.splitLine.lineStyle.width = isYAxisSplitlineLinestyleWidth
326
+ ? 1
327
+ : 0;
316
328
  this.config.yAxis.splitLine.lineStyle.type = yAxisSplitlineLinestyleType;
317
329
  }
318
330
  // 显示 Y 轴刻度 最大值,最小值
@@ -336,7 +348,9 @@ class EchartBase {
336
348
  */
337
349
  setEmptyValue(xIsCountEmpty) {
338
350
  if (!xIsCountEmpty) {
339
- const nonEmpty = this.config.xAxis.data.filter(item => item !== undefined && item !== null);
351
+ const nonEmpty = this.config.xAxis.data.filter(
352
+ (item) => item !== undefined && item !== null
353
+ );
340
354
  this.config.xAxis.data = nonEmpty;
341
355
  }
342
356
  }
@@ -349,7 +363,7 @@ class EchartBase {
349
363
  removeEmpty(arrXAxis) {
350
364
  const arrNewxAxis = [];
351
365
  if (arrXAxis.length > 0) {
352
- for(let i = 0; i < arrXAxis.length; i++) {
366
+ for (let i = 0; i < arrXAxis.length; i++) {
353
367
  if (arrXAxis[i]) {
354
368
  arrNewxAxis.push(arrXAxis[i]);
355
369
  }
@@ -36,7 +36,7 @@ class EchartLine extends EchartBase {
36
36
  name,
37
37
  methodName,
38
38
  type,
39
- params,
39
+ params
40
40
  );
41
41
  // 获取 x 轴数据
42
42
  const sortedXAxisData = this.sortXAxisData(arrSourData, xField.format);
@@ -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 ((!itemSource.YLabels[j].Value === undefined || itemSource.YLabels[j].Value === null) && !xIsCountEmpty) {
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 ? itemSource.YLabels[j].Value : 0;
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
- // 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
- );
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
- && this.config.series.forEach((itemSeries) => {
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
- && this.config.series.forEach((itemSeries) => {
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
  });
@@ -188,7 +182,7 @@ class EchartLine extends EchartBase {
188
182
  isUnit,
189
183
  unit,
190
184
  decimalDigits,
191
- suffix
185
+ suffix,
192
186
  }) {
193
187
  if (dataSource) {
194
188
  await this.setSourceData({
@@ -221,7 +215,7 @@ class EchartLine extends EchartBase {
221
215
  isUnit,
222
216
  unit,
223
217
  decimalDigits,
224
- suffix
218
+ suffix,
225
219
  });
226
220
  }
227
221
  }
@@ -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
- && this.config.series.forEach((itemSeries) => {
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 {
@@ -76,7 +76,7 @@ class EchartPie extends EchartBase {
76
76
  isUnit,
77
77
  unit,
78
78
  decimalDigits,
79
- suffix
79
+ suffix,
80
80
  }) {
81
81
  decimalDigits = decimalDigits < 0 ? 0 : decimalDigits;
82
82
  let show = false;
@@ -92,10 +92,12 @@ class EchartPie extends EchartBase {
92
92
  } else {
93
93
  this.config.series[0].label.normal.formatter = (objValue) => {
94
94
  let reData = '';
95
- if (isSeriesShowSymbol) { // 显示数值
95
+ if (isSeriesShowSymbol) {
96
+ // 显示数值
96
97
  reData = objValue.value;
97
98
  }
98
- if (isUnit) { // 显示单位
99
+ if (isUnit) {
100
+ // 显示单位
99
101
  if (unit) {
100
102
  const objNewValue = this.getValueByUnit(objValue.value, unit);
101
103
  reData = `${objNewValue.toFixed(decimalDigits)}${suffix}`;
@@ -109,7 +111,8 @@ class EchartPie extends EchartBase {
109
111
  };
110
112
  });
111
113
  }
112
- if (isPercent) { // 显示百分比
114
+ if (isPercent) {
115
+ // 显示百分比
113
116
  reData = `${reData}(${objValue.percent}%)`;
114
117
  }
115
118
  return reData;
@@ -135,7 +138,7 @@ class EchartPie extends EchartBase {
135
138
  isUnit,
136
139
  unit,
137
140
  decimalDigits,
138
- suffix
141
+ suffix,
139
142
  }) {
140
143
  if (dataSource) {
141
144
  await this.setSourceData({
@@ -158,7 +161,7 @@ class EchartPie extends EchartBase {
158
161
  isUnit,
159
162
  unit,
160
163
  decimalDigits,
161
- suffix
164
+ suffix,
162
165
  });
163
166
  }
164
167
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "component": true,
3
3
  "usingComponents": {}
4
- }
4
+ }
@@ -6,8 +6,7 @@ class WxCanvas {
6
6
  this.isNew = isNew;
7
7
  if (isNew) {
8
8
  this.canvasNode = canvasNode;
9
- }
10
- else {
9
+ } else {
11
10
  this._initStyle(ctx);
12
11
  }
13
12
 
@@ -60,26 +59,31 @@ class WxCanvas {
60
59
 
61
60
  _initEvent() {
62
61
  this.event = {};
63
- const eventNames = [{
64
- wxName: 'touchStart',
65
- ecName: 'mousedown'
66
- }, {
67
- wxName: 'touchMove',
68
- ecName: 'mousemove'
69
- }, {
70
- wxName: 'touchEnd',
71
- ecName: 'mouseup'
72
- }, {
73
- wxName: 'touchEnd',
74
- ecName: 'click'
75
- }];
62
+ const eventNames = [
63
+ {
64
+ wxName: 'touchStart',
65
+ ecName: 'mousedown',
66
+ },
67
+ {
68
+ wxName: 'touchMove',
69
+ ecName: 'mousemove',
70
+ },
71
+ {
72
+ wxName: 'touchEnd',
73
+ ecName: 'mouseup',
74
+ },
75
+ {
76
+ wxName: 'touchEnd',
77
+ ecName: 'click',
78
+ },
79
+ ];
76
80
 
77
- eventNames.forEach(name => {
78
- this.event[name.wxName] = e => {
81
+ eventNames.forEach((name) => {
82
+ this.event[name.wxName] = (e) => {
79
83
  const touch = e.touches[0];
80
84
  this.chart.getZr().handler.dispatch(name.ecName, {
81
85
  zrX: name.wxName === 'tap' ? touch.clientX : touch.x,
82
- zrY: name.wxName === 'tap' ? touch.clientY : touch.y
86
+ zrY: name.wxName === 'tap' ? touch.clientY : touch.y,
83
87
  });
84
88
  };
85
89
  });
@@ -93,13 +97,11 @@ class WxCanvas {
93
97
  }
94
98
 
95
99
  get width() {
96
- if (this.canvasNode)
97
- return this.canvasNode.width;
100
+ if (this.canvasNode) return this.canvasNode.width;
98
101
  return 0;
99
102
  }
100
103
  get height() {
101
- if (this.canvasNode)
102
- return this.canvasNode.height;
104
+ if (this.canvasNode) return this.canvasNode.height;
103
105
  return 0;
104
106
  }
105
107
  }
@@ -237,11 +237,11 @@ Component({
237
237
  },
238
238
  observers: {
239
239
  // 当参数变化时
240
- '**': async function() {
240
+ '**': async function () {
241
241
  const objEChartLine = new EchartLine();
242
242
  await objEChartLine.setOptions(this.properties);
243
243
  const options = objEChartLine.getOptions();
244
244
  this._chart && this._chart.setOption(options);
245
245
  },
246
- }
246
+ },
247
247
  });
@@ -1,3 +1,3 @@
1
1
  <view wx:if="ec" class="{{className}} ec_container" style="{{style}}" id="{{id}}">
2
- <ec-canvas canvas-id="{{canvas_id}}" ec="{{ ec }}"></ec-canvas>
2
+ <ec-canvas canvas-id="{{canvas_id}}" ec="{{ ec }}"></ec-canvas>
3
3
  </view>
@@ -147,7 +147,7 @@ Component({
147
147
  },
148
148
  observers: {
149
149
  // 当参数变化时
150
- '**': async function() {
150
+ '**': async function () {
151
151
  const objEChartPie = new EchartPie();
152
152
  await objEChartPie.setOptions(this.properties);
153
153
  const options = await objEChartPie.getOptions();
@@ -1,4 +1,3 @@
1
1
  <view wx:if="ec" class="{{className}} ec_container" style="{{style}}" id="{{id}}">
2
- <ec-canvas canvas-id="{{canvas_id}}" ec="{{ ec }}"></ec-canvas>
2
+ <ec-canvas canvas-id="{{canvas_id}}" ec="{{ ec }}"></ec-canvas>
3
3
  </view>
4
-