Pārlūkot izejas kodu

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

为多个模块的饼图组件添加图例配置,包括数据映射、位置和字体大小
在RankList组件中新增getItemClass方法实现隔行灰色背景效果
移除ModuleBrigadeOne中未使用的图表配置函数
huoyi 1 mēnesi atpakaļ
vecāks
revīzija
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 230
 const horizontalBarChartOption = (data, color) => ({
250 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 99
 const ringChartOption = (data, colors) => ({
100 100
   color: colors,
101 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 107
   series: [{
103 108
     type: 'pie',
104 109
     radius: ['40%', '65%'],

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

@@ -322,6 +322,11 @@ watch(() => props.filterParams, () => {
322 322
 const pieChartOption = (data, colors) => ({
323 323
   color: colors,
324 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 330
   series: [{
326 331
     type: 'pie',
327 332
     radius: ['40%', '65%'],
@@ -342,6 +347,11 @@ const pieChartOption = (data, colors) => ({
342 347
 const donutChartOption = (data, colors) => ({
343 348
   color: colors,
344 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 355
   series: [{
346 356
     type: 'pie',
347 357
     radius: ['30%', '55%'],

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

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

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

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