lw-cdp-ui 1.3.31 → 1.3.33

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.
@@ -246,6 +246,8 @@ export default {
246
246
 
247
247
  <style scoped>
248
248
  .chart {
249
+ background-color: var(--el-bg-color-overlay);
250
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.0509803922);
249
251
  width: 100%;
250
252
  height: 100%;
251
253
  }
@@ -49,8 +49,7 @@ export default {
49
49
  if (this.chart) {
50
50
  this.chart.dispose()
51
51
  }
52
-
53
- this.chart = markRaw(markRaw(this.echarts.init(this.$refs.chartRef)))
52
+ this.chart = markRaw(this.echarts.init(this.$refs.chartRef))
54
53
  this.updateChart()
55
54
 
56
55
  window.addEventListener('resize', () => {
@@ -62,19 +61,20 @@ export default {
62
61
  updateChart() {
63
62
  if (!this.chart || !this.rawData) return
64
63
 
65
- const {setting, dataSet} = this.rawData
66
- const {tables} = dataSet
67
- if (!tables || tables.length === 0) return
64
+ const {setting = {}, dataSet} = this.rawData
65
+ const {tables = []} = dataSet || {}
68
66
 
69
67
  this.option = {
70
68
  title: this.getTitleOption(setting),
71
69
  legend: this.getLegendOption(setting, tables),
72
- grid: setting.grid || {containLabel: true},
73
- tooltip: setting.tooltip || {},
74
- color: setting.color,
70
+ grid: this.getGridOption(setting),
71
+ tooltip: this.getTooltipOption(setting),
72
+ toolbox: this.getToolboxOption(setting),
73
+ color: setting.useThemeColor ? undefined : setting.color || this.getDefaultColors(),
75
74
  xAxis: this.getXAxisOption(setting, tables),
76
- yAxis: this.getYAxisOption(setting),
77
- series: this.getSeries(setting, tables)
75
+ yAxis: this.getYAxisOption(setting, tables),
76
+ series: this.getSeries(setting, tables),
77
+ dataZoom: this.getDataZoomOption(setting)
78
78
  }
79
79
  this.chart.setOption(this.option)
80
80
  setTimeout(() => {
@@ -82,65 +82,195 @@ export default {
82
82
  }, 10)
83
83
  },
84
84
 
85
+ // 配置项方法(保持与AreaChart一致的逻辑结构)
85
86
  getTitleOption(setting) {
86
87
  return {
87
- show: setting.title?.show || false,
88
+ show: setting.title?.show !== false,
88
89
  text: setting.title?.text || '',
89
- textStyle: setting.title?.textStyle || {},
90
+ textStyle: {
91
+ fontSize: 16,
92
+ fontWeight: 'bold',
93
+ color: '#333',
94
+ ...setting.title?.textStyle
95
+ },
90
96
  left: setting.title?.left || 'center',
97
+ top: setting.title?.top || 'top',
91
98
  padding: setting.title?.padding || [5, 5, 5, 5]
92
99
  }
93
100
  },
94
101
 
95
102
  getLegendOption(setting, tables) {
96
103
  return {
97
- ...(setting.legend || {}),
98
- data: tables.map(table => table.metricName)
104
+ show: setting.legend?.show !== false,
105
+ data: tables.map(table => table.metricName),
106
+ type: setting.legend?.type || 'scroll',
107
+ orient: setting.legend?.orient || 'horizontal',
108
+ left: setting.legend?.left || 'center',
109
+ top: setting.legend?.top || 'bottom',
110
+ itemGap: setting.legend?.itemGap || 10,
111
+ itemWidth: setting.legend?.itemWidth || 25,
112
+ itemHeight: setting.legend?.itemHeight || 14,
113
+ textStyle: {
114
+ fontSize: 12,
115
+ ...setting.legend?.textStyle
116
+ }
99
117
  }
100
118
  },
101
119
 
102
- getXAxisOption(setting, tables) {
103
- return setting.revertAxis
104
- ? {type: 'value'}
105
- : {
106
- type: 'category',
107
- data: tables[0].headers
120
+ getGridOption(setting) {
121
+ return {
122
+ left: setting.grid?.left || '3%',
123
+ right: setting.grid?.right || '4%',
124
+ top: setting.grid?.top || '15%',
125
+ bottom: setting.grid?.bottom || (setting.legend?.show !== false ? '15%' : '3%'),
126
+ containLabel: setting.grid?.containLabel !== false
127
+ }
128
+ },
129
+
130
+ getTooltipOption(setting) {
131
+ return {
132
+ trigger: 'axis',
133
+ axisPointer: {
134
+ type: setting.tooltip?.axisPointer?.type || 'shadow',
135
+ label: {
136
+ backgroundColor: setting.tooltip?.axisPointer?.label?.backgroundColor || '#6a7985'
108
137
  }
138
+ },
139
+ formatter: params => {
140
+ if (setting.tooltip?.formatter) return setting.tooltip.formatter(params)
141
+ return params.map(item => `${item.marker} ${item.seriesName}: ${item.value}`).join('<br/>')
142
+ }
143
+ }
109
144
  },
110
145
 
111
- getYAxisOption(setting) {
112
- return setting.revertAxis
113
- ? {
114
- type: 'category',
115
- data: this.rawData.dataSet.tables[0].headers
146
+ getToolboxOption(setting) {
147
+ if (setting.toolbox?.show === false) return {show: false}
148
+
149
+ return {
150
+ right: 10,
151
+ top: 0,
152
+ feature: {
153
+ saveAsImage: {
154
+ show: setting.toolbox?.features?.saveAsImage?.show !== false,
155
+ title: '保存为图片',
156
+ pixelRatio: 2
157
+ },
158
+ dataView: {
159
+ show: setting.toolbox?.features?.dataView?.show !== false,
160
+ readOnly: true,
161
+ title: '数据视图'
162
+ },
163
+ magicType: {
164
+ show: setting.toolbox?.features?.magicType?.show !== false,
165
+ title: {line: '折线图', bar: '柱状图'},
166
+ type: ['line', 'bar']
167
+ },
168
+ restore: {
169
+ show: setting.toolbox?.features?.restore?.show !== false,
170
+ title: '还原'
116
171
  }
117
- : {type: 'value'}
172
+ }
173
+ }
118
174
  },
119
175
 
120
- getSeries(setting, tables) {
121
- return tables
122
- .filter(item => {
123
- const key = `${item.name}.${item.metricId}`
124
- console.log(key, setting.displayMetrics)
125
- return setting.displayMetrics.includes(key)
126
- })
127
- .map(table => ({
128
- name: table.metricName,
129
- type: 'bar',
130
- data: setting.revertAxis
131
- ? table.rows[0].values.map((value, index) => ({
132
- value,
133
- name: table.headers[index]
134
- }))
135
- : table.rows[0].values,
136
- barMaxWidth: setting.barMaxWidth,
137
- barMinWidth: setting.barMinWidth,
138
- label: {
139
- show: setting.label?.show || false,
140
- position: setting.label?.position || 'outside',
141
- formatter: setting.label?.formatter || '{@value}'
176
+ getXAxisOption(setting, tables) {
177
+ const isCategory = !setting.revertAxis
178
+ return {
179
+ type: isCategory ? 'category' : 'value',
180
+ data: isCategory ? tables[0]?.headers : undefined,
181
+ axisLabel: {
182
+ show: setting.xAxis?.axisLabel?.show !== false,
183
+ rotate: setting.xAxis?.axisLabel?.rotate || 0,
184
+ interval: setting.xAxis?.axisLabel?.interval || 0,
185
+ formatter: setting.xAxis?.axisLabel?.formatter
186
+ },
187
+ axisTick: {
188
+ show: setting.xAxis?.axisTick?.show !== false,
189
+ alignWithLabel: true
190
+ },
191
+ axisLine: {
192
+ show: setting.xAxis?.axisLine?.show !== false
193
+ },
194
+ splitLine: {
195
+ show: setting.xAxis?.splitLine?.show || false
196
+ }
197
+ }
198
+ },
199
+
200
+ getYAxisOption(setting, tables) {
201
+ const isValue = !setting.revertAxis
202
+ return {
203
+ type: isValue ? 'value' : 'category',
204
+ data: isValue ? undefined : tables[0]?.headers,
205
+ axisLabel: {
206
+ show: setting.yAxis?.axisLabel?.show !== false,
207
+ formatter: isValue
208
+ ? setting.yAxis?.axisLabel?.formatter || (val => (val >= 10000 ? `${(val / 10000).toFixed(1)}万` : val))
209
+ : undefined
210
+ },
211
+ axisTick: {
212
+ show: setting.yAxis?.axisTick?.show !== false
213
+ },
214
+ axisLine: {
215
+ show: setting.yAxis?.axisLine?.show !== false
216
+ },
217
+ splitLine: {
218
+ show: setting.yAxis?.splitLine?.show !== false,
219
+ lineStyle: {
220
+ type: 'dashed'
142
221
  }
143
- }))
222
+ }
223
+ }
224
+ },
225
+
226
+ getSeries(setting, tables) {
227
+ const visibleTables = setting.displayMetrics
228
+ ? tables.filter(table => setting.displayMetrics.includes(`${table.name}.${table.metricId}`))
229
+ : tables
230
+
231
+ return visibleTables.map(table => ({
232
+ name: table.metricName,
233
+ type: 'bar',
234
+ // barWidth: setting.barWidth || '60%',
235
+ barGap: setting.barGap || '30%',
236
+ barCategoryGap: setting.barCategoryGap || '30%',
237
+ data: table.rows[0].values.map((value, idx) => ({
238
+ value,
239
+ name: table.headers[idx]
240
+ })),
241
+ label: {
242
+ show: setting.label?.show || false,
243
+ position: setting.label?.position || 'top',
244
+ formatter: setting.label?.formatter || '{@value}',
245
+ fontSize: setting.label?.fontSize || 12
246
+ },
247
+ itemStyle: {
248
+ borderRadius: setting.itemStyle?.borderRadius || 0,
249
+ opacity: setting.itemStyle?.opacity || 1
250
+ },
251
+ showBackground: setting.showBackground || false,
252
+ backgroundStyle: {
253
+ color: 'rgba(180, 180, 180, 0.2)'
254
+ }
255
+ }))
256
+ },
257
+
258
+ getDataZoomOption(setting) {
259
+ if (!setting.dataZoom?.show) return undefined
260
+
261
+ return [
262
+ {
263
+ type: 'slider',
264
+ show: true,
265
+ start: setting.dataZoom?.start || 0,
266
+ end: setting.dataZoom?.end || 100,
267
+ ...setting.dataZoom
268
+ }
269
+ ]
270
+ },
271
+
272
+ getDefaultColors() {
273
+ return ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc']
144
274
  }
145
275
  }
146
276
  }
@@ -148,6 +278,8 @@ export default {
148
278
 
149
279
  <style scoped>
150
280
  .chart {
281
+ background-color: var(--el-bg-color-overlay);
282
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.0509803922);
151
283
  width: 100%;
152
284
  height: 100%;
153
285
  }
@@ -165,6 +165,8 @@ export default {
165
165
 
166
166
  <style scoped>
167
167
  .chart {
168
+ background-color: var(--el-bg-color-overlay);
169
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.0509803922);
168
170
  width: 100%;
169
171
  height: 100%;
170
172
 
@@ -163,6 +163,8 @@ export default {
163
163
 
164
164
  <style scoped>
165
165
  .chart {
166
+ background-color: var(--el-bg-color-overlay);
167
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.0509803922);
166
168
  width: 100%;
167
169
  height: 100%;
168
170
 
@@ -250,6 +250,8 @@ export default {
250
250
 
251
251
  <style scoped>
252
252
  .chart {
253
+ background-color: var(--el-bg-color-overlay);
254
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.0509803922);
253
255
  width: 100%;
254
256
  height: 100%;
255
257
  }
@@ -171,6 +171,8 @@ export default {
171
171
 
172
172
  <style scoped>
173
173
  .chart {
174
+ background-color: var(--el-bg-color-overlay);
175
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.0509803922);
174
176
  width: 100%;
175
177
  height: 100%;
176
178
 
@@ -14,12 +14,12 @@
14
14
  </el-tooltip>
15
15
 
16
16
  <strong class="title"
17
- style="{ color: item.color }">{{ item.index }}</strong>
17
+ :style="{ color: item.color }">{{ item.index }}</strong>
18
18
  </div>
19
19
  </template>
20
20
  </el-statistic>
21
21
 
22
- <div class="statistic-footer">
22
+ <!-- <div class="statistic-footer">
23
23
  <span>{{ item.subtitle }}</span>
24
24
  <div :style="{ color: item.percentage >= 0 ? '#BF1220' : '#00B78B' }">
25
25
  <el-icon v-if="item.percentage >= 0"
@@ -28,7 +28,7 @@
28
28
  class="icon-down"><el-icon-bottom /></el-icon>
29
29
  {{ Math.abs(item.percentage) }}%
30
30
  </div>
31
- </div>
31
+ </div> -->
32
32
  </div>
33
33
  </template>
34
34
 
@@ -57,7 +57,7 @@ export default {
57
57
  tables.forEach((table, index) => {
58
58
  table.headers.forEach((x, xIndex) => {
59
59
  result.push({
60
- title: setting?.title?.text || table.metricName,
60
+ title: `${setting?.title?.text || table.metricName} ${table?.unitName ? `(${table.unitName})` : ''}`,
61
61
  index: x,
62
62
  color: setting.color[xIndex],
63
63
  subtitle: '环比上期',
@@ -83,33 +83,31 @@ export default {
83
83
  </script>
84
84
 
85
85
  <style lang="scss" scoped>
86
-
87
-
88
86
  .chart-title-card {
89
- padding: 20px;
90
-
87
+ padding: 15px;
88
+ flex: 1;
91
89
  border-radius: 5px;
92
- min-height: 135px;
90
+ min-height: 110px;
93
91
  height: 100%;
94
- max-height: 200px;
95
- max-width: 300px;
92
+ max-height: 110px;
93
+ // max-width: 300px;
96
94
  width: 100%;
97
- min-width: 240px;
95
+ min-width: 30%;
98
96
  display: flex;
99
97
  flex-direction: column;
100
- justify-content: space-between
101
- }
102
- :global(h2#card-usage ~ .example .example-showcase) {
103
- background-color: var(--el-fill-color) !important;
98
+ justify-content: space-between;
99
+ background-color: var(--el-bg-color-overlay);
100
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.0509803922);
104
101
  }
105
-
106
- .el-statistic {
107
- --el-statistic-content-font-size: 28px;
102
+ :deep(.el-statistic__number) {
103
+ line-height: 50px;
104
+ font-size: 40px;
108
105
  }
109
106
  .title-container {
110
107
  position: relative;
108
+ font-size: 14px;
111
109
  .title {
112
- font-size: 16px;
110
+ font-size: 17px;
113
111
  position: absolute;
114
112
  right: 0;
115
113
  }
@@ -154,6 +154,8 @@ export default {
154
154
 
155
155
  <style scoped>
156
156
  .chart {
157
+ background-color: var(--el-bg-color-overlay);
158
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.0509803922);
157
159
  width: 100%;
158
160
  height: 100%;
159
161
 
@@ -173,6 +173,8 @@ export default {
173
173
 
174
174
  <style scoped>
175
175
  .chart {
176
+ background-color: var(--el-bg-color-overlay);
177
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.0509803922);
176
178
  width: 100%;
177
179
  height: 100%;
178
180
 
@@ -29,6 +29,7 @@
29
29
  <el-pagination :current-page="currentPage"
30
30
  :page-sizes="pageSizes"
31
31
  :page-size="pageSize"
32
+ size="small"
32
33
  layout="total, sizes, prev, pager, next, jumper"
33
34
  :total="total"
34
35
  @size-change="handleSizeChange"
@@ -128,8 +129,9 @@ export default {
128
129
  width: 100%;
129
130
  }
130
131
  .pagination-container {
131
- margin-top: 16px;
132
+ margin-top: 10px;
132
133
  display: flex;
133
134
  justify-content: flex-end;
135
+ padding-right: 10px;
134
136
  }
135
137
  </style>
@@ -247,6 +247,8 @@ export default {
247
247
 
248
248
  <style scoped>
249
249
  .chart {
250
+ background-color: var(--el-bg-color-overlay);
251
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.0509803922);
250
252
  width: 100%;
251
253
  height: 100%;
252
254
  }