xt-element-ui 1.2.4 → 1.2.5

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 (42) hide show
  1. package/docs/README.md +201 -0
  2. package/docs/components/base/xt-button.md +114 -0
  3. package/docs/components/base/xt-card-item.md +104 -0
  4. package/docs/components/base/xt-card.md +108 -0
  5. package/docs/components/base/xt-config-provider.md +199 -0
  6. package/docs/components/base/xt-flex-box.md +115 -0
  7. package/docs/components/base/xt-grid-box.md +303 -0
  8. package/docs/components/base/xt-input.md +150 -0
  9. package/docs/components/base/xt-text.md +212 -0
  10. package/docs/components/extend/ex-bar.md +68 -0
  11. package/docs/components/extend/ex-button.md +62 -0
  12. package/docs/components/extend/ex-card.md +86 -0
  13. package/docs/components/extend/ex-chart.md +355 -0
  14. package/docs/components/extend/ex-icon.md +190 -0
  15. package/docs/components/extend/ex-line.md +71 -0
  16. package/docs/components/extend/ex-multi.md +156 -0
  17. package/docs/components/extend/ex-page.md +75 -0
  18. package/docs/components/extend/ex-pie.md +70 -0
  19. package/docs/components/extend/ex-select-tree.md +210 -0
  20. package/docs/components/extend/ex-table.md +591 -0
  21. package/docs/components/extend/ex-upload.md +134 -0
  22. package/docs/components/utils/size.md +148 -0
  23. package/docs/components/utils/theme.md +183 -0
  24. package/lib/index.common.js +332 -296
  25. package/lib/index.css +1 -1
  26. package/lib/index.umd.js +332 -296
  27. package/lib/index.umd.min.js +4 -4
  28. package/package.json +4 -2
  29. package/src/components/ex-chart/ExMulti.vue +44 -32
  30. package/src/components/ex-chart/ExPie.vue +5 -4
  31. package/src/components/ex-chart/index.vue +1 -4
  32. package/src/components/ex-chart/utils.js +1 -1
  33. package/src/components/ex-icon/index.js +2 -0
  34. package/src/components/ex-icon/index.vue +168 -0
  35. package/src/components/ex-icon/style/index.scss +7 -0
  36. package/src/components/ex-table/index.vue +3 -3
  37. package/src/components/index.scss +4 -1
  38. package/src/components/xt-card-item/images/bar.svg +1 -0
  39. package/src/components/xt-card-item/images/line.svg +1 -0
  40. package/src/components/xt-card-item/images/pie.svg +1 -0
  41. package/src/index.js +3 -0
  42. package/src/components/ex-chart/ExTrend.vue +0 -124
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xt-element-ui",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "基于 Vue2.7 + ElementUI 的组件库",
5
5
  "main": "lib/index.common.js",
6
6
  "module": "lib/index.esm.js",
@@ -27,7 +27,9 @@
27
27
  "files": [
28
28
  "lib",
29
29
  "src",
30
- "README.md"
30
+ "README.md",
31
+ "docs/components/**/*md",
32
+ "docs/README.md"
31
33
  ],
