@cloudbase/weda-ui 0.2.16 → 0.2.17

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 (86) hide show
  1. package/README.md +39 -170
  2. package/package.json +17 -10
  3. package/src/configs/components/chart/bar.json +711 -0
  4. package/src/configs/components/chart/line.json +666 -0
  5. package/src/configs/components/chart/pie.json +487 -0
  6. package/src/configs/components/listView.json +2 -1
  7. package/src/configs/index.js +7 -0
  8. package/src/mp/components/chart/bar/index.js +254 -0
  9. package/src/mp/components/chart/bar/index.json +6 -0
  10. package/src/mp/components/chart/bar/index.wxml +3 -0
  11. package/src/mp/components/chart/bar/index.wxss +9 -0
  12. package/src/mp/components/chart/common/config/bar.js +50 -0
  13. package/src/mp/components/chart/common/config/global.js +16 -0
  14. package/src/mp/components/chart/common/config/line.js +48 -0
  15. package/src/mp/components/chart/common/config/pie.js +36 -0
  16. package/src/mp/components/chart/common/core/eChartBar.js +262 -0
  17. package/src/mp/components/chart/common/core/eChartBase.js +371 -0
  18. package/src/mp/components/chart/common/core/eChartLine.js +228 -0
  19. package/src/mp/components/chart/common/core/eChartPie.js +166 -0
  20. package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
  21. package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
  22. package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
  23. package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
  24. package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
  25. package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
  26. package/src/mp/components/chart/line/index.js +243 -0
  27. package/src/mp/components/chart/line/index.json +6 -0
  28. package/src/mp/components/chart/line/index.wxml +3 -0
  29. package/src/mp/components/chart/line/index.wxss +9 -0
  30. package/src/mp/components/chart/pie/index.js +178 -0
  31. package/src/mp/components/chart/pie/index.json +6 -0
  32. package/src/mp/components/chart/pie/index.wxml +4 -0
  33. package/src/mp/components/chart/pie/index.wxss +9 -0
  34. package/src/mp/components/dataView/index.json +1 -1
  35. package/src/mp/components/form/radio/index.js +5 -0
  36. package/src/mp/components/form/select/index.wxml +4 -4
  37. package/src/mp/components/form/textarea/index.wxml +6 -5
  38. package/src/mp/components/form/uploader/index.js +42 -22
  39. package/src/mp/components/form/uploader/index.wxml +15 -3
  40. package/src/mp/components/form/uploaderFile/index.js +58 -30
  41. package/src/mp/components/graphicCard/index.js +26 -28
  42. package/src/mp/components/internals/listView/arrow-right-line.svg +3 -0
  43. package/src/mp/components/internals/listView/index.js +286 -0
  44. package/src/mp/components/internals/listView/index.json +4 -0
  45. package/src/mp/components/internals/listView/index.wxml +40 -0
  46. package/src/mp/components/internals/listView/index.wxss +150 -0
  47. package/src/mp/components/internals/listView/more-line.svg +3 -0
  48. package/src/mp/components/listView/index.js +17 -24
  49. package/src/mp/components/listView/index.wxml +1 -1
  50. package/src/mp/components/navLayout/index.js +3 -3
  51. package/src/mp/index.json +3 -0
  52. package/src/mp/utils/platform.js +15 -0
  53. package/src/setupTests.js +2 -1
  54. package/src/web/components/chart/bar/index.tsx +139 -0
  55. package/src/web/components/chart/common/config/bar.js +49 -0
  56. package/src/web/components/chart/common/config/global.js +16 -0
  57. package/src/web/components/chart/common/config/line.js +50 -0
  58. package/src/web/components/chart/common/config/pie.js +37 -0
  59. package/src/web/components/chart/common/core/eChartBar.js +264 -0
  60. package/src/web/components/chart/common/core/eChartBase.ts +379 -0
  61. package/src/web/components/chart/common/core/eChartLine.js +229 -0
  62. package/src/web/components/chart/common/core/eChartPie.js +170 -0
  63. package/src/web/components/chart/common/core/type.ts +34 -0
  64. package/src/web/components/chart/common/echart.css +106 -0
  65. package/src/web/components/chart/common/echarts.ts +33 -0
  66. package/src/web/components/chart/common/useChart.tsx +69 -0
  67. package/src/web/components/chart/line/index.tsx +135 -0
  68. package/src/web/components/chart/pie/index.tsx +99 -0
  69. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +3 -3
  70. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +2 -2
  71. package/src/web/components/form/select/h5.tsx +3 -1
  72. package/src/web/components/form/select/time.jsx +1 -0
  73. package/src/web/components/form/uploader/uploader.h5.tsx +19 -17
  74. package/src/web/components/form/uploader/uploader.pc.tsx +13 -16
  75. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +35 -37
  76. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +15 -21
  77. package/src/web/components/graphicCard/index.css +1 -5
  78. package/src/web/components/graphicCard/index.tsx +4 -3
  79. package/src/web/components/index.js +5 -2
  80. package/src/web/utils/platform.js +1 -1
  81. package/src/web/utils/tcb.js +3 -15
  82. package/CHANGELOG.md +0 -240
  83. package/src/.DS_Store +0 -0
  84. package/src/configs/.DS_Store +0 -0
  85. package/src/mp/.gitignore +0 -10
  86. package/src/web/.DS_Store +0 -0
