index3.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <el-row>
  3. <div id="index1" ref="echartD" style="width:100%;height:300px;"></div>
  4. </el-row>
  5. </template>
  6. <script>
  7. import * as echarts from "echarts";
  8. export default {
  9. props: ["resData"],
  10. data() {
  11. return {};
  12. },
  13. watch: {
  14. resData() {
  15. this.getData();
  16. },
  17. },
  18. mounted() {
  19. this.getData();
  20. },
  21. methods: {
  22. getData() {
  23. setTimeout(() =>{
  24. let data = this.resData
  25. echarts.init(this.$refs.echartD).setOption({
  26. series: [
  27. // 进度条
  28. {
  29. name: "仪表盘",
  30. type: "gauge",
  31. radius: "55%", // 半径
  32. startAngle: 270, //开始角度 左侧角度
  33. endAngle: -89.999, //结束角度 右侧
  34. splitNumber: 30,
  35. axisLine: {
  36. lineStyle: {
  37. color: [
  38. [0, "#80FFA5"],
  39. [1, "#FF5801"],
  40. ],
  41. width: 10,
  42. },
  43. },
  44. axisLabel: {
  45. show: false,
  46. },
  47. axisTick: {
  48. show: false,
  49. },
  50. splitLine: {
  51. show: false,
  52. },
  53. itemStyle: {
  54. show: false,
  55. },
  56. detail: {
  57. formatter: () => {
  58. return `电量:${data.dianliang}%\n信号:${data.xinhao}`;
  59. },
  60. offsetCenter: [0, "0%"],
  61. textStyle: {
  62. fontSize: 16,
  63. fontWeight: "700",
  64. height:20,
  65. color:"#80FFA5",
  66. fontFamily: '"DS", "DS-B", "DS-BB", "DS-BS"',
  67. },
  68. },
  69. title: {
  70. offsetCenter: [0, "10%"],
  71. },
  72. pointer: {
  73. show: false,
  74. },
  75. data: [
  76. (`电量:${data.dianliang}%\n信号:${data.xinhao}`),
  77. ],
  78. },
  79. ],
  80. })
  81. window.addEventListener("resize", function() {
  82. myChart.resize();
  83. });
  84. },1000)
  85. },
  86. }
  87. };
  88. </script>
  89. <style lang="scss" scoped></style>