ratio.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div id="ratio_echart" ref="echart"></div>
  3. </template>
  4. <script>
  5. let option = {
  6. title: [
  7. {
  8. text: "rate",
  9. x: "center",
  10. y: "35%",
  11. textStyle: {
  12. fontSize: 16,
  13. color: "#fff",
  14. fontWeight: "bold",
  15. },
  16. },
  17. {
  18. text: "关联率",
  19. x: "center",
  20. y: "55%",
  21. borderColor: "#fff",
  22. textStyle: {
  23. fontWeight: "normal",
  24. fontSize: 12,
  25. color: "#fff",
  26. },
  27. },
  28. ],
  29. polar: {
  30. center: ["50%", "55%"],
  31. radius: ["65%", "95%"],
  32. },
  33. angleAxis: {
  34. max: 100,
  35. startAngle: 180,
  36. show: false,
  37. },
  38. radiusAxis: {
  39. type: "category",
  40. show: true,
  41. axisLabel: {
  42. show: false,
  43. },
  44. axisLine: {
  45. show: false,
  46. },
  47. axisTick: {
  48. show: false,
  49. },
  50. },
  51. series: [
  52. {
  53. data: [80],
  54. name: "",
  55. type: "bar",
  56. roundCap: true,
  57. showBackground: true,
  58. // backgroundStyle: {
  59. // color: 'rgba(19, 84, 146, .4)',
  60. // },
  61. coordinateSystem: "polar",
  62. itemStyle: {
  63. normal: {
  64. color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
  65. {
  66. offset: 0,
  67. color: "#005DCF",
  68. },
  69. {
  70. offset: 1,
  71. color: "#00CCFF",
  72. },
  73. ]),
  74. },
  75. },
  76. },
  77. ],
  78. };
  79. export default {
  80. name: "ratio_echart",
  81. components: {},
  82. data() {
  83. return {
  84. myChart: null,
  85. };
  86. },
  87. methods: {
  88. setOptions(cartData) {
  89. if (!this.myChart) {
  90. // var dom = document.getElementById("ratio_echart");
  91. this.myChart = echarts.init(this.$refs.echart);
  92. }
  93. option.title[0].text = cartData.ratio + "%";
  94. option.title[1].text = cartData.name;
  95. option.series.data = [cartData.ratio];
  96. this.myChart.resize();
  97. this.myChart.setOption(option);
  98. },
  99. },
  100. mounted() {
  101. // this.setOptions();
  102. },
  103. };
  104. </script>
  105. <style lang="scss" scoped>
  106. .ratio_echart {
  107. width: 100%;
  108. height: 100%;
  109. }
  110. </style>