@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.
- package/README.md +39 -170
- package/package.json +17 -10
- package/src/configs/components/chart/bar.json +711 -0
- package/src/configs/components/chart/line.json +666 -0
- package/src/configs/components/chart/pie.json +487 -0
- package/src/configs/components/listView.json +2 -1
- package/src/configs/index.js +7 -0
- package/src/mp/components/chart/bar/index.js +254 -0
- package/src/mp/components/chart/bar/index.json +6 -0
- package/src/mp/components/chart/bar/index.wxml +3 -0
- package/src/mp/components/chart/bar/index.wxss +9 -0
- package/src/mp/components/chart/common/config/bar.js +50 -0
- package/src/mp/components/chart/common/config/global.js +16 -0
- package/src/mp/components/chart/common/config/line.js +48 -0
- package/src/mp/components/chart/common/config/pie.js +36 -0
- package/src/mp/components/chart/common/core/eChartBar.js +262 -0
- package/src/mp/components/chart/common/core/eChartBase.js +371 -0
- package/src/mp/components/chart/common/core/eChartLine.js +228 -0
- package/src/mp/components/chart/common/core/eChartPie.js +166 -0
- package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
- package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
- package/src/mp/components/chart/line/index.js +243 -0
- package/src/mp/components/chart/line/index.json +6 -0
- package/src/mp/components/chart/line/index.wxml +3 -0
- package/src/mp/components/chart/line/index.wxss +9 -0
- package/src/mp/components/chart/pie/index.js +178 -0
- package/src/mp/components/chart/pie/index.json +6 -0
- package/src/mp/components/chart/pie/index.wxml +4 -0
- package/src/mp/components/chart/pie/index.wxss +9 -0
- package/src/mp/components/dataView/index.json +1 -1
- package/src/mp/components/form/radio/index.js +5 -0
- package/src/mp/components/form/select/index.wxml +4 -4
- package/src/mp/components/form/textarea/index.wxml +6 -5
- package/src/mp/components/form/uploader/index.js +42 -22
- package/src/mp/components/form/uploader/index.wxml +15 -3
- package/src/mp/components/form/uploaderFile/index.js +58 -30
- package/src/mp/components/graphicCard/index.js +26 -28
- package/src/mp/components/internals/listView/arrow-right-line.svg +3 -0
- package/src/mp/components/internals/listView/index.js +286 -0
- package/src/mp/components/internals/listView/index.json +4 -0
- package/src/mp/components/internals/listView/index.wxml +40 -0
- package/src/mp/components/internals/listView/index.wxss +150 -0
- package/src/mp/components/internals/listView/more-line.svg +3 -0
- package/src/mp/components/listView/index.js +17 -24
- package/src/mp/components/listView/index.wxml +1 -1
- package/src/mp/components/navLayout/index.js +3 -3
- package/src/mp/index.json +3 -0
- package/src/mp/utils/platform.js +15 -0
- package/src/setupTests.js +2 -1
- package/src/web/components/chart/bar/index.tsx +139 -0
- package/src/web/components/chart/common/config/bar.js +49 -0
- package/src/web/components/chart/common/config/global.js +16 -0
- package/src/web/components/chart/common/config/line.js +50 -0
- package/src/web/components/chart/common/config/pie.js +37 -0
- package/src/web/components/chart/common/core/eChartBar.js +264 -0
- package/src/web/components/chart/common/core/eChartBase.ts +379 -0
- package/src/web/components/chart/common/core/eChartLine.js +229 -0
- package/src/web/components/chart/common/core/eChartPie.js +170 -0
- package/src/web/components/chart/common/core/type.ts +34 -0
- package/src/web/components/chart/common/echart.css +106 -0
- package/src/web/components/chart/common/echarts.ts +33 -0
- package/src/web/components/chart/common/useChart.tsx +69 -0
- package/src/web/components/chart/line/index.tsx +135 -0
- package/src/web/components/chart/pie/index.tsx +99 -0
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +3 -3
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +2 -2
- package/src/web/components/form/select/h5.tsx +3 -1
- package/src/web/components/form/select/time.jsx +1 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +19 -17
- package/src/web/components/form/uploader/uploader.pc.tsx +13 -16
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +35 -37
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +15 -21
- package/src/web/components/graphicCard/index.css +1 -5
- package/src/web/components/graphicCard/index.tsx +4 -3
- package/src/web/components/index.js +5 -2
- package/src/web/utils/platform.js +1 -1
- package/src/web/utils/tcb.js +3 -15
- package/CHANGELOG.md +0 -240
- package/src/.DS_Store +0 -0
- package/src/configs/.DS_Store +0 -0
- package/src/mp/.gitignore +0 -10
- 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;
|