Radar.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div id="radar"></div>
  3. </template>
  4. <script>
  5. import { ref, onMounted, computed } from "vue";
  6. import { mapState } from "vuex";
  7. export default {
  8. setup() {
  9. let echarts = inject("ec");
  10. let radartDom = ref({});
  11. let radarChart = ref({});
  12. function init() {
  13. radartDom.value = document.getElementById("radar");
  14. radarChart.value = echarts.init(radartDom, "dark");
  15. radarChart.value.setOption(option.value);
  16. }
  17. function exchangeUrl(icon) {
  18. return `/${icon}.png`;
  19. }
  20. let option = ref({
  21. title: {},
  22. legend: {},
  23. radar: {
  24. // shape: 'circle',
  25. indicator: [
  26. { name: "数据1", max: 6500 },
  27. { name: "数据2", max: 16000 },
  28. { name: "数据3", max: 30000 },
  29. { name: "数据4", max: 38000 },
  30. { name: "数据5", max: 52000 },
  31. ],
  32. axisLine: {
  33. // (圆内的几条直线)坐标轴轴线相关设置
  34. lineStyle: {
  35. color: "#45FAFF",
  36. // 坐标轴线线的颜色。
  37. width: 2,
  38. // 坐标轴线线宽。
  39. type: "solid",
  40. // 坐标轴线线的类型。
  41. },
  42. },
  43. splitLine: {
  44. // (这里是指所有圆环)坐标轴在 grid 区域中的分隔线。
  45. lineStyle: {
  46. color: "#45FAFF",
  47. // 分隔线颜色
  48. width: 2,
  49. // 分隔线线宽
  50. },
  51. },
  52. splitArea: {
  53. // 坐标轴在 grid 区域中的分隔区域,默认不显示。
  54. show: true,
  55. areaStyle: {
  56. // 分隔区域的样式设置。
  57. color: ["rgba(250,250,250,0)", "rgba(200,200,200,0)"],
  58. // 分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
  59. },
  60. },
  61. },
  62. series: [
  63. {
  64. name: "Budget vs spending",
  65. type: "radar",
  66. data: [
  67. {
  68. value: [4200, 3000, 20000, 35000, 50000],
  69. },
  70. ],
  71. areaStyle: {
  72. // 单项区域填充样式
  73. normal: {
  74. color: "rgb(69,250,255)", // 填充的颜色。[ default: "#000" ]
  75. },
  76. },
  77. },
  78. ],
  79. });
  80. onMounted(() => {
  81. init();
  82. });
  83. return {
  84. init,
  85. exchangeUrl,
  86. };
  87. },
  88. };
  89. </script>
  90. <style lang="scss" scoped>
  91. </style>