one.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div
  3. id="one"
  4. :style="{width: '100%', height: '100%'}"
  5. ></div>
  6. </template>
  7. <script type="text/ecmascript-6">
  8. export default {
  9. data() {
  10. return {
  11. chartInstance: null,
  12. allData: null, // 服务器返回的数据
  13. };
  14. },
  15. mounted() {
  16. this.initChart(); //函数调用
  17. // this.getData();
  18. this.updateChart();
  19. },
  20. methods: {
  21. initChart() {
  22. this.chartInstance = this.$echarts.init(
  23. document.getElementById("one")
  24. );
  25. },
  26. updateChart() {
  27. const option = {
  28. grid: {
  29. height: 200,
  30. left: 0,
  31. top: 0,
  32. bottom: 0,
  33. right: 0,
  34. },
  35. series: [
  36. {
  37. name: "仪表盘",
  38. type: "gauge",
  39. min: 0,
  40. max: 2500,
  41. splitNumber: 10,
  42. // "axisLine": {
  43. // "lineStyle": {
  44. // "color": [
  45. // [
  46. // 0.2,
  47. // "#5DD1FA"
  48. // ],
  49. // [
  50. // 1,
  51. // "#f7f9fc"
  52. // ]
  53. // ],
  54. // "width": 10
  55. // }
  56. // },
  57. axisLabel: {
  58. distance: -60,
  59. show: true,
  60. },
  61. axisTick: {
  62. show: true,
  63. },
  64. splitLine: {
  65. show: true,
  66. },
  67. itemStyle: {
  68. show: true,
  69. },
  70. title: {
  71. color: "#7f7f7f",
  72. fontSize: 16,
  73. fontWeight: "bolder",
  74. },
  75. detail: {
  76. offsetCenter: [0, 0],
  77. textStyle: {
  78. fontSize: "18",
  79. fontWeight: "bolder",
  80. color: "#000",
  81. },
  82. },
  83. pointer: {
  84. show: true,
  85. },
  86. data: [
  87. {
  88. name: "系统电压",
  89. value: 2000,
  90. itemStyle: { color: "#00ccee" },
  91. },
  92. ],
  93. },
  94. ],
  95. };
  96. this.chartInstance.setOption(option);
  97. },
  98. },
  99. };
  100. </script>
  101. <style scoped>
  102. </style>