@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,254 @@
1
+ import * as echarts from '../common/lib/echarts.min';
2
+ import EchartBar from '../common/core/eChartBar';
3
+ Component({
4
+ options: {
5
+ virtualHost: true,
6
+ multipleSlots: true,
7
+ },
8
+ properties: {
9
+ id: {
10
+ type: String,
11
+ value: '',
12
+ },
13
+ className: {
14
+ type: String,
15
+ value: '',
16
+ },
17
+ style: {
18
+ type: String,
19
+ value: '',
20
+ },
21
+ directionType: {
22
+ // 柱状图方向
23
+ type: String,
24
+ value: 'lengthways',
25
+ },
26
+ isPile: {
27
+ // 柱状图方向
28
+ type: Boolean,
29
+ value: false,
30
+ },
31
+ title: {
32
+ // 图表标题
33
+ type: String,
34
+ },
35
+ isTitle: {
36
+ // 是否显示标题
37
+ type: Boolean,
38
+ value: false,
39
+ },
40
+ titleLocation: {
41
+ type: String,
42
+ value: 'top',
43
+ },
44
+ dataSource: {
45
+ // 数据源
46
+ type: Object,
47
+ },
48
+ filterData: {
49
+ // 数据筛选
50
+ type: Array,
51
+ value: [],
52
+ },
53
+ setColor: {
54
+ // 设置颜色
55
+ type: Array,
56
+ value: [],
57
+ },
58
+ xField: {
59
+ // x轴字段选择
60
+ type: Object,
61
+ value: {
62
+ format: '',
63
+ type: '', // 数据源字段 类型
64
+ title: '', // 字段名中文
65
+ name: '', // 字段名英文
66
+ },
67
+ },
68
+ xStatistics: {
69
+ // x轴统计维度
70
+ type: String,
71
+ value: '', // 统计纬度, 只有选择时间类型才有,y 年,m月,d 日,w周,h时,min 分,s秒
72
+ },
73
+ groupKey: {
74
+ // x轴字段选择
75
+ type: Object,
76
+ value: {
77
+ format: '',
78
+ type: '', // 数据源字段 类型
79
+ title: '', // 字段名中文
80
+ name: '', // 字段名英文
81
+ },
82
+ },
83
+ groupKeyTimeSpan: {
84
+ // x轴统计维度
85
+ type: String,
86
+ value: '', // 统计纬度, 只有选择时间类型才有,y 年,m月,d 日,w周,h时,min 分,s秒
87
+ },
88
+ xIsCountEmpty: {
89
+ // x轴 是否统计空值
90
+ type: Boolean,
91
+ value: false,
92
+ },
93
+ yField: {
94
+ // Y轴字段,分组字段,是否分组
95
+ type: Object,
96
+ value: {
97
+ numValue: [{ key: '', operationType: '' }],
98
+ groupKey: '',
99
+ },
100
+ },
101
+ isLegend: {
102
+ // 是否显示图例
103
+ type: Boolean,
104
+ value: false,
105
+ },
106
+ legend: {
107
+ // 图例
108
+ type: String,
109
+ value: 'bottom', // 上top,下 bottom
110
+ },
111
+
112
+ // 高级属性
113
+ isXaxisName: {
114
+ // 是否显示坐标轴名称
115
+ type: Boolean,
116
+ value: true,
117
+ },
118
+ xAxisName: {
119
+ // 是否显示坐标轴名称
120
+ type: String,
121
+ value: '',
122
+ },
123
+ isXaxisAxisLabelShow: {
124
+ // 是否显示标签
125
+ type: Boolean,
126
+ value: true,
127
+ },
128
+ isXaxisAxisTickShow: {
129
+ // 显示X轴刻度线
130
+ type: Boolean,
131
+ value: true,
132
+ },
133
+ isXaxisAxisLabelRotate: {
134
+ // 文字自动倾斜
135
+ type: Boolean,
136
+ value: false,
137
+ },
138
+ isYAxisShow: {
139
+ // 是否显示 Y 轴刻度线
140
+ type: Boolean,
141
+ value: true,
142
+ },
143
+ isYAxisName: {
144
+ // 是否显示 Y坐标轴名称
145
+ type: Boolean,
146
+ value: true,
147
+ },
148
+ isYAxisSplitlineLinestyleWidth: {
149
+ // 是否显示网格线 ,yAxis.splitLine.lineStyle.width设置为0
150
+ type: Boolean,
151
+ value: true,
152
+ },
153
+ yAxisSplitlineLinestyleType: {
154
+ // 网格线线条类型 solid,dashed,dotted
155
+ type: String,
156
+ value: 'dashed',
157
+ },
158
+ yAxisName: {
159
+ // Y坐标轴名称 显示名称后需要设置居中,轴线距离属性 yAxis.nameLocation='middle' yAxis.nameGap =20
160
+ type: String,
161
+ value: '',
162
+ },
163
+ yAxisMin: {
164
+ // Y轴刻度最小值
165
+ type: Number,
166
+ value: 0,
167
+ },
168
+ yAxisMax: {
169
+ // Y轴刻度最大值, 切记如果为0时,则不设置
170
+ type: Number,
171
+ value: 0,
172
+ },
173
+ isSeriesShowSymbol: {
174
+ // 是否显示数据标签 开启后 属性 series.label.show 要同时设置为true
175
+ type: Boolean,
176
+ value: true,
177
+ },
178
+ isUnit: {
179
+ // 显示单位
180
+ type: Boolean,
181
+ value: false,
182
+ },
183
+ unit: {
184
+ // 数字显示的单位 百分比,千分比,千,万,百万,亿,十亿
185
+ type: String,
186
+ value: '%',
187
+ },
188
+ decimalDigits: {
189
+ // 小数位数
190
+ type: Number,
191
+ value: 0,
192
+ },
193
+ suffix: {
194
+ // 后缀
195
+ type: String,
196
+ value: '',
197
+ },
198
+
199
+ },
200
+ data: {
201
+ ec: {},
202
+ canvas_id: {
203
+ type: String,
204
+ value: `canvas_bar_${Date.now()}_${Math.random() * 100}`,
205
+ },
206
+ },
207
+ lifetimes: {
208
+ attached() {
209
+ // 在组件实例进入页面节点树时执行
210
+ this.initData();
211
+ },
212
+ detached() {
213
+ // 在组件实例被从页面节点树移除时执行
214
+ },
215
+ },
216
+ // 以下是旧式的定义方式,可以保持对 <2.2.3 版本基础库的兼容
217
+ attached() {
218
+ // 在组件实例进入页面节点树时执行
219
+ this.initData();
220
+ },
221
+ detached() {
222
+ // 在组件实例被从页面节点树移除时执行
223
+ },
224
+ observers: {
225
+ // 当参数变化时
226
+ option() {
227
+ this.initData();
228
+ },
229
+ },
230
+ methods: {
231
+ initData() {
232
+ this.setData({
233
+ ec: {
234
+ onInit: this.initChart.bind(this),
235
+ },
236
+ });
237
+ },
238
+ async initChart(canvas, width, height, dpr) {
239
+ const objEchart = echarts.init(canvas, null, {
240
+ width,
241
+ height,
242
+ devicePixelRatio: dpr,
243
+ });
244
+ canvas.setChart(objEchart);
245
+ const objEChartBar = new EchartBar();
246
+ await objEChartBar.setOptions(this.properties);
247
+ const options = await objEChartBar.getOptions();
248
+ // objEchart.clear();
249
+ console.log('设置前参数bar', options);
250
+ objEchart.setOption(options);
251
+ return objEchart;
252
+ },
253
+ },
254
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "ec-canvas": "../ec-canvas/ec-canvas"
5
+ }
6
+ }
@@ -0,0 +1,3 @@
1
+ <view wx:if="ec" class="{{className}} ec_container" style="{{style}}" id="{{id}}">
2
+ <ec-canvas canvas-id="{{canvas_id}}" ec="{{ ec }}"></ec-canvas>
3
+ </view>
@@ -0,0 +1,9 @@
1
+ /**index.wxss**/
2
+ ec-canvas {
3
+ width: 100%;
4
+ height: 100%;
5
+ }
6
+ .ec_container {
7
+ width: 100%;
8
+ height: 380px;
9
+ }
@@ -0,0 +1,50 @@
1
+ /** 根据当前环境获取 pc 上配置,还是 H5上的配置 */
2
+ const getConfig = () => {
3
+ const barH5 = {
4
+ xAxis: {
5
+ name: 'X轴名',
6
+ nameTextStyle: { align: 'center' },
7
+ axisLabel: {
8
+ show: true, // 刻度标签显示
9
+ rotate: 0, // 字体倾斜
10
+ },
11
+ axisTick: {
12
+ show: true, // 刻度显示
13
+ },
14
+ type: 'category',
15
+ data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
16
+ inverse:false,
17
+ },
18
+ yAxis: {
19
+ type: 'value',
20
+ show: true, // y轴刻度线
21
+ name: 'Y轴名',
22
+ splitLine: {
23
+ lineStyle: {
24
+ width: 1, // 网格线宽度,为0则不显示
25
+ type: 'dashed', //solid,dashed,dotted
26
+ },
27
+ },
28
+ axisLabel: { padding: [0, -10, 0, 0] },
29
+ min: null,
30
+ max: null,
31
+ },
32
+ series: [
33
+ {
34
+ name: 'demo',
35
+ data: [820, 932, 901, 934, 1290, 1330, 1320],
36
+ type: 'bar',
37
+ itemStyle: {
38
+ color: 'green',
39
+ },
40
+ smooth: true,
41
+ showSymbol: true, //是否显示线条上数据标签
42
+ label: {
43
+ show: true, // 显示线条上的数据
44
+ },
45
+ },
46
+ ],
47
+ };
48
+ return barH5;
49
+ };
50
+ export default getConfig;
@@ -0,0 +1,16 @@
1
+ /** 根据当前环境获取 pc 上配置,还是 H5上的配置 */
2
+ const getConfig = () => {
3
+ const globalH5 = {
4
+ title: {
5
+ text: 'demo实例',
6
+ show: true,
7
+ left: '45%',
8
+ },
9
+ legend: {
10
+ top: '83%',
11
+ },
12
+ tooltip: {},
13
+ };
14
+ return globalH5;
15
+ };
16
+ export default getConfig;
@@ -0,0 +1,48 @@
1
+ /** 根据当前环境获取 pc 上配置,还是 H5上的配置 */
2
+ const getConfig = () => {
3
+ const lineH5 = {
4
+ xAxis: {
5
+ name: 'X轴名',
6
+ nameTextStyle: { align: 'center' },
7
+ axisLabel: {
8
+ show: true, // 刻度标签显示
9
+ rotate: 0, // 字体倾斜
10
+ },
11
+ axisTick: {
12
+ show: true, // 刻度显示
13
+ },
14
+ type: 'category',
15
+ data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
16
+ },
17
+ yAxis: {
18
+ type: 'value',
19
+ show: true, // y轴刻度线
20
+ name: 'Y轴名',
21
+ splitLine: {
22
+ lineStyle: {
23
+ width: 1, // 网格线宽度,为0则不显示
24
+ type: 'dashed', //solid,dashed,dotted
25
+ },
26
+ },
27
+ axisLabel: {
28
+ padding: [0, -10, 0, 0],
29
+ },
30
+ min: null,
31
+ max: null,
32
+ },
33
+ series: [
34
+ {
35
+ name: 'demo',
36
+ data: [820, 932, 901, 934, 1290, 1330, 1320],
37
+ type: 'line',
38
+ smooth: true,
39
+ showSymbol: true, //是否显示线条上数据标签
40
+ label: {
41
+ show: true, // 显示线条上的数据
42
+ },
43
+ },
44
+ ],
45
+ };
46
+ return lineH5;
47
+ };
48
+ export default getConfig;
@@ -0,0 +1,36 @@
1
+ /** 根据当前环境获取 pc 上配置,还是 H5上的配置 */
2
+ const getConfig = () => {
3
+ const pieH5 = {
4
+ series: [
5
+ {
6
+ // name: 'demo',
7
+ data: [
8
+ { value: 820, name: '实例数据1', tooltip: {}, itemStyle: {} },
9
+ { value: 932, name: '实例数据2', tooltip: {}, itemStyle: {} },
10
+ { value: 901, name: '实例数据3', tooltip: {}, itemStyle: {} },
11
+ { value: 934, name: '实例数据4', tooltip: {}, itemStyle: {} },
12
+ { value: 1290, name: '实例数据5', tooltip: {}, itemStyle: {} },
13
+ ],
14
+ label: {
15
+ show: true,
16
+ position: 'inner',
17
+ normal: {
18
+ formatter: null,
19
+ position: 'inner',
20
+ },
21
+ },
22
+ type: 'pie',
23
+ radius: '70%',
24
+ emphasis: {
25
+ itemStyle: {
26
+ shadowBlur: 10,
27
+ shadowOffsetX: 0,
28
+ shadowColor: 'rgba(0, 0, 0, 0.5)',
29
+ },
30
+ },
31
+ },
32
+ ],
33
+ };
34
+ return pieH5;
35
+ };
36
+ export default getConfig;
@@ -0,0 +1,262 @@
1
+ import EchartBase from './eChartBase';
2
+ import getConfig from '../config/bar';
3
+ /**
4
+ * 柱状图表
5
+ * @author loonglong
6
+ **/
7
+ class EchartBar 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
+ isPile,
21
+ groupKey,
22
+ groupKeyTimeSpan,
23
+ }) {
24
+ xField = xField || {};
25
+ const { name = '', type = '', methodName = '' } = dataSource;
26
+ if (name !== '') {
27
+ const params = this.createWhere({
28
+ filterData,
29
+ xField,
30
+ xStatistics,
31
+ xIsCountEmpty,
32
+ yField,
33
+ groupKey,
34
+ groupKeyTimeSpan,
35
+ });
36
+ const arrSourData = await this.getSourceData(
37
+ name,
38
+ methodName,
39
+ type,
40
+ params,
41
+ );
42
+ // 获取 x 轴数据
43
+ const arrXaxisData = this.setXaxis(arrSourData, xField.format);
44
+ const arrXisCountEmptyIndex = []; // 记录空值的key
45
+ if (!groupKey) { // 没有分组
46
+ const numLine = arrSourData[0].YLabels.length;
47
+ if (numLine > 0) {
48
+ for (let j = 0; j < numLine; j++) {
49
+ this.config.series[j] = {
50
+ type: 'bar',
51
+ name: '',
52
+ itemStyle: { color: null },
53
+ showSymbol: true,
54
+ label: {
55
+ show: true,
56
+ },
57
+ stack: isPile ? 'pile' : null,
58
+ data: [],
59
+ };
60
+ arrSourData.forEach((itemSource,index) => {
61
+ this.config.series[j].name = itemSource.YLabels[j].Cn_Name;
62
+ if ((!itemSource.YLabels[j].Value || itemSource.YLabels[j].Value === 0 || 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
+ // 处理显示空值问题
73
+ this.setEmptyValue(xIsCountEmpty);
74
+ } else if (groupKey) {
75
+ // 如果是分组,则这里需要特殊处理
76
+ // 按groupKey分组存放数据值
77
+ const objGroupKey = {}; // {'分组字段':[{value:'统计的值', dimensionality:'维度名', name:'统计的数值字段名'}]}
78
+ arrSourData.forEach((itemSourData) => {
79
+ itemSourData.YLabels.forEach((yLabel) => {
80
+ if (!objGroupKey[yLabel.Group_Name]) {
81
+ objGroupKey[yLabel.Group_Name] = [];
82
+ }
83
+ objGroupKey[yLabel.Group_Name].push({
84
+ value: yLabel.Value,
85
+ dimensionality: itemSourData.XLabel.Value,
86
+ name: yLabel.Cn_Name,
87
+ });
88
+ });
89
+ });
90
+
91
+ // 组装图表需要的数据
92
+ const arrGroupKey = Object.keys(objGroupKey);
93
+ this.config.series = arrGroupKey.map((groupKey) => {
94
+ // groupKey分组字段中文名
95
+ const serie = {
96
+ name: groupKey,
97
+ type: 'bar',
98
+ itemStyle: {
99
+ color: null,
100
+ },
101
+ showSymbol: true,
102
+ label: {
103
+ show: true,
104
+ },
105
+ data: this.getSeriesDataGroup(
106
+ arrXaxisData,
107
+ objGroupKey[groupKey],
108
+ ),
109
+ stack: isPile ? 'pile' : null,
110
+ };
111
+ return serie;
112
+ });
113
+ this.config.tooltip.formatter = params => (
114
+ `${params.data.dimensionality
115
+ }\r\n${
116
+ params.data.name
117
+ }\r\n${
118
+ params.seriesName
119
+ }:${
120
+ params.value}`
121
+ );
122
+ }
123
+ console.log('sourData处理后数据bar:', this.config.series);
124
+ }
125
+ }
126
+ setColor({ setColor }) {
127
+ if (this.config.series.length > 0 && setColor && setColor.length > 0) {
128
+ let i = 0;
129
+ this.config.series.forEach((itemSeries) => {
130
+ itemSeries.itemStyle.color = setColor[i % 6];
131
+ i = i + 1;
132
+ });
133
+ }
134
+ }
135
+
136
+ // 显示图表上的数据标签 单位,标签,小数位数,后缀
137
+ setIsSeriesShowSymbol({
138
+ isSeriesShowSymbol,
139
+ isUnit,
140
+ unit,
141
+ decimalDigits,
142
+ suffix
143
+ }) {
144
+ decimalDigits = Math.max(0, decimalDigits);
145
+ this.config.series.length > 0
146
+ && this.config.series.forEach((itemSeries) => {
147
+ itemSeries.showSymbol = isSeriesShowSymbol;
148
+ itemSeries.label.show = isSeriesShowSymbol;
149
+ if (isUnit) {
150
+ itemSeries.label.formatter = (params) => {
151
+ const objNewValue = this.getValueByUnit(params.value, unit);
152
+ return (
153
+ `${objNewValue.toFixed(decimalDigits)}${objNewValue.unit}${suffix}`
154
+ );
155
+ };
156
+ }
157
+ });
158
+ if (isUnit) {
159
+ this.config.yAxis.axisLabel.formatter = (value) => {
160
+ const objNewValue = this.getValueByUnit(value, unit);
161
+ return `${objNewValue.toFixed(decimalDigits)}${objNewValue.unit}${suffix}`;
162
+ };
163
+ } else {
164
+ this.config.yAxis.axisLabel.formatter = null;
165
+ }
166
+ }
167
+ // 设置柱状图X,Y倒转
168
+ setDirectionType({directionType}) {
169
+ let temAxis = {};
170
+ if (directionType === 'crosswise') { // 横向
171
+ temAxis = this.config.xAxis;
172
+ // @ts-ignore
173
+ this.config.xAxis = this.config.yAxis;
174
+ // @ts-ignore
175
+ this.config.yAxis = temAxis;
176
+ this.config.yAxis.inverse = true;
177
+
178
+ } else { // 纵向
179
+ if (this.config.yAxis.inverse) {
180
+ temAxis = this.config.yAxis;
181
+ // @ts-ignore
182
+ this.config.yAxis = this.config.xAxis;
183
+ // @ts-ignore
184
+ this.config.xAxis = temAxis;
185
+ this.config.xAxis.inverse = false;
186
+ }
187
+ }
188
+ }
189
+ async setOptions({
190
+ directionType,
191
+ isPile,
192
+ setColor,
193
+ isTitle,
194
+ title,
195
+ titleLocation,
196
+ dataSource,
197
+ filterData,
198
+ xField,
199
+ xStatistics,
200
+ xIsCountEmpty,
201
+ groupKey,
202
+ groupKeyTimeSpan,
203
+ yField,
204
+ isLegend,
205
+ legend,
206
+ isXaxisName,
207
+ xAxisName,
208
+ isXaxisAxisLabelShow,
209
+ isXaxisAxisTickShow,
210
+ isXaxisAxisLabelRotate,
211
+ isYAxisSplitlineLinestyleWidth,
212
+ yAxisSplitlineLinestyleType,
213
+ yAxisMax,
214
+ yAxisMin,
215
+ isYAxisName,
216
+ yAxisName,
217
+ isSeriesShowSymbol,
218
+ isYAxisShow,
219
+ isUnit,
220
+ unit,
221
+ decimalDigits,
222
+ suffix
223
+ }) {
224
+ if (dataSource) {
225
+ await this.setSourceData({
226
+ dataSource,
227
+ filterData,
228
+ xField,
229
+ xStatistics,
230
+ xIsCountEmpty,
231
+ yField,
232
+ isPile,
233
+ groupKey,
234
+ groupKeyTimeSpan,
235
+ });
236
+ }
237
+ this.setColor({ setColor });
238
+ this.setTitle({ isTitle, title, titleLocation });
239
+ this.setLegend({ isLegend, legend });
240
+ this.setIsXaxisAxisLabelShow({ isXaxisAxisLabelShow });
241
+ this.setIsXaxisName({ isXaxisName, xAxisName });
242
+ this.setIsXaxisAxisTickShow({ isXaxisAxisTickShow });
243
+ this.setIsXaxisAxisLabelRotate({ isXaxisAxisLabelRotate, xStatistics});
244
+ this.setIsYAxisSplitlineLinestyleWidth({
245
+ isYAxisSplitlineLinestyleWidth,
246
+ yAxisSplitlineLinestyleType,
247
+ });
248
+ this.setYAxisMaxMin({ yAxisMax, yAxisMin });
249
+ this.setIsYAxisName({ isYAxisName, yAxisName });
250
+ this.setIsYAxisShow({ isYAxisShow });
251
+ this.setIsSeriesShowSymbol({
252
+ isSeriesShowSymbol,
253
+ isUnit,
254
+ unit,
255
+ decimalDigits,
256
+ suffix
257
+ });
258
+ this.setDirectionType({directionType});
259
+ }
260
+ }
261
+
262
+ export default EchartBar;