EHHumidity.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div class="container">
  3. <div id="EHHumidity" style="height:400px;"></div>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: "EHHumidity",
  9. data() {
  10. return {};
  11. },
  12. mounted() {
  13. this.drawChart();
  14. },
  15. methods: {
  16. drawChart() {
  17. // 基于准备好的dom,初始化echarts实例
  18. let myChart = this.$echarts.init(document.getElementById("EHHumidity"));
  19. // 指定图表的配置项和数据
  20. let option = {
  21. title: {
  22. text: "湿度-小时折线表",
  23. left: "center",
  24. bottom: 0
  25. },
  26. color: ["#7c92f7"],
  27. tooltip: {
  28. trigger: "axis"
  29. },
  30. xAxis: {
  31. type: "category",
  32. data: [0, 2, 4, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]
  33. },
  34. yAxis: {
  35. type: "value",
  36. axisLabel: {
  37. formatter: "{value} %"
  38. },
  39. scale: true
  40. },
  41. series: [
  42. {
  43. name: '湿度',
  44. data: [66, 68, 67.2, 64, 60.5, 68, 67, 67.5, 63.8, 64.8, 67, 62, 67.8],
  45. type: "line",
  46. markPoint: {
  47. data: [
  48. { type: "max", name: "最大值" },
  49. { type: "min", name: "最小值" }
  50. ]
  51. },
  52. symbol: '',
  53. markLine: {
  54. data: [{ type: "average", name: "平均值" }]
  55. }
  56. }
  57. ]
  58. };
  59. // 使用刚指定的配置项和数据显示图表。
  60. myChart.setOption(option);
  61. }
  62. }
  63. };
  64. </script>
  65. <style lang="scss" scoped>
  66. </style>