ELeft1.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="container">
  3. <div id="ELeft1" style="height:100%;"></div>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: "ELeft1",
  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("ELeft1"));
  19. // 指定图表的配置项和数据
  20. let option = {
  21. color: ["#01D7EF"],
  22. tooltip: {
  23. trigger: "axis",
  24. textStyle: {
  25. fontSize: 20,
  26. color: "#fff"
  27. }
  28. },
  29. grid: {
  30. x: "5%",
  31. y: "18%",
  32. x2: "10%",
  33. y2: "13%",
  34. containLabel: true,
  35. },
  36. calculable: true,
  37. xAxis: {
  38. name: "(时间)",
  39. nameTextStyle: {
  40. fontSize: 20,
  41. color: "#fff",
  42. },
  43. type: "category",
  44. data: ["2015", "2016", "2017", "2018", "2019", "2020"],
  45. textStyle: {
  46. fontSize: 20,
  47. color: "#fff",
  48. },
  49. axisLabel: {
  50. textStyle: {
  51. fontSize: 20,
  52. color: "#fff"
  53. },
  54. },
  55. axisLine: {
  56. lineStyle: {
  57. color: "#fff",
  58. width: 2,
  59. },
  60. },
  61. },
  62. yAxis: {
  63. name: "(元/公斤)",
  64. nameTextStyle: {
  65. fontSize: 20,
  66. color: "#fff",
  67. },
  68. type: "value",
  69. axisLabel: {
  70. textStyle: {
  71. fontSize: 20,
  72. color: "#fff"
  73. },
  74. },
  75. axisLine: {
  76. lineStyle: {
  77. color: "#fff",
  78. width: 2,
  79. },
  80. },
  81. scale: true,
  82. min(val) {
  83. return Number((val.min*0.7).toFixed(0))
  84. }
  85. },
  86. series: [
  87. {
  88. name: "公羊",
  89. type: "line",
  90. barWidth: "30%",
  91. data: [21.9, 21.0, 23.6, 27.8, 30.7, 32.4],
  92. markLine: {
  93. data: [{ type: "average", name: "平均值", label: {fontSize: 20} }],
  94. },
  95. }
  96. ]
  97. };
  98. // 使用刚指定的配置项和数据显示图表。
  99. myChart.setOption(option);
  100. },
  101. },
  102. };
  103. </script>
  104. <style lang="scss" scoped>
  105. </style>