浏览代码

feat(图表组件): 为饼图添加图例并优化排名列表样式

为多个模块的饼图组件添加图例配置,包括数据映射、位置和字体大小
在RankList组件中新增getItemClass方法实现隔行灰色背景效果
移除ModuleBrigadeOne中未使用的图表配置函数
huoyi 1 月之前
父节点
当前提交
e4c07891ac

+ 0 - 19
src/views/blockingData/blockingDataScreen/components/ModuleBrigadeOne.vue

@@ -225,26 +225,7 @@ const multiLineChartOption = (xAxisData, series) => ({
225
   }))
225
   }))
226
 })
226
 })
227
 
227
 
228
-const lineChartOption = (data, color, title) => ({
229
-  grid: { left: '10%', top: '15%', right: '5%', bottom: '15%', containLabel: true },
230
-  xAxis: { type: 'category', data: xAxisData, axisLine: { lineStyle: { color: '#999' } }, axisLabel: { fontSize: 10, color: '#666' } },
231
-  yAxis: { type: 'value', axisLine: { lineStyle: { color: '#999' } }, axisLabel: { fontSize: 10, color: '#666' }, splitLine: { lineStyle: { color: '#eee' } } },
232
-  series: [{ name: title, type: 'line', smooth: true, symbol: 'circle', symbolSize: 6, data: data, itemStyle: { color: color }, lineStyle: { color: color } }]
233
-})
234
 
228
 
235
-const areaChartOption = (data, color) => ({
236
-  grid: { left: '10%', top: '15%', right: '5%', bottom: '15%', containLabel: true },
237
-  xAxis: { type: 'category', data: xAxisData, axisLine: { lineStyle: { color: '#999' } }, axisLabel: { fontSize: 10, color: '#666' } },
238
-  yAxis: { type: 'value', axisLine: { lineStyle: { color: '#999' } }, axisLabel: { fontSize: 10, color: '#666' }, splitLine: { lineStyle: { color: '#eee' } } },
239
-  series: [{ type: 'line', smooth: true, symbol: 'circle', symbolSize: 6, data: data, itemStyle: { color: color }, lineStyle: { color: color }, areaStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: color + '40' }, { offset: 1, color: color + '10' }]) } }]
240
-})
241
-
242
-const barChartOption = (data, color) => ({
243
-  grid: { left: '15%', top: '15%', right: '5%', bottom: '15%', containLabel: true },
244
-  xAxis: { type: 'category', data: data.map(d => d.name), axisLine: { lineStyle: { color: '#999' } }, axisLabel: { fontSize: 10, color: '#666' } },
245
-  yAxis: { type: 'value', axisLine: { lineStyle: { color: '#999' } }, axisLabel: { fontSize: 10, color: '#666' }, splitLine: { lineStyle: { color: '#eee' } } },
246
-  series: [{ type: 'bar', data: data.map(d => d.value), itemStyle: { color: color }, barWidth: 20 }]
247
-})
248
 
229
 
