ProfileRadar.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <InfoCard title="七维得分一览">
  3. <div class="radar-section">
  4. <div ref="radarChartRef" class="radar-chart"></div>
  5. <div class="radar-list">
  6. <div class="radar-item" v-for="(item, index) in computedRadarData" :key="index">
  7. <span class="item-label">{{ item.name }}</span>
  8. <div class="progress-row">
  9. <div class="progress-bar">
  10. <div class="progress-fill" :style="{ width: item.value + '%', background: `linear-gradient(to right, transparent, ${item.color})` }">
  11. <span class="progress-end"></span>
  12. </div>
  13. </div>
  14. <span class="item-value">{{ item.value }}</span>
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. </InfoCard>
  20. </template>
  21. <script setup>
  22. import { ref, computed, onMounted, onUnmounted, nextTick } from 'vue'
  23. import * as echarts from 'echarts'
  24. import InfoCard from './card.vue'
  25. const props = defineProps({
  26. chartData1: {
  27. type: Array,
  28. default: () => []
  29. },
  30. chartData2: {
  31. type: Array,
  32. default: () => []
  33. },
  34. chartData3: {
  35. type: Array,
  36. default: () => []
  37. },
  38. chartData4: {
  39. type: Array,
  40. default: () => []
  41. }
  42. })
  43. const defaultRadarData = [
  44. { name: '通道安全防控力', value: 86, color: '#00e5ff' },
  45. { name: '通道安全防控力', value: 90, color: '#00e5ff' },
  46. { name: '通道安全防控力', value: 72, color: '#ff4757' },
  47. { name: '通道安全防控力', value: 68, color: '#ff4757' },
  48. { name: '通道安全防控力', value: 78, color: '#3742fa' },
  49. { name: '通道安全防控力', value: 80, color: '#3742fa' },
  50. { name: '通道协同作战能力', value: 72, color: '#ff4757' }
  51. ]
  52. const defaultIndicators = [
  53. { name: '通道安全防控力', max: 100 },
  54. { name: '通道安全防控力', max: 100 },
  55. { name: '通道安全防控力', max: 100 },
  56. { name: '通道安全防控力', max: 100 },
  57. { name: '通道安全防控力', max: 100 },
  58. { name: '通道安全防控力', max: 100 },
  59. { name: '通道协同作战能力', max: 100 }
  60. ]
  61. const defaultSeries1 = [86, 90, 72, 68, 78, 80, 72]
  62. const defaultSeries2 = [80, 85, 65, 60, 72, 75, 68]
  63. const computedRadarData = computed(() => {
  64. return props.chartData1.length > 0 ? props.chartData1 : defaultRadarData
  65. })
  66. const radarChartRef = ref(null)
  67. let radarChart = null
  68. const initRadarChart = () => {
  69. if (!radarChartRef.value) return
  70. radarChart = echarts.init(radarChartRef.value)
  71. const indicators = props.chartData2.length > 0 ? props.chartData2 : defaultIndicators
  72. const series1 = props.chartData3.length > 0 ? props.chartData3 : defaultSeries1
  73. const series2 = props.chartData4.length > 0 ? props.chartData4 : defaultSeries2
  74. const option = {
  75. radar: {
  76. indicator: indicators,
  77. center: ['50%', '50%'],
  78. radius: '70%',
  79. splitNumber: 4,
  80. axisLine: {
  81. lineStyle: {
  82. color: 'rgba(15, 70, 250, 0.3)'
  83. }
  84. },
  85. splitArea: {
  86. areaStyle: {
  87. color: ['rgba(15, 70, 250, 0.05)', 'rgba(15, 70, 250, 0.1)', 'rgba(15, 70, 250, 0.15)', 'rgba(15, 70, 250, 0.2)']
  88. }
  89. },
  90. splitLine: {
  91. lineStyle: {
  92. color: 'rgba(15, 70, 250, 0.2)'
  93. }
  94. },
  95. name: {
  96. textStyle: {
  97. color: '#a0c4ff',
  98. fontSize: 11
  99. }
  100. }
  101. },
  102. series: [
  103. {
  104. type: 'radar',
  105. data: [
  106. {
  107. value: series1,
  108. name: '综合得分',
  109. areaStyle: {
  110. color: 'rgba(189, 3, 251, 0.3)'
  111. },
  112. lineStyle: {
  113. color: '#bd03fb',
  114. width: 2
  115. },
  116. itemStyle: {
  117. color: '#bd03fb'
  118. }
  119. },
  120. {
  121. value: series2,
  122. name: '基准值',
  123. areaStyle: {
  124. color: 'rgba(15, 70, 250, 0.2)'
  125. },
  126. lineStyle: {
  127. color: '#0f46fa',
  128. width: 2
  129. },
  130. itemStyle: {
  131. color: '#0f46fa'
  132. }
  133. }
  134. ],
  135. symbol: 'circle',
  136. symbolSize: 6
  137. }
  138. ],
  139. tooltip: {
  140. trigger: 'item',
  141. backgroundColor: 'rgba(13, 80, 122, 0.95)',
  142. borderColor: '#70CFE7',
  143. textStyle: {
  144. color: '#fff'
  145. }
  146. }
  147. }
  148. radarChart.setOption(option)
  149. }
  150. const handleResize = () => {
  151. if (radarChart) radarChart.resize()
  152. }
  153. onMounted(() => {
  154. nextTick(() => {
  155. setTimeout(() => {
  156. initRadarChart()
  157. window.addEventListener('resize', handleResize)
  158. }, 100)
  159. })
  160. })
  161. onUnmounted(() => {
  162. window.removeEventListener('resize', handleResize)
  163. if (radarChart) radarChart.dispose()
  164. })
  165. </script>
  166. <style lang="scss" scoped>
  167. .radar-section {
  168. display: flex;
  169. gap: 20px;
  170. min-height: 400px;
  171. .radar-chart {
  172. flex: 1;
  173. min-width: 300px;
  174. height: 380px;
  175. }
  176. .radar-list {
  177. flex: 1;
  178. display: flex;
  179. flex-direction: column;
  180. gap: 16px;
  181. padding: 10px 0;
  182. .radar-item {
  183. display: flex;
  184. flex-direction: column;
  185. gap: 6px;
  186. font-size: 13px;
  187. .item-label {
  188. color: #a0c4ff;
  189. }
  190. .progress-row {
  191. display: flex;
  192. align-items: center;
  193. gap: 10px;
  194. .progress-bar {
  195. flex: 1;
  196. height: 5px;
  197. background: rgba(255, 255, 255, 0.1);
  198. border-radius: 0;
  199. overflow: visible;
  200. .progress-fill {
  201. height: 100%;
  202. border-radius: 0;
  203. transition: width 0.3s ease;
  204. position: relative;
  205. .progress-end {
  206. position: absolute;
  207. right: -4px;
  208. top: 50%;
  209. transform: translateY(-50%);
  210. width: 3px;
  211. height: 9px;
  212. background: #fff;
  213. border-radius: 2px;
  214. }
  215. }
  216. }
  217. .item-value {
  218. width: 45px;
  219. text-align: right;
  220. color: #fff;
  221. font-weight: bold;
  222. font-size: 13px;
  223. }
  224. }
  225. }
  226. }
  227. }
  228. </style>