@@ -0,0 +1,166 @@
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
+ itemSeries.radius = ['40%', '70%'];
68
+ }
69
+ });
70
+ }
71
+
72
+ // 显示图表上的数据标签 单位,标签,小数位数,后缀
73
+ setIsSeriesShowSymbol({
74
+ isSeriesShowSymbol,
75
+ isPercent,
76
+ isUnit,
77
+ unit,
78
+ decimalDigits,
79
+ suffix
80
+ }) {
81
+ decimalDigits = decimalDigits < 0 ? 0 : decimalDigits;
82
+ let show = false;
83
+ let position = 'inner';
84
+ let formatter = null;
85
+ if (isSeriesShowSymbol || isPercent || isUnit) {
86
+ formatter = '';
87
+ }
88
+ this.config.series[0].label.show = show;
89
+ this.config.series[0].label.position = position;
90
+ if (formatter === null) {
91
+ this.config.series[0].label.normal = null;
92
+ } else {
93
+ this.config.series[0].label.normal.formatter = (objValue) => {
94
+ let reData = '';
95
+ if (isSeriesShowSymbol) { // 显示数值
96
+ reData = objValue.value;
97
+ }
98
+ if (isUnit) { // 显示单位
99
+ if (unit) {
100
+ const objNewValue = this.getValueByUnit(objValue.value, unit);
101
+ reData = `${objNewValue.toFixed(decimalDigits)}${suffix}`;
102
+ } else {
103
+ reData = `${objValue.value.toFixed(decimalDigits)}`;
104
+ }
105
+ this.config.series[0].data.forEach((itemData) => {
106
+ itemData.tooltip.formatter = (objVal) => {
107
+ const objItemData = this.getValueByUnit(objVal.value, unit);
108
+ return `${objItemData.toFixed(decimalDigits)}${suffix}`;
109
+ };
110
+ });
111
+ }
112
+ if (isPercent) { // 显示百分比
113
+ reData = `${reData}(${objValue.percent}%)`;
114
+ }
115
+ return reData;
116
+ };
117
+ }
118
+ }
119
+ async setOptions({
120
+ chartType,
121
+ isTitle,
122
+ title,
123
+ titleLocation,
124
+ dataSource,
125
+ filterData,
126
+ setColor,
127
+ xField,
128
+ xStatistics,
129
+ xIsCountEmpty,
130
+ yField,
131
+ isLegend,
132
+ legend,
133
+ isSeriesShowSymbol,
134
+ isPercent,
135
+ isUnit,
136
+ unit,
137
+ decimalDigits,
138
+ suffix
139
+ }) {
140
+ if (dataSource) {
141
+ await this.setSourceData({
142
+ dataSource,
143
+ filterData,
144
+ setColor,
145
+ xField,
146
+ xStatistics,
147
+ xIsCountEmpty,
148
+ yField,
149
+ });
150
+ }
151
+
152
+ this.setChartType({ chartType });
153
+ this.setTitle({ isTitle, title, titleLocation });
154
+ this.setLegend({ isLegend, legend });
155
+ this.setIsSeriesShowSymbol({
156
+ isSeriesShowSymbol,
157
+ isPercent,
158
+ isUnit,
159
+ unit,
160
+ decimalDigits,
161
+ suffix
162
+ });
163
+ }
164
+ }
165
+
166
+ export default EchartPie;