249
 const horizontalBarChartOption = (data, color) => ({
230
 const horizontalBarChartOption = (data, color) => ({
250
   grid: { left: '20%', top: '15%', right: '5%', bottom: '15%', containLabel: true },
231
   grid: { left: '20%', top: '15%', right: '5%', bottom: '15%', containLabel: true },

+ 5 - 0
src/views/blockingData/blockingDataScreen/components/ModuleBrigadeThree.vue

@@ -99,6 +99,11 @@ watch(() => props.filterParams, () => {
99
 const ringChartOption = (data, colors) => ({
99
 const ringChartOption = (data, colors) => ({
100
   color: colors,
100
   color: colors,
101
   tooltip: { trigger: 'item', formatter: '{b}: {c}' },
101
   tooltip: { trigger: 'item', formatter: '{b}: {c}' },
102
+  legend: {
103
+    data: data.map(item => item.name),
104
+    top: '0%',
105
+    textStyle: { fontSize: 10 }
106
+  },
102
   series: [{
107
   series: [{
103
     type: 'pie',
108
     type: 'pie',
104
     radius: ['40%', '65%'],
109
     radius: ['40%', '65%'],

+ 10 - 0
src/views/blockingData/blockingDataScreen/components/ModuleBrigadeTwo.vue

@@ -322,6 +322,11 @@ watch(() => props.filterParams, () => {
322
 const pieChartOption = (data, colors) => ({
322
 const pieChartOption = (data, colors) => ({
323
   color: colors,
323
   color: colors,
324
   tooltip: { trigger: 'item', formatter: '{b}: {c}' },
324
   tooltip: { trigger: 'item', formatter: '{b}: {c}' },
325
+  legend: {
326
+    data: data.map(item => item.name),
327
+    top: '0%',
328
+    textStyle: { fontSize: 10 }
329
+  },
325
   series: [{
330
   series: [{
326
     type: 'pie',
331
     type: 'pie',
327
     radius: ['40%', '65%'],
332
     radius: ['40%', '65%'],
@@ -342,6 +347,11 @@ const pieChartOption = (data, colors) => ({
342
 const donutChartOption = (data, colors) => ({
347
 const donutChartOption = (data, colors) => ({
343
   color: colors,
348
   color: colors,
344
   tooltip: { trigger: 'item', formatter: '{b}: {c}' },
349
   tooltip: { trigger: 'item', formatter: '{b}: {c}' },
350
+  legend: {
351
+    data: data.map(item => item.name),
352
+    top: '0%',
353
+    textStyle: { fontSize: 10 }
354
+  },
345
   series: [{
355
   series: [{
346
     type: 'pie',
356
     type: 'pie',
347
     radius: ['30%', '55%'],
357
     radius: ['30%', '55%'],

+ 5 - 0
src/views/blockingData/blockingDataScreen/components/ModuleThree.vue

@@ -102,6 +102,11 @@ watch(() => props.filterParams, () => {
102
 
102
 
103
 const ringPieOption = (data, colors, centerOffset = ['50%', '55%']) => ({
103
 const ringPieOption = (data, colors, centerOffset = ['50%', '55%']) => ({
104
   color: colors,
104
   color: colors,
105
+  legend: {
106
+    data: data.map(item => item.name),
107
+    top: '0%',
108
+    textStyle: { fontSize: 10 }
109
+  },
105
   series: [{
110
   series: [{
106
     type: 'pie',
111
     type: 'pie',
107
     radius: ['45%', '70%'],
112
     radius: ['45%', '70%'],

+ 15 - 4
src/views/blockingData/blockingDataScreen/components/RankList.vue

@@ -6,7 +6,7 @@
6
       <span class="header-count">{{ headerCount }}</span>
6
       <span class="header-count">{{ headerCount }}</span>
7
     </div>
7
     </div>
8
     <div class="rank-list-body">
8
     <div class="rank-list-body">
9
-      <div v-for="(item, index) in rankData" :key="index" class="rank-item" :class="'rank-item-' + getRankClass(index)">
9
+      <div v-for="(item, index) in rankData" :key="index" class="rank-item" :class="getItemClass(index)">
10
         <span class="rank-number" :class="'rank-number-' + getRankClass(index)">NO.{{ index + 1 }}</span>
10
         <span class="rank-number" :class="'rank-number-' + getRankClass(index)">NO.{{ index + 1 }}</span>
11
         <div class="rank-info">
11
         <div class="rank-info">
12
           <span class="rank-name">{{ item.name }}</span>
12
           <span class="rank-name">{{ item.name }}</span>
@@ -61,6 +61,13 @@ const getRankClass = (index) => {
61
 const getProgressWidth = (value, max) => {
61
 const getProgressWidth = (value, max) => {
62
   return (value / max) * 100
62
   return (value / max) * 100
63
 }
63
 }
64
+
65
+const getItemClass = (index) => {
66
+  const baseClass = 'rank-item rank-item-' + getRankClass(index)
67
+  if (index < 3) return baseClass
68
+  const isGray = (index - 3) % 2 === 0
69
+  return baseClass + (isGray ? ' rank-item-gray' : '')
70
+}
64
 </script>
71
 </script>
65
 
72
 
66
 <style lang="less" scoped>
73
 <style lang="less" scoped>
@@ -80,7 +87,7 @@ const getProgressWidth = (value, max) => {
80
   align-items: center;
87
   align-items: center;
81
   padding: 8px;
88
   padding: 8px;
82
   border-bottom: 1px solid #e5e7eb;
89
   border-bottom: 1px solid #e5e7eb;
83
-  margin-bottom: 8px;
90
+ 
84
   flex-shrink: 0; /* 防止头部被压缩 */
91
   flex-shrink: 0; /* 防止头部被压缩 */
85
 }
92
 }
86
 
93
 
@@ -109,7 +116,7 @@ const getProgressWidth = (value, max) => {
109
 .rank-list-body {
116
 .rank-list-body {
110
   flex: 1;
117
   flex: 1;
111
   overflow-y: auto; /* 启用垂直滚动 */
118
   overflow-y: auto; /* 启用垂直滚动 */
112
-  padding: 0 8px 8px 8px;
119
+
113
   
120
   
114
   /* 自定义滚动条样式 */
121
   /* 自定义滚动条样式 */
115
   &::-webkit-scrollbar {
122
   &::-webkit-scrollbar {
@@ -136,7 +143,7 @@ const getProgressWidth = (value, max) => {
136
   align-items: center;
143
   align-items: center;
137
   padding: 10px;
144
   padding: 10px;
138
   border-radius: 4px;
145
   border-radius: 4px;
139
-  margin-bottom: 4px;
146
+  
140
   min-height: 40px; /* 最小高度确保项目可见 */
147
   min-height: 40px; /* 最小高度确保项目可见 */
141
 }
148
 }
142
 
149
 
@@ -160,6 +167,10 @@ const getProgressWidth = (value, max) => {
160
   background-color: #f9fafb;
167
   background-color: #f9fafb;
161
 }
168
 }
162
 
169
 
170
+.rank-item-gray {
171
+  background-color: #f3f4f6;
172
+}
173
+
163
 .rank-number {
174
 .rank-number {
164
   font-weight: bold;
175
   font-weight: bold;
165
   font-size: 15px;
176
   font-size: 15px;