当前位置:   article > 正文

【Vue3】 echarts雷达图 [文字标题过长显示不全]_雷达图设置文字宽度不生效

雷达图设置文字宽度不生效

1、代码

  1. <template>
  2. <!-- 双预防运行结果 -->
  3. <div style="width: 1400px; height: 1000px; display: flex; padding: 0 10px">
  4. <v-chart :option="option" autoresize style="width: 85%;margin-right: 30px;" />
  5. </div>
  6. </template>
  7. <script lang="ts">
  8. export default {
  9. name: 'DualPreventionOperation',
  10. }
  11. </script>
  12. <script lang="ts" setup>
  13. import { useDataStatus, dialogTypeEnum } from '@/stores/dialog/data-status'
  14. import VChart from 'vue-echarts'
  15. const dataStatus = useDataStatus()
  16. onMounted(() => {
  17. })
  18. const obj = dataStatus.dialogMap.get(dialogTypeEnum.prevention_operation).condition?.row
  19. //visualMap 填充色对比 最大值
  20. const option = ref(
  21. {
  22. backgroundColor: 'rgb(30, 36, 50)',
  23. tooltip: {
  24. 'show': true,
  25. 'trigger': 'item',
  26. },
  27. radar: {
  28. // shape: 'circle',
  29. radius: '65%',
  30. name: {
  31. textStyle: {
  32. color: '#fff',
  33. //backgroundColor: '#999',
  34. borderRadius: 3,
  35. padding: [-10, -10],
  36. fontSize: 20
  37. },
  38. formatter: function (value) {
  39. let list = value.split("");
  40. console.log(list);
  41. let result = "";
  42. for (let i = 1; i <= list.length; i++) {
  43. if (!(i % 7) && list[i] != undefined) {
  44. result += list[i - 1] + '\n';
  45. } else {
  46. result += list[i - 1];
  47. }
  48. }
  49. return result;
  50. },
  51. },
  52. axisLine: {
  53. lineStyle: {
  54. color: '#1968a0',
  55. width: 1,
  56. type: 'solid'
  57. },
  58. },
  59. splitArea: {
  60. areaStyle: {
  61. color: ['rgba(40,203,228,0.3)', 'rgb(30, 36, 50,0.7)']
  62. }
  63. },
  64. splitLine: {
  65. lineStyle: {
  66. color: ['#74e7f0', '#74e7f0', '#74e7f0', '#74e7f0'],
  67. width: 1
  68. }
  69. },
  70. indicator: [{
  71. text: '风险分析完成率',
  72. }, {
  73. text: '隐患整改率',
  74. }, {
  75. text: '排查任务完成率',
  76. },
  77. ]
  78. },
  79. series: [{
  80. name: '双预防运行结果',
  81. type: 'radar',
  82. symbol: 'circle',
  83. symbolSize: 3,
  84. areaStyle: {
  85. normal: {
  86. color: 'rgba(103,194,58,0.3)',
  87. fontSize: 24
  88. },
  89. },
  90. itemStyle: {
  91. color: 'rgba(103,194,58,.7)',
  92. borderColor: 'rgba(103,194,58,.5)',
  93. borderWidth: 5,
  94. },
  95. data: [
  96. {
  97. value: [obj.num9, obj.num10, obj.num11],
  98. name: '双预防运行结果'
  99. }],
  100. }]
  101. }
  102. )
  103. </script>
  104. <style lang="scss" scoped></style>

注意:

1)、文字显示不全

        解决:

           <1>、radius: '65%',   // 设置这个文字少的情况下可解决

           <2>、上诉代码formatter这个方法,可解决文字过长进行换行展示

2)、indicator中可以设置max值

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/91726
推荐阅读
相关标签
  

闽ICP备14008679号