32
34
  "dependencies": {
33
35
  "echarts": "^6.1.0",
@@ -15,6 +15,12 @@ export default {
15
15
  type: String,
16
16
  default: "medium"
17
17
  },
18
+ // 新增极简模式开关
19
+ simpleMode: {
20
+ type: Boolean,
21
+ default: false
22
+ },
23
+ highlightKey: String,// 需要高亮的日期/标识
18
24
  config: {
19
25
  type: Object,
20
26
  default() {
@@ -33,6 +39,7 @@ export default {
33
39
  return [
34
40
  {
35
41
  label: "入户数",
42
+ unit: "户",
36
43
  data: [
37
44
  { label: "01月", value: 980 },
38
45
  { label: "02月", value: 806 },
@@ -50,6 +57,7 @@ export default {
50
57
  },
51
58
  {
52
59
  label: "隐患数",
60
+ unit: "个",
53
61
  data: [
54
62
  { label: "01月", value: 200 },
55
63
  { label: "02月", value: 120 },
@@ -67,6 +75,7 @@ export default {
67
75
  },
68
76
  {
69
77
  label: "整改数",
78
+ unit: "个",
70
79
  data: [
71
80
  { label: "01月", value: 25 },
72
81
  { label: "02月", value: 19 },
@@ -89,10 +98,6 @@ export default {
89
98
  type: Array,
90
99
  default: () => { return []; }
91
100
  },
92
- selectedNew: {
93
- type: Object,
94
- default: null
95
- },
96
101
  energyType: {
97
102
  type: [String, Array],
98
103
  default: ""
@@ -138,9 +143,19 @@ export default {
138
143
  methods: {
139
144
  initChart() {
140
145
  const _self = this;
141
- // 数据处理
142
- const groupYAxis = (unit) => {
143
- return {
146
+
147
+ // chartData 中收集所有 unit,并保持首次出现顺序去重
148
+ const uniqueUnits = [];
149
+ (_self.chartData || []).forEach(item => {
150
+ const u = item.unit || "";
151
+ if (uniqueUnits.indexOf(u) === -1) {
152
+ uniqueUnits.push(u);
153
+ }
154
+ });
155
+
156
+ // 单个 yAxis 的生成函数
157
+ const groupYAxis = (unit, index) => {
158
+ const yAxis = {
144
159
  type: "value",
145
160
  name: unit,
146
161
  axisLine: {
@@ -167,7 +182,24 @@ export default {
167
182
  }
168
183
  }
169
184
  };
185
+ if (index > 0) {
186
+ yAxis.position = "right";
187
+ yAxis.splitLine = { show: false };
188
+ }
189
+ return yAxis;
170
190
  };
191
+
192
+ // 根据去重后的 unit 生成 yAxis
193
+ const yAxisList = uniqueUnits.length
194
+ ? uniqueUnits.map((unit, idx) => groupYAxis(unit, idx))
195
+ : [groupYAxis("", 0)];
196
+
197
+ // unit -> yAxisIndex 的映射,便于 series 绑定
198
+ const unitToYAxisIndex = {};
199
+ uniqueUnits.forEach((unit, idx) => {
200
+ unitToYAxisIndex[unit] = idx;
201
+ });
202
+
171
203
  const option = {
172
204
  legend: {
173
205
  right: 20,
@@ -176,10 +208,7 @@ export default {
176
208
  data: _self.chartData.map((item) => {
177
209
  return item.label;
178
210
  }),
179
- selectedMode: "multiple",
180
- selected: _self.selectedNew,
181
211
  textStyle: {
182
- fontSize: 12
183
212
  }
184
213
  },
185
214
  tooltip: {
@@ -197,12 +226,6 @@ export default {
197
226
  },
198
227
  xAxis: {
199
228
  type: "category",
200
- // splitLine: {
201
- // show: true,
202
- // lineStyle: {
203
- // type: "dashed"
204
- // }
205
- // },
206
229
  axisLabel: {
207
230
  rotate: this.config.rotate
208
231
  },
@@ -210,7 +233,7 @@ export default {
210
233
  return item.label;
211
234
  }) : []
212
235
  },
213
- yAxis: typeof _self.energyType == "string" ? groupYAxis(_self.energyType) : this.energyType.map(unit => groupYAxis(unit)),
236
+ yAxis: yAxisList,
214
237
  dataZoom: [
215
238
  {
216
239
  type: "inside",
@@ -219,33 +242,22 @@ export default {
219
242
  end: 100
220
243
  }
221
244
  ],
222
- series: this.getSeriesData()
245
+ series: this.getSeriesData(unitToYAxisIndex)
223
246
  };
224
247
  this.myChart = EchartsUtil.init(_self.$refs.multilinechart, this.theme, option, this.size);
225
248
  },
226
- getSeriesData() {
227
- // 创建 24小时 时间数据填充对象
249
+ getSeriesData(unitToYAxisIndex) {
228
250
  const _self = this;
229
251
 
230
252
  const _seriesData = [];
231
253
  _self.chartData.map((item, ind) => {
232
- // debugger;
233
- const _isNUll = item.data.some(it => !it.value || it.value == "--");
234
- const _itemNull = {
235
- type: "",
236
- name: item.label,
237
- connectNulls: true, // 断点连线,true-连接,false-不连接
238
- data: item.data.map(it => it.value),
239
- tooltip: {
240
- show: false
241
- }
242
- };
243
254
  const _item = {
244
255
  animation: true,
245
256
  name: item.label,
246
257
  type: item.type || "bar",
247
258
  avoidLabelOverlap: true,
248
- data: item.data.map(it => it.value)
259
+ data: item.data.map(it => it.value),
260
+ yAxisIndex: unitToYAxisIndex[item.unit || ""] != null ? unitToYAxisIndex[item.unit || ""] : 0
249
261
  };
250
262
  _seriesData.push(_item);
251
263
  });
@@ -33,10 +33,12 @@ export default {
33
33
  type: Boolean,
34
34
  default: true
35
35
  },
36
- chartMode: {
37
- type: String,
38
- default: "dark"
36
+ // 新增极简模式开关
37
+ simpleMode: {
38
+ type: Boolean,
39
+ default: false
39
40
  },
41
+ highlightKey: String,// 需要高亮的日期/标识
40
42
  roseType: {
41
43
  type: String,
42
44
  default: ""
@@ -83,7 +85,6 @@ export default {
83
85
  methods: {
84
86
  initChart() {
85
87
  const _self = this;
86
- console.log(this.chartMode);
87
88
  // 数据处理
88
89
  const option = {
89
90
  title: {
@@ -3,14 +3,12 @@
3
3
  <ex-line v-else-if="type=='line'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-line>
4
4
  <ex-pie v-else-if="type=='pie'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-pie>
5
5
  <ex-multi v-else-if="type=='multi'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-multi>
6
- <ex-trend v-else-if="type=='trend'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-trend>
7
6
  </template>
8
7
  <script>
9
8
  import ExBar from "./ExBar.vue"
10
9
  import ExLine from "./ExLine.vue"
11
10
  import ExPie from "./ExPie.vue"
12
11
  import ExMulti from "./ExMulti.vue"
13
- import ExTrend from "./ExTrend.vue"
14
12
 
15
13
  export default {
16
14
  name: "ExChart",
@@ -18,8 +16,7 @@ export default {
18
16
  ExBar,
19
17
  ExLine,
20
18
  ExPie,
21
- ExMulti,
22
- ExTrend
19
+ ExMulti
23
20
  },
24
21
  props: {
25
22
  theme: {
@@ -122,7 +122,7 @@ EchartsUtil.EchartsUtil = {
122
122
  EchartsUtil.chartInstanceList = [];
123
123
 
124
124
  EchartsUtil.mergeOptions = function(themeOption, customOption) {
125
- return Object.assign({}, this.baseOption, themeOption, customOption);
125
+ return Object.assign({}, themeOption, customOption);
126
126
  };
127
127
 
128
128
  // 根据字体大小调整主题配置
@@ -0,0 +1,2 @@
1
+ import ExIcon from './index.vue'
2
+ export default ExIcon
@@ -0,0 +1,168 @@
1
+ <template>
2
+ <component
3
+ :is="tag"
4
+ :class="iconClasses"
5
+ :style="iconStyle"
6
+ v-on="$listeners"
7
+ @click="handleClick"
8
+ >
9
+ <svg v-if="isSvgSprite" :style="svgStyle" aria-hidden="true">
10
+ <use :href="svgHref" />
11
+ </svg>
12
+ <slot v-else-if="hasDefaultSlot" />
13
+ </component>
14
+ </template>
15
+
16
+ <script>
17
+ const customPrefixes = {}
18
+
19
+ const ExIcon = {
20
+ name: 'ExIcon',
21
+ inheritAttrs: false,
22
+
23
+ props: {
24
+ name: {
25
+ type: String,
26
+ default: ''
27
+ },
28
+ size: {
29
+ type: [String, Number],
30
+ default: ''
31
+ },
32
+ color: {
33
+ type: String,
34
+ default: ''
35
+ },
36
+ spin: {
37
+ type: Boolean,
38
+ default: false
39
+ }
40
+ },
41
+
42
+ computed: {
43
+ hasDefaultSlot() {
44
+ return !!this.$slots.default
45
+ },
46
+ iconName() {
47
+ return (this.name || '').trim()
48
+ },
49
+ isElIcon() {
50
+ return /^el-icon-/.test(this.iconName)
51
+ },
52
+ isSvgInline() {
53
+ return this.iconName.indexOf('<svg') > -1
54
+ },
55
+ isSvgSprite() {
56
+ return /^(#|svg:)/.test(this.iconName)
57
+ },
58
+ isCustomFont() {
59
+ if (!this.iconName) return false
60
+ return !this.isElIcon && !this.isSvgInline && !this.isSvgSprite
61
+ },
62
+ svgHref() {
63
+ if (!this.isSvgSprite) return ''
64
+ const name = this.iconName.replace(/^svg:/, '').replace(/^#/, '')
65
+ return `#${name}`
66
+ },
67
+ needsExIconPrefix() {
68
+ if (!this.isCustomFont) return false
69
+ for (const prefix of Object.keys(customPrefixes)) {
70
+ if (this.iconName.indexOf(prefix) === 0) {
71
+ return false
72
+ }
73
+ }
74
+ return true
75
+ },
76
+ tag() {
77
+ if (this.isSvgInline) return 'span'
78
+ return 'i'
79
+ },
80
+ iconClasses() {
81
+ const classes = []
82
+ if (this.isElIcon) {
83
+ classes.push(this.iconName)
84
+ } else if (this.isSvgSprite) {
85
+ classes.push('ex-icon-svg')
86
+ } else if (this.isCustomFont) {
87
+ if (this.needsExIconPrefix) classes.push('ex-icon')
88
+ classes.push(this.iconName)
89
+ } else if (this.isSvgInline) {
90
+ classes.push('ex-icon-inline-svg')
91
+ }
92
+ if (this.spin) classes.push('ex-icon-spin')
93
+ return classes
94
+ },
95
+ iconStyle() {
96
+ const style = {}
97
+ if (this.size) {
98
+ const s = typeof this.size === 'number' ? `${this.size}px` : this.size
99
+ style.fontSize = s
100
+ style.width = s
101
+ style.height = s
102
+ }
103
+ if (this.color) {
104
+ style.color = this.color
105
+ }
106
+ if (this.isSvgInline) {
107
+ style.display = 'inline-block'
108
+ style.verticalAlign = 'middle'
109
+ }
110
+ return style
111
+ },
112
+ svgStyle() {
113
+ return {
114
+ width: '1em',
115
+ height: '1em',
116
+ verticalAlign: '-0.15em',
117
+ fill: 'currentColor',
118
+ overflow: 'hidden'
119
+ }
120
+ }
121
+ },
122
+
123
+ mounted() {
124
+ if (this.isSvgInline && this.$el) {
125
+ this.$el.innerHTML = this.iconName
126
+ }
127
+ },
128
+
129
+ beforeUpdate() {
130
+ if (this.isSvgInline && this.$el) {
131
+ this.$el.innerHTML = this.iconName
132
+ }
133
+ },
134
+
135
+ methods: {
136
+ handleClick(e) {
137
+ this.$emit('click', e)
138
+ }
139
+ }
140
+ }
141
+
142
+ ExIcon.registerPrefix = function (prefix) {
143
+ if (prefix && typeof prefix === 'string') {
144
+ customPrefixes[prefix] = true
145
+ }
146
+ }
147
+
148
+ export default ExIcon
149
+ </script>
150
+
151
+ <style lang="scss" scoped>
152
+ .ex-icon-svg {
153
+ display: inline-flex;
154
+ align-items: center;
155
+ justify-content: center;
156
+ vertical-align: middle;
157
+ font-size: inherit;
158
+ }
159
+
160
+ .ex-icon-spin {
161
+ animation: ex-icon-spin-rotate 1s linear infinite;
162
+ }
163
+
164
+ @keyframes ex-icon-spin-rotate {
165
+ from { transform: rotate(0deg); }
166
+ to { transform: rotate(360deg); }
167
+ }
168
+ </style>
@@ -0,0 +1,7 @@
1
+ .ex-icon {
2
+ display: inline-block;
3
+ font-style: normal;
4
+ -webkit-font-smoothing: antialiased;
5
+ -moz-osx-font-smoothing: grayscale;
6
+ vertical-align: -0.15em;
7
+ }
@@ -97,10 +97,10 @@
97
97
  <!-- 分页 -->
98
98
  <div class="ex-table-footer" v-if="showPagination">
99
99
  <el-pagination
100
- :current-page="pagination.PageNum"
101
- :page-size="pagination.PageSize"
100
+ :current-page="pagination.ppageNum"
101
+ :page-size="pagination.pageSize"
102
102
  :total="total"
103
- :page-sizes="pagination.PageSizes || [10, 20, 50, 100]"
103
+ :page-sizes="pagination.pageSizes || [10, 20, 50, 100]"
104
104
  layout="total, sizes, prev, pager, next, jumper"
105
105
  @size-change="handleSizeChange"
106
106
  @current-change="handleCurrentChange"
@@ -28,4 +28,7 @@
28
28
  @import './ex-card/style/index.scss';
29
29
 
30
30
  // GridBox 组件样式
31
- @import './xt-grid-box/style/index.scss';
31
+ @import './xt-grid-box/style/index.scss';
32
+
33
+ // ExIcon 组件样式
34
+ @import './ex-icon/style/index.scss';
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1781571276852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="35671" data-spm-anchor-id="a313x.search_index.0.i17.53a93a81J5fQhI" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M0 346.453333h179.2v611.84H0z" fill="#C0D6FF" p-id="35672" data-spm-anchor-id="a313x.search_index.0.i14.53a93a81J5fQhI" class=""></path><path d="M281.6 113.777778H460.8v844.8H281.6z" fill="#035DFF" p-id="35673" data-spm-anchor-id="a313x.search_index.0.i16.53a93a81J5fQhI" class="selected"></path><path d="M563.2 229.376h179.2v729.088H563.2z" fill="#32C894" p-id="35674"></path><path d="M844.8 338.716444H1024v620.032h-179.2z" fill="#CCF1E4" p-id="35675" data-spm-anchor-id="a313x.search_index.0.i13.53a93a81J5fQhI" class="selected"></path></svg>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1781571535496" class="icon" viewBox="0 0 1228 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="54623" data-spm-anchor-id="a313x.search_index.0.i19.53a93a81J5fQhI" xmlns:xlink="http://www.w3.org/1999/xlink" width="239.84375" height="200"><path d="M25.4464 679.296C137.3696 957.952 264.3968 1061.4528 405.8624 985.088c41.5744-22.4256 85.1712-81.0752 138.24-179.5584 21.3504-39.5776 43.8272-84.736 72.448-144.7168 12.9536-27.1872 63.5392-134.8096 75.6992-160.4096 97.6128-205.1328 165.2224-323.9168 238.7456-403.2768 92.5184-99.8912 180.1216-113.4592 271.2576-27.392l8.8064-9.2928c-96.896-91.4944-192.512-76.672-289.4592 27.9808-74.7008 80.64-142.7456 200.1408-240.896 406.5024-12.2112 25.6-62.7712 133.2224-75.7248 160.384-28.5184 59.8016-50.9184 104.7808-72.1408 144.128-51.8912 96.3328-94.464 153.5488-133.0688 174.3872C267.3664 1045.2992 146.7904 947.0976 37.3504 674.56l-11.8784 4.7616z" fill="#67c8fb" p-id="54624" data-spm-anchor-id="a313x.search_index.0.i20.53a93a81J5fQhI" class="selected"></path><path d="M0.1024 472.3968c95.0272 187.1616 234.496 238.72 415.744 153.4976 69.632-32.768 118.8864-87.6288 209.3312-215.7056l9.728-13.7984 9.728-13.7216c92.3648-130.3552 146.2272-184.4736 218.6496-199.8592 93.1328-19.7632 201.8816 44.5696 340.736 215.936l9.984-8.064c-141.568-174.6944-254.3616-241.408-353.3568-220.3904-76.8512 16.3328-132.1728 71.8848-226.4576 204.9792l-9.728 13.7472-9.728 13.7984c-89.088 126.1568-137.472 180.0448-204.3392 211.4816-174.848 82.2528-306.944 33.408-398.8736-147.712L0.1024 472.4224z" fill="#5483FC" p-id="54625"></path></svg>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1781571036529" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="15689" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M463.368 835.6c-139.688-23.544-278.456-159-278.456-323.256 6.512-159.328 121.848-293.224 278.456-323.256V0.648C230.768 24.192 0.008 244.08 0.008 511.704c0 267.616 230.624 488.16 463.352 511.048V835.6z m0 0" fill="#83a9fd" p-id="15690"></path><path d="M837.352 511.704a322.96 322.96 0 0 1-21.6 121.048l161.832 93.592a520.536 520.536 0 0 0 44.528-214.64m0 0c6.728-267.888-199.096-493.376-466.488-511.056l0.648 187.8c186.088 23.576 281.08 159 281.08 323.256" fill="#2e65f3" p-id="15691" data-spm-anchor-id="a313x.search_index.0.i8.53a93a81J5fQhI" class="selected"></path><path d="M770.336 711.928a315.104 315.104 0 0 1-212.056 121.832v188a533.704 533.704 0 0 0 371.096-216.168l-159.04-93.664z m0 0" fill="#83a9fd" p-id="15692"></path></svg>
package/src/index.js CHANGED
@@ -29,6 +29,7 @@ import XtDatePicker from './components/xt-date-picker'
29
29
  import ExButton from './components/ex-button'
30
30
  import ExChart from './components/ex-chart' // ExChart 组件(基于 ECharts 封装)
31
31
  import ExCard from './components/ex-card'
32
+ import ExIcon from './components/ex-icon' // ExIcon 组件(支持 el-icon / svg / 自定义字体)
32
33
  import ExTable from './components/ex-table' // ExTable 组件(基于 ElementUI Table 封装)
33
34
 
34
35
  // 导入 Element UI 组件注册配置
@@ -49,6 +50,7 @@ const components = [
49
50
  ExButton,
50
51
  ExChart,
51
52
  ExCard,
53
+ ExIcon,
52
54
  ExTable
53
55
  ]
54
56
 
@@ -134,6 +136,7 @@ export default {
134
136
  XtDatePicker,
135
137
  ExButton,
136
138
  ExCard,
139
+ ExIcon,
137
140
  ExTable
138
141
  }
139
142
 
@@ -1,124 +0,0 @@
1
- <template>
2
- <div ref="barchart" class="bar-box" :style="{width:width}"></div>
3
- </template>
4
- <script>
5
- import EchartsUtil from "./utils";
6
- export default {
7
- name: "XtTrend",
8
- props: {
9
- type: {
10
- type: String,
11
- default: "bar"
12
- },
13
- theme: {},
14
- size: {
15
- type: String,
16
- default: "medium"
17
- },
18
- chartData: {
19
- type: Array,
20
- default: () => {
21
- return [
22
- { value: 53, label: "正常设备" },
23
- { value: 10, label: "正常设备" },
24
- { value: 60, label: "离线设备" }
25
- ];
26
- }
27
- },
28
- width: {
29
- type: String,
30
- default: "100%"
31
- },
32
- energyType: {
33
- type: String,
34
- default: "m³"
35
- }
36
- },
37
- data() {
38
- return {
39
- myChart: null
40
- };
41
- },
42
- watch: {
43
- type: {
44
- handler() {
45
- const _self = this;
46
- const option = _self.getOption();
47
- _self.myChart.setOption(option);
48
- }
49
- },
50
- chartData: {
51
- deep: true,
52
- handler(newVal, oldVal) {
53
- const _self = this;
54
- _self.initChart();
55
- }
56
- },
57
- theme(newVal) {
58
- this.initChart();
59
- }
60
- },
61
- mounted() {
62
- this.initChart();
63
- },
64
- methods: {
65
- getOption() {
66
- const _self = this;
67
- // 数据处理
68
- const option = {
69
- xAxis: {
70
- type: "category",
71
- axisTick: {
72
- show: false,
73
- splitLine: {
74
- lineStyle: {
75
- }
76
- }
77
- },
78
- axisLabel: {
79
- }
80
- },
81
- tooltip: {
82
- borderWidth: 1,
83
- trigger: "item"
84
- },
85
- grid: {
86
- top: "10",
87
- left: "10",
88
- right: "10",
89
- bottom: "20"
90
- },
91
- yAxis: {
92
- show: false,
93
- type: "value"
94
- },
95
- series: {
96
- type: _self.type || "bar",
97
- areaStyle: {},
98
- showSymbol: false,
99
- smooth: true,
100
- data: _self.chartData.map((item, ind) => {
101
- const { label, value } = item;
102
- return {
103
- value,
104
- label
105
- };
106
- })
107
- }
108
- };
109
- return option;
110
- },
111
- initChart() {
112
- const _self = this;
113
- // 数据处理
114
- const option = this.getOption();
115
- this.myChart = EchartsUtil.init(_self.$refs.barchart, this.theme, option, this.size);
116
- }
117
- }
118
- };
119
- </script>
120
- <style lang="scss" scoped>
121
- .bar-box{
122
- position: relative;
123
- }
124
- </style>