@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,379 @@
1
+ import { callDataSource, callWedaApi } from '../../../../utils/tcb';
2
+ import getConfig from '../config/global';
3
+
4
+ export type IEchartModalBase = typeof EchartBase
5
+ export abstract class AbstractEchartBaseModal {
6
+ abstract setOptions(options: any): Promise<void>;
7
+ abstract getOptions(option: any): Promise<void>;
8
+ }
9
+
10
+ type IReturnData = {
11
+ value: {
12
+ Key: string;
13
+ OperationType: 'count' | 'sum' | 'avg' | 'max' | 'min';
14
+ }[],
15
+ where: [],
16
+ dimension: {
17
+ TimeSpan?: string;
18
+ Key?: string;
19
+ IsCountEmpty?: boolean;
20
+ },
21
+ group: {
22
+ TimeSpan?: string;
23
+ Key?: string;
24
+ },
25
+ }
26
+
27
+ /**
28
+ * 图表处理基类
29
+ * @author loonglong
30
+ **/
31
+ class EchartBase extends AbstractEchartBaseModal {
32
+ // config: ECOption;
33
+ // TODO: type
34
+ config: any;
35
+ constructor() {
36
+ super();
37
+ this.config = getConfig();
38
+ }
39
+
40
+ public async setOptions(options: any): Promise<void> {}
41
+
42
+
43
+ /** 获取所有配置好的图表数据 */
44
+ public getOptions() {
45
+ return this.config;
46
+ }
47
+
48
+ /** 生成后台查询条件 */
49
+ protected createWhere({
50
+ filterData,
51
+ xField,
52
+ xStatistics,
53
+ xIsCountEmpty,
54
+ yField,
55
+ groupKey=({} as Record<string, any>),
56
+ groupKeyTimeSpan='',
57
+ }) {
58
+ const objReturnData: IReturnData = {
59
+ value: [],
60
+ where: [],
61
+ dimension: {},
62
+ group: {},
63
+ };
64
+ if (filterData && filterData.length > 0) { // 协议转化,把首字母改成大写
65
+ objReturnData.where = filterData.map((val) => {
66
+ let arrLogicData = val.logicData;
67
+ if (val.logicData && val.logicData.length > 0) {
68
+ arrLogicData = val.logicData.map((mval)=>{
69
+ return {
70
+ Key: mval.key,
71
+ Rel: mval.rel,
72
+ Value: mval.value,
73
+ Logic: mval.logic,
74
+ Extra: {
75
+ Type:mval?.extra?.type,
76
+ Format:mval?.extra?.format,
77
+ IsExpression:mval?.extra?.isExpression,
78
+ },
79
+ ValueType:mval.valueType,
80
+ Expression:mval.expression
81
+ };
82
+ });
83
+ }
84
+ return {
85
+ GroupLogic:val.groupLogic,
86
+ LogicData: arrLogicData,
87
+ };
88
+ });
89
+ }
90
+ if (xField && xField.name) {
91
+ objReturnData.dimension = {
92
+ Key: xField.name,
93
+ };
94
+ if (xStatistics) {
95
+ objReturnData.dimension.TimeSpan = xStatistics;
96
+ } else {
97
+ objReturnData.dimension.IsCountEmpty = xIsCountEmpty;
98
+ }
99
+ }
100
+ if (yField && yField.numValue && yField.numValue.length > 0) {
101
+ yField.numValue.forEach((itemVal) => {
102
+ objReturnData.value.push({
103
+ Key: itemVal.key,
104
+ OperationType: itemVal.operationType,
105
+ });
106
+ });
107
+ }
108
+
109
+ if (yField && groupKey && groupKey.name) {
110
+ objReturnData.group.Key = groupKey.name;
111
+ objReturnData.group.TimeSpan = groupKeyTimeSpan;
112
+ }
113
+ return objReturnData;
114
+ }
115
+
116
+ /**
117
+ * 从后台获取统计数据
118
+ *
119
+ **/
120
+ protected async getSourceData(
121
+ sourceName = '',
122
+ methods = '',
123
+ dataSourceType = '',
124
+ params,
125
+ ) {
126
+ try {
127
+ if (dataSourceType === 'database') {
128
+ return await callWedaApi({
129
+ action: 'DescribeChartData',
130
+ data: {
131
+ DataSourceName: sourceName,
132
+ Value: params.value,
133
+ Where: params.where,
134
+ Dimension: params.dimension,
135
+ Group: params.group,
136
+ },
137
+ });
138
+ }
139
+ const res = await callDataSource({
140
+ dataSourceName: sourceName,
141
+ methodName: methods,
142
+ params,
143
+ });
144
+ return res.result ?? [];
145
+ } catch (err) {
146
+ return [];
147
+ }
148
+ }
149
+
150
+ protected setTitle({ isTitle, title, titleLocation = '' }) {
151
+ this.config.title;
152
+ this.config.title.show = isTitle;
153
+ this.config.title.text = title;
154
+
155
+ this.config.title.top = '-1%';
156
+ this.config.title.left = '35%';
157
+ this.config.title.right = null;
158
+ }
159
+
160
+ protected setLegend({ isLegend, legend= 'top'}) {
161
+ this.config.legend.show = isLegend;
162
+ switch (legend) {
163
+ case 'top' :
164
+ this.config.legend.orient = 'horizontal';
165
+ this.config.legend.x = 'center';
166
+ this.config.legend.top = '6%';
167
+ break;
168
+ case 'left' :
169
+ this.config.legend.orient = 'vertical';
170
+ this.config.legend.top = '30%';
171
+ this.config.legend.left = '1%';
172
+ break;
173
+ case 'right' :
174
+ this.config.legend.orient = 'vertical';
175
+ this.config.legend.top = '30%';
176
+ this.config.legend.right = '6%';
177
+ break;
178
+ default:
179
+ this.config.legend.top = '89%';
180
+ this.config.legend.orient = 'horizontal';
181
+ this.config.legend.x = 'center';
182
+ break;
183
+ }
184
+ }
185
+
186
+ /**
187
+ * 设置 X轴数据
188
+ * @param { Array<object> } arrData 后台返回的数据
189
+ * @param { string } formatType 类型 datetime:日期时间;date:日期,time:时间,其它
190
+ */
191
+ protected setXaxis(arrData, formatType = '') {
192
+ const xAxisData = [];
193
+ let xFields = [...arrData];
194
+ if(['datetime', 'date', 'time'].includes(formatType)) {
195
+ xFields.sort((a, b) => {
196
+ if(a.XLabel.Value && b.XLabel.Value ) {
197
+ return new Date(a.XLabel.Value).getTime() - new Date(b.XLabel.Value).getTime();
198
+ }
199
+ // 产品需求空值放最后
200
+ if(!a.XLabel.Value) {
201
+ return 1;
202
+ }
203
+ if(!b.XLabel.Value) {
204
+ return -1;
205
+ }
206
+ });
207
+ }
208
+ if (arrData.length > 0) {
209
+ xFields.forEach((itemSource) => {
210
+ let value = itemSource.XLabel.Value;
211
+ if (formatType === 'datetime') {
212
+ value = this.formatTime(itemSource.XLabel.Value, 'dt');
213
+ } else if (formatType === 'date') {
214
+ value = this.formatTime(itemSource.XLabel.Value, 'd');
215
+ } else if (formatType === 'time') {
216
+ value = this.formatTime(itemSource.XLabel.Value, 't');
217
+ }
218
+ xAxisData.push(value);
219
+ });
220
+ this.config.xAxis.data = xAxisData;
221
+ }
222
+ return xAxisData;
223
+ }
224
+
225
+ /**
226
+ * 时间轴格式化为日期,时间,日期时间
227
+ * @param { number } time 时间戳
228
+ * @param { string } timeType 需要格式化的类型 dt:日期时间,d:日期,t:时间
229
+ * @returns { string } 格式化结果
230
+ */
231
+ private formatTime(time, timeType='dt') {
232
+ if(typeof time === 'undefined' || time === null) {
233
+ return '空';
234
+ }
235
+ if (typeof(time) === 'string') { // 如果是字符串,代表后台返回的就是格式化的时间格式,则这里不再做格式化处理
236
+ return time;
237
+ }
238
+ const date = new Date(time + 8 * 3600 * 1000);
239
+ let startNum = 0;
240
+ let endNum = 19;
241
+ if (timeType === 'd') {
242
+ startNum = 0;
243
+ endNum = 10;
244
+ } else if (timeType === 't') {
245
+ startNum = 11;
246
+ endNum = 5;
247
+ }
248
+ return date.toISOString().substr(startNum, endNum).replace('T', ' ');
249
+ }
250
+
251
+ /**
252
+ * 当有分组字段时,该方法用于获取图表 series 里的 data值,自动补全没有的数据
253
+ * @param { array } arrXaxisData - 维度名 eg:['张三','李四','王二']
254
+ * @param { array } arrGroupValue - 所属当前分组的数据 eg:[{value:'统计值',name:'统计名',dimensionality:'维度名'}]
255
+ * @returns 返回补全的数组
256
+ **/
257
+ protected getSeriesDataGroup(arrXaxisData, arrGroupValue) {
258
+ const xNums = arrXaxisData.length;
259
+ const arrRe = [];
260
+ for (let i = 0; i < xNums; i++) {
261
+ const objIsInArray = this.isInArray(arrXaxisData[i], arrGroupValue);
262
+ if (Object.keys(objIsInArray).length > 0) {
263
+ arrRe.push({
264
+ value: objIsInArray.value,
265
+ name: objIsInArray.name,
266
+ dimensionality: arrXaxisData[i],
267
+ });
268
+ } else {
269
+ arrRe.push({
270
+ value: null,
271
+ });
272
+ }
273
+ }
274
+ return arrRe;
275
+ }
276
+
277
+ // 判断当前的维度名是否在该数组里
278
+ // TODO: any
279
+ private isInArray(strDimensionality, arrGroupValue): any {
280
+ let mixStatus = {};
281
+ if (arrGroupValue.length > 0) {
282
+ arrGroupValue.forEach((itemGroupValue) => {
283
+ if (strDimensionality === itemGroupValue.dimensionality) {
284
+ mixStatus = itemGroupValue;
285
+ }
286
+ });
287
+ }
288
+ return mixStatus;
289
+ }
290
+
291
+ // 显示 X 轴标签名
292
+ protected setIsXaxisAxisLabelShow({ isXaxisAxisLabelShow }) {
293
+ this.config.xAxis.axisLabel.show = isXaxisAxisLabelShow;
294
+ }
295
+ // 显示 X 轴名
296
+ protected setIsXaxisName({ isXaxisName, xAxisName }) {
297
+ this.config.xAxis.name = isXaxisName ? xAxisName : '';
298
+ }
299
+ // 显示X轴刻度线
300
+ protected setIsXaxisAxisTickShow({ isXaxisAxisTickShow }) {
301
+ this.config.xAxis.axisTick = {show:isXaxisAxisTickShow};
302
+ }
303
+ // X 轴文字倾斜
304
+ protected setIsXaxisAxisLabelRotate({ isXaxisAxisLabelRotate, xStatistics, angle = 30}) {
305
+ this.config.xAxis.axisLabel.rotate = isXaxisAxisLabelRotate ? angle : 0;
306
+ if (isXaxisAxisLabelRotate || xStatistics) { // 如果X轴是时间类型,自动斜30度展示
307
+ this.config.xAxis.axisLabel.rotate = angle;
308
+ } else {
309
+ this.config.xAxis.axisLabel.rotate = 0;
310
+ }
311
+ }
312
+
313
+ // 显示网格线 及 线条类型
314
+ protected setIsYAxisSplitlineLinestyleWidth({
315
+ isYAxisSplitlineLinestyleWidth,
316
+ yAxisSplitlineLinestyleType,
317
+ }) {
318
+ this.config.yAxis.splitLine = {lineStyle:{}};
319
+ this.config.yAxis.splitLine.lineStyle.width = isYAxisSplitlineLinestyleWidth ? 1 : 0;
320
+ this.config.yAxis.splitLine.lineStyle.type = yAxisSplitlineLinestyleType;
321
+ }
322
+ // 显示 Y 轴刻度 最大值,最小值
323
+ protected setYAxisMaxMin({ yAxisMax, yAxisMin }) {
324
+ this.config.yAxis.min = yAxisMin ? yAxisMin : null;
325
+ this.config.yAxis.max = yAxisMax ? yAxisMax : null;
326
+ }
327
+ // 显示 Y 轴名称
328
+ protected setIsYAxisName({ isYAxisName, yAxisName }) {
329
+ this.config.yAxis.name = isYAxisName ? yAxisName : '';
330
+ }
331
+ // 显示 Y 轴刻度线
332
+ protected setIsYAxisShow({ isYAxisShow }) {
333
+ this.config.yAxis.show = isYAxisShow;
334
+ }
335
+
336
+ /**
337
+ * 当为空值时,重写xAxis, 只处理单Y轴情况
338
+ * @param { array } arrXisCountEmptyIndex Y轴空值key记录
339
+ * @param { boolean } xIsCountEmpty 是否统计空值
340
+ */
341
+ protected setEmptyValue(xIsCountEmpty) {
342
+ if (!xIsCountEmpty) {
343
+ const nonEmpty = this.config.xAxis.data.filter(item => item !== undefined && item !== null);
344
+ this.config.xAxis.data = nonEmpty;
345
+ }
346
+ }
347
+
348
+ /**
349
+ * 删除数组里面不存在的键值
350
+ * @param { array } arrXAxis 需要处理的数组
351
+ * @returns { array } 返回处理后的数组
352
+ **/
353
+ private removeEmpty(arrXAxis) {
354
+ const arrNewxAxis = [];
355
+ if (arrXAxis.length > 0) {
356
+ for(let i = 0; i < arrXAxis.length; i++) {
357
+ if (arrXAxis[i]) {
358
+ arrNewxAxis.push(arrXAxis[i]);
359
+ }
360
+ }
361
+ return arrNewxAxis;
362
+ } else {
363
+ return arrXAxis;
364
+ }
365
+ }
366
+
367
+ /**
368
+ * 根据值 value,返回指定单位的数
369
+ * @param {number} value 原始值
370
+ * @param {string} unit 单位,'%'百分比,'‰'千分比, K千,W万,BW 百万,Y 亿,B 十亿
371
+ * @returns {object} 返回对象 {value:新值,postfix:'单位'}
372
+ **/
373
+ protected getValueByUnit(value, unit) {
374
+ value = Number(value);
375
+ return value / unit;
376
+ }
377
+ }
378
+
379
+ export default EchartBase;
@@ -0,0 +1,229 @@
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
+ const arrXaxisData = this.setXaxis(arrSourData, xField.format);
42
+ const arrXisCountEmptyIndex = []; // 记录空值的key
43
+ if (!groupKey) {
44
+ const numLine = arrSourData[0].YLabels.length;
45
+ if (numLine > 0) {
46
+ for (let j = 0; j < numLine; j++) {
47
+ this.config.series[j] = {
48
+ type: 'line',
49
+ smooth: true,
50
+ name: '',
51
+ connectNulls: true,
52
+ showSymbol: true,
53
+ label: {
54
+ show: true,
55
+ },
56
+ data: [],
57
+ };
58
+ arrSourData.forEach((itemSource,index) => {
59
+ this.config.series[j].name = itemSource.YLabels[j].Cn_Name;
60
+ if ((!itemSource.YLabels[j].Value || itemSource.YLabels[j].Value === 0 || itemSource.YLabels[j].Value === null) && !xIsCountEmpty) {
61
+ arrXisCountEmptyIndex.push(index);
62
+ } else {
63
+ const value = itemSource.YLabels[j].Value ? itemSource.YLabels[j].Value : 0;
64
+ this.config.series[j].data.push(value);
65
+ }
66
+ });
67
+ }
68
+ }
69
+ // 处理显示空值问题
70
+ this.setEmptyValue(xIsCountEmpty);
71
+ } else if (groupKey) {
72
+ // 如果是分组,则这里需要特殊处理
73
+ // 按groupKey分组存放数据值
74
+ const objGroupKey = {}; // {'分组字段':[{value:'统计的值', dimensionality:'维度名', name:'统计的数值字段名'}]}
75
+ arrSourData.forEach((itemSourData) => {
76
+ itemSourData.YLabels.forEach((yLabel) => {
77
+ if (!objGroupKey[yLabel.Group_Name]) {
78
+ objGroupKey[yLabel.Group_Name] = [];
79
+ }
80
+ objGroupKey[yLabel.Group_Name].push({
81
+ value: yLabel.Value,
82
+ dimensionality: itemSourData.XLabel.Value,
83
+ name: yLabel.Cn_Name,
84
+ });
85
+ });
86
+ });
87
+
88
+ // 组装图表需要的数据
89
+ const groupNames = Object.keys(objGroupKey);
90
+ this.config.series = groupNames.map((groupKey) => {
91
+ // groupKey分组字段中文名
92
+ const serie = {
93
+ name: groupKey,
94
+ connectNulls: true,
95
+ data: this.getSeriesDataGroup(
96
+ arrXaxisData,
97
+ objGroupKey[groupKey],
98
+ ),
99
+ type: 'line',
100
+ smooth: true,
101
+ showSymbol: true, // 是否显示线条上数据标签
102
+ label: {
103
+ show: true, // 显示线条上的数据
104
+ },
105
+ };
106
+ return serie;
107
+ });
108
+ this.config.tooltip.formatter = params => (
109
+ `${params.data.dimensionality
110
+ }\r\n${
111
+ params.data.name
112
+ }\r\n${
113
+ params.seriesName
114
+ }:${
115
+ params.value}`
116
+ );
117
+ }
118
+ }
119
+ }
120
+ setChartType({ chartType }) {
121
+ this.config.series.length > 0
122
+ && this.config.series.forEach((itemSeries) => {
123
+ itemSeries.smooth = chartType !== 'line';
124
+ });
125
+ }
126
+
127
+ // 显示图表上的数据标签 单位,标签,小数位数,后缀
128
+ setIsSeriesShowSymbol({
129
+ isSeriesShowSymbol,
130
+ isUnit,
131
+ unit,
132
+ decimalDigits,
133
+ suffix
134
+ }) {
135
+ decimalDigits = decimalDigits < 0 ? 0 : decimalDigits;
136
+ this.config.series.length > 0
137
+ && this.config.series.forEach((itemSeries) => {
138
+ itemSeries.showSymbol = isSeriesShowSymbol;
139
+ itemSeries.label.show = isSeriesShowSymbol;
140
+ if (isUnit) {
141
+ itemSeries.label.formatter = (params) => {
142
+ const objNewValue = this.getValueByUnit(params.value, unit);
143
+ return (
144
+ `${objNewValue.toFixed(decimalDigits)}${suffix}`
145
+ );
146
+ };
147
+ }
148
+ });
149
+ if (isUnit) {
150
+ this.config.yAxis.axisLabel.formatter = (value) => {
151
+ const objNewValue = this.getValueByUnit(value, unit);
152
+ return `${objNewValue.toFixed(decimalDigits)}${suffix}`;
153
+ };
154
+ } else {
155
+ this.config.yAxis.axisLabel.formatter = null;
156
+ }
157
+ }
158
+ async setOptions({
159
+ chartType,
160
+ isTitle,
161
+ title,
162
+ titleLocation,
163
+ dataSource,
164
+ filterData,
165
+ xField,
166
+ xStatistics,
167
+ groupKey,
168
+ groupKeyTimeSpan,
169
+ xIsCountEmpty,
170
+ yField,
171
+ isLegend,
172
+ legend,
173
+ legend2,
174
+ isXaxisName,
175
+ xAxisName,
176
+ isXaxisAxisLabelShow,
177
+ isXaxisAxisTickShow,
178
+ isXaxisAxisLabelRotate,
179
+ isYAxisSplitlineLinestyleWidth,
180
+ yAxisSplitlineLinestyleType,
181
+ yAxisMax,
182
+ yAxisMin,
183
+ isYAxisName,
184
+ yAxisName,
185
+ isSeriesShowSymbol,
186
+ isYAxisShow,
187
+ isUnit,
188
+ unit,
189
+ decimalDigits,
190
+ suffix
191
+ }) {
192
+ if (dataSource) {
193
+ await this.setSourceData({
194
+ dataSource,
195
+ filterData,
196
+ xField,
197
+ xStatistics,
198
+ xIsCountEmpty,
199
+ yField,
200
+ groupKey,
201
+ groupKeyTimeSpan,
202
+ });
203
+ }
204
+ legend = document.body.clientWidth < 1024 ? legend : legend2;
205
+ this.setChartType({ chartType });
206
+ this.setTitle({ isTitle, title, titleLocation });
207
+ this.setLegend({ isLegend, legend });
208
+ this.setIsXaxisAxisLabelShow({ isXaxisAxisLabelShow });
209
+ this.setIsXaxisName({ isXaxisName, xAxisName });
210
+ this.setIsXaxisAxisTickShow({ isXaxisAxisTickShow });
211
+ this.setIsXaxisAxisLabelRotate({ isXaxisAxisLabelRotate, xStatistics });
212
+ this.setIsYAxisSplitlineLinestyleWidth({
213
+ isYAxisSplitlineLinestyleWidth,
214
+ yAxisSplitlineLinestyleType,
215
+ });
216
+ this.setYAxisMaxMin({ yAxisMax, yAxisMin });
217
+ this.setIsYAxisName({ isYAxisName, yAxisName });
218
+ this.setIsYAxisShow({ isYAxisShow });
219
+ this.setIsSeriesShowSymbol({
220
+ isSeriesShowSymbol,
221
+ isUnit,
222
+ unit,
223
+ decimalDigits,
224
+ suffix
225
+ });
226
+ }
227
+ }
228
+
229
+ export default EchartLine;