Переглянути джерело

refactor(chart): 统一优化图表样式与布局

调整多处图表的图例配置、内边距和容器高度,优化展示效果;修正部门档案页面的得分标题文案,注释无用的原生图例布局代码
huoyi 1 тиждень тому
батько
коміт
9409954aaf

+ 6 - 1
src/pages/components/AreaDistribution.vue

@@ -50,11 +50,16 @@ export default {
50 50
           trigger: 'axis',
51 51
           axisPointer: { type: 'shadow' }
52 52
         },
53
+        legend: {
54
+          data: ['查获数量'],
55
+          textStyle: { color: '#666', fontSize: 10 },
56
+          top: 0
57
+        },
53 58
         grid: {
54 59
           left: '15%',
55 60
           right: '5%',
56 61
           bottom: '15%',
57
-          top: '10%'
62
+          top: '22%'
58 63
         },
59 64
         xAxis: {
60 65
           type: 'category',

+ 7 - 1
src/pages/components/DailySeizureChart.vue

@@ -81,11 +81,16 @@ export default {
81 81
           trigger: 'axis',
82 82
           axisPointer: { type: 'shadow' }
83 83
         },
84
+        legend: {
85
+          data: ['查获总数'],
86
+          textStyle: { color: '#666', fontSize: 10 },
87
+          top: 0
88
+        },
84 89
         grid: {
85 90
           left: '10%',
86 91
           right: '5%',
87 92
           bottom: '18%',
88
-          top: '10%'
93
+          top: '22%'
89 94
         },
90 95
         xAxis: {
91 96
           type: 'category',
@@ -166,6 +171,7 @@ export default {
166 171
           axisPointer: { type: 'shadow' }
167 172
         },
168 173
         legend: {
174
+          type:'scroll',
169 175
           data: (this.chartsData.dept.deptData || []).map(d => d.name),
170 176
           textStyle: {
171 177
             color: '#333',

+ 6 - 1
src/pages/components/InterceptionDistribution.vue

@@ -45,11 +45,16 @@ export default {
45 45
             const option = {
46 46
                 responsive: true,
47 47
                 maintainAspectRatio: false,
48
+                legend: {
49
+                    data: ['拦截数量'],
50
+                    textStyle: { color: '#666', fontSize: 10 },
51
+                    top: 0
52
+                },
48 53
                 grid: {
49 54
                     left: '25%',
50 55
                     right: '10%',
51 56
                     bottom: '10%',
52
-                    top: '10%'
57
+                    top: '22%'
53 58
                 },
54 59
                 xAxis: {
55 60
                     type: 'value',

+ 10 - 4
src/pages/components/ItemDistribution.vue

@@ -1,12 +1,12 @@
1 1
 <template>
2 2
   <div class="item-distribution">
3 3
     <div class="chart-container" ref="itemChart"></div>
4
-    <div class="legend-grid">
4
+    <!-- <div class="legend-grid">
5 5
       <div v-for="(item, index) in chartsData.items" :key="index" class="legend-item">
6 6
         <div class="legend-dot" :style="{ backgroundColor: item.color }"></div>
7 7
         <div class="legend-text">{{ item.name }}: {{ item.value }}</div>
8 8
       </div>
9
-    </div>
9
+    </div> -->
10 10
   </div>
11 11
 </template>
12 12
 
@@ -57,9 +57,15 @@ export default {
57 57
           trigger: 'item',
58 58
           formatter: '{b}: {c} ({d}%)'
59 59
         },
60
+        legend: {
61
+          type: 'scroll',
62
+          data: this.chartsData.items.map(item => item.name),
63
+          textStyle: { color: '#666', fontSize: 10 },
64
+          top: 0
65
+        },
60 66
         series: [{
61 67
           type: 'pie',
62
-          radius: ['50%', '70%'],
68
+          radius: ['30%', '47%'],
63 69
           data: this.chartsData.items.map(item => ({
64 70
             name: item.name,
65 71
             value: item.value,
@@ -90,7 +96,7 @@ export default {
90 96
 <style lang="scss" scoped>
91 97
 .item-distribution {
92 98
   .chart-container {
93
-    height: 300rpx;
99
+    height: 450rpx;
94 100
   }
95 101
 
96 102
   .legend-grid {

+ 26 - 10
src/pages/components/MemberBasicDistribution.vue

@@ -75,9 +75,14 @@ export default {
75 75
           trigger: 'item',
76 76
           formatter: '{b}: {c} ({d}%)'
77 77
         },
78
+        legend: {
79
+          data: this.chartsData.gender.labels,
80
+          textStyle: { color: '#666', fontSize: 10 },
81
+          top: 0
82
+        },
78 83
         series: [{
79 84
           type: 'pie',
80
-          radius: ['40%', '60%'],
85
+          radius: ['25%', '40%'],
81 86
           data: this.chartsData.gender.data.map((value, index) => ({
82 87
             name: this.chartsData.gender.labels[index],
83 88
             value: value
@@ -108,19 +113,25 @@ export default {
108 113
           trigger: 'item',
109 114
           formatter: '{b}: {c} ({d}%)'
110 115
         },
116
+        legend: {
117
+          type: 'scroll',
118
+          data: this.chartsData.ethnicity.labels,
119
+          textStyle: { color: '#666', fontSize: 10 },
120
+          top: 0
121
+        },
111 122
         series: [{
112 123
           type: 'pie',
113
-          radius: ['40%', '60%'],
124
+          radius: ['25%', '40%'],
114 125
           data: this.chartsData.ethnicity.data.map((value, index) => ({
115 126
             name: this.chartsData.ethnicity.labels[index],
116 127
             value: value
117 128
           })),
118
-          itemStyle: {
119
-            color: function(params) {
120
-              const colors = ['#A78BFA', '#34D399']
121
-              return colors[params.dataIndex]
122
-            }
123
-          },
129
+          // itemStyle: {
130
+          //   color: function(params) {
131
+          //     const colors = ['#A78BFA', '#34D399']
132
+          //     return colors[params.dataIndex]
133
+          //   }
134
+          // },
124 135
           label: {
125 136
             show: true,
126 137
             color: '#333',
@@ -141,9 +152,14 @@ export default {
141 152
           trigger: 'item',
142 153
           formatter: '{b}: {c} ({d}%)'
143 154
         },
155
+        legend: {
156
+          data: this.chartsData.political.labels,
157
+          textStyle: { color: '#666', fontSize: 10 },
158
+          top: 0
159
+        },
144 160
         series: [{
145 161
           type: 'pie',
146
-          radius: ['40%', '60%'],
162
+          radius: ['25%', '40%'],
147 163
           data: this.chartsData.political.data.map((value, index) => ({
148 164
             name: this.chartsData.political.labels[index],
149 165
             value: value
@@ -195,7 +211,7 @@ export default {
195 211
 
196 212
     .chart-container {
197 213
       flex: 1;
198
-      height:250rpx;
214
+      height:450rpx;
199 215
     }
200 216
   }
201 217
 }

+ 18 - 3
src/pages/components/MemberPositionDistribution.vue

@@ -73,11 +73,16 @@ export default {
73 73
           trigger: 'axis',
74 74
           axisPointer: { type: 'shadow' }
75 75
         },
76
+        legend: {
77
+          data: ['人数'],
78
+          textStyle: { color: '#666', fontSize: 10 },
79
+          top: 0
80
+        },
76 81
         grid: {
77 82
           left: '10%',
78 83
           right: '5%',
79 84
           bottom: '14%',
80
-          top: '10%'
85
+          top: '22%'
81 86
         },
82 87
         xAxis: {
83 88
           type: 'category',
@@ -144,11 +149,16 @@ export default {
144 149
           trigger: 'axis',
145 150
           axisPointer: { type: 'shadow' }
146 151
         },
152
+        legend: {
153
+          data: ['人数'],
154
+          textStyle: { color: '#666', fontSize: 10 },
155
+          top: 0
156
+        },
147 157
         grid: {
148 158
           left: '10%',
149 159
           right: '5%',
150 160
           bottom: '14%',
151
-          top: '10%'
161
+          top: '22%'
152 162
         },
153 163
         xAxis: {
154 164
           type: 'category',
@@ -215,11 +225,16 @@ export default {
215 225
           trigger: 'axis',
216 226
           axisPointer: { type: 'shadow' }
217 227
         },
228
+        legend: {
229
+          data: ['人数'],
230
+          textStyle: { color: '#666', fontSize: 10 },
231
+          top: 0
232
+        },
218 233
         grid: {
219 234
           left: '10%',
220 235
           right: '5%',
221 236
           bottom: '20%',
222
-          top: '10%'
237
+          top: '22%'
223 238
         },
224 239
         xAxis: {
225 240
           type: 'category',

+ 21 - 3
src/pages/components/SecurityTestCharts.vue

@@ -83,9 +83,15 @@ export default {
83 83
           trigger: 'item',
84 84
           formatter: '{b}: {c} ({d}%)'
85 85
         },
86
+        legend: {
87
+          type: 'scroll',
88
+          data: this.chartsData.items.labels,
89
+          textStyle: { color: '#666', fontSize: 10 },
90
+          top: 0
91
+        },
86 92
         series: [{
87 93
           type: 'pie',
88
-          radius: ['50%', '70%'],
94
+          radius: ['30%', '40%'],
89 95
           data: this.chartsData.items.labels.map((label, index) => ({
90 96
             name: label,
91 97
             value: this.chartsData.items.data[index]
@@ -112,13 +118,19 @@ export default {
112 118
       const option = {
113 119
         responsive: true,
114 120
         maintainAspectRatio: false,
121
+        legend: {
122
+          type: 'scroll',
123
+          data: this.chartsData.results.labels,
124
+          textStyle: { color: '#666', fontSize: 10 },
125
+          top: 0
126
+        },
115 127
         tooltip: {
116 128
           trigger: 'item',
117 129
           formatter: '{b}: {c} ({d}%)'
118 130
         },
119 131
         series: [{
120 132
           type: 'pie',
121
-          radius: ['50%', '70%'],
133
+          radius: ['30%', '40%'],
122 134
           data: this.chartsData.results.labels.map((label, index) => ({
123 135
             name: label,
124 136
             value: this.chartsData.results.data[index]
@@ -149,9 +161,15 @@ export default {
149 161
           trigger: 'item',
150 162
           formatter: '{b}: {c} ({d}%)'
151 163
         },
164
+        legend: {
165
+          type: 'scroll',
166
+          data: this.chartsData.areas.labels,
167
+          textStyle: { color: '#666', fontSize: 10 },
168
+          top: 0
169
+        },
152 170
         series: [{
153 171
           type: 'pie',
154
-          radius: ['50%', '70%'],
172
+          radius: ['30%', '40%'],
155 173
           data: this.chartsData.areas.labels.map((label, index) => ({
156 174
             name: label,
157 175
             value: this.chartsData.areas.data[index]

+ 6 - 1
src/pages/components/SeizedNumAll.vue

@@ -47,7 +47,12 @@ export default {
47 47
                     left: '15%',
48 48
                     right: '5%',
49 49
                     bottom: '15%',
50
-                    top: '10%'
50
+                    top: '22%'
51
+                },
52
+                legend: {
53
+                    data: ['查获数'],
54
+                    textStyle: { color: '#666', fontSize: 10 },
55
+                    top: 0
51 56
                 },
52 57
                 xAxis: {
53 58
                     type: 'category',

+ 6 - 1
src/pages/components/SeizureInfo.vue

@@ -130,11 +130,16 @@ export default {
130 130
           trigger: 'axis',
131 131
           axisPointer: { type: 'shadow' }
132 132
         },
133
+        legend: {
134
+          data: ['查获数量'],
135
+          textStyle: { color: '#666', fontSize: 10 },
136
+          top: 0
137
+        },
133 138
         grid: {
134 139
           left: '15%',
135 140
           right: '5%',
136 141
           bottom: '15%',
137
-          top: '10%'
142
+          top: '22%'
138 143
         },
139 144
         xAxis: {
140 145
           type: 'category',

+ 6 - 1
src/pages/components/SupervisionDistribution.vue

@@ -47,7 +47,7 @@ export default {
47 47
                     left: '15%',
48 48
                     right: '5%',
49 49
                     bottom: '20%',
50
-                    top: '10%'
50
+                    top: '22%'
51 51
                 },
52 52
                 xAxis: {
53 53
                     type: 'category',
@@ -101,6 +101,11 @@ export default {
101 101
                         barWidth: '40%'
102 102
                     }
103 103
                 ],
104
+                legend: {
105
+                    data: ['查获数量'],
106
+                    textStyle: { color: '#666', fontSize: 10 },
107
+                    top: 0
108
+                },
104 109
                 tooltip: {
105 110
                     trigger: 'axis',
106 111
                     axisPointer: { type: 'shadow' }

+ 6 - 1
src/pages/components/UnsafeItemsChart.vue

@@ -61,6 +61,11 @@ export default {
61 61
           trigger: 'item',
62 62
           formatter: '{b}: {c} ({d}%)'
63 63
         },
64
+        legend: {
65
+          data: this.chartsData.items.map(item => item.name),
66
+          textStyle: { color: '#666', fontSize: 10 },
67
+          top: 0
68
+        },
64 69
         series: [{
65 70
           type: 'pie',
66 71
           radius: ['50%', '70%'],
@@ -94,7 +99,7 @@ export default {
94 99
 <style lang="scss" scoped>
95 100
 .unsafe-items-chart {
96 101
   .chart-container {
97
-    height: 220rpx;
102
+    height: 400rpx;
98 103
   }
99 104
 
100 105
   .items-list {

+ 7 - 2
src/pages/components/UnsafePositionChart.vue

@@ -56,11 +56,16 @@ export default {
56 56
           trigger: 'axis',
57 57
           axisPointer: { type: 'shadow' }
58 58
         },
59
+        legend: {
60
+          data: ['人数'],
61
+          textStyle: { color: '#666', fontSize: 10 },
62
+          top: 0
63
+        },
59 64
         grid: {
60 65
           left: '15%',
61 66
           right: '5%',
62 67
           bottom: '15%',
63
-          top: '10%'
68
+          top: '22%'
64 69
         },
65 70
         xAxis: {
66 71
           type: 'category',
@@ -126,7 +131,7 @@ export default {
126 131
 <style lang="scss" scoped>
127 132
 .unsafe-position-chart {
128 133
   .chart-container {
129
-    height: 240rpx;
134
+    height: 400rpx;
130 135
   }
131 136
 
132 137
   .position-info {

+ 6 - 1
src/pages/components/UnsafeTypesChart.vue

@@ -61,6 +61,11 @@ export default {
61 61
           trigger: 'item',
62 62
           formatter: '{b}: {c} ({d}%)'
63 63
         },
64
+        legend: {
65
+          data: this.chartsData.types.map(item => item.name),
66
+          textStyle: { color: '#666', fontSize: 10 },
67
+          top: 0
68
+        },
64 69
         series: [{
65 70
           type: 'pie',
66 71
           radius: ['50%', '70%'],
@@ -94,7 +99,7 @@ export default {
94 99
 <style lang="scss" scoped>
95 100
 .unsafe-types-chart {
96 101
   .chart-container {
97
-    height: 220rpx;
102
+    height: 400rpx;
98 103
   }
99 104
 
100 105
   .types-list {

+ 1 - 1
src/pages/deptProfile/index.vue

@@ -59,7 +59,7 @@
59 59
             </SectionTitle>
60 60
 
61 61
             <view v-if="activeTab === 'profile'">
62
-                <SectionTitle title="维得分一览">
62
+                <SectionTitle title="维得分一览">
63 63
                     <ProfileRadar :chartsData="radarData" />
64 64
                 </SectionTitle>
65 65