nhtbtj.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div>
  3. <div id="echarts"></div>
  4. </div>
  5. </template>
  6. <script>
  7. import * as echarts from "echarts";
  8. export default {
  9. data() {
  10. return {
  11. }
  12. },
  13. created() {},
  14. mounted() {
  15. this.typeCharts0()
  16. },
  17. methods: {
  18. typeCharts0() {
  19. let option = this.getOption();
  20. var chartDom = document.getElementById('echarts');
  21. var myChart = echarts.init(chartDom);
  22. myChart.setOption(option, true);
  23. },
  24. getOption(data) {
  25. let option = {
  26. color: ["#2B80FF", "#3DF3C4"],
  27. title: {
  28. text: ''
  29. },
  30. tooltip: {
  31. trigger: 'axis'
  32. },
  33. legend: {
  34. orient: 'horizontal',
  35. x: 'center',
  36. y: 'top',
  37. textStyle: {
  38. fontSize: 12,
  39. },
  40. data: [{
  41. name: '上月(kw/h)',
  42. textStyle: {
  43. color: "#2B80FF "
  44. }
  45. },
  46. {
  47. name: '本月(kw/h)',
  48. textStyle: {
  49. color: "#3DF3C4"
  50. }
  51. }
  52. ],
  53. backgroundColor: 'rgba(0,0,0,0)',
  54. borderColor: '#ccc',
  55. borderWidth: 0,
  56. padding: 5,
  57. itemGap: 10,
  58. itemWidth: 20,
  59. itemHeight: 14,
  60. },
  61. grid: {
  62. left: '3%',
  63. right: '4%',
  64. bottom: '3%',
  65. containLabel: true
  66. },
  67. // toolbox: {
  68. // feature: {
  69. // saveAsImage: {}
  70. // }
  71. // },
  72. xAxis: {
  73. type: 'category',
  74. boundaryGap: false,
  75. data: ['一月', '二月', '三月', '四月', '五月', '六月']
  76. },
  77. yAxis: {
  78. type: 'value'
  79. },
  80. series: [{
  81. name: '上月(kw/h)',
  82. type: 'line',
  83. // stack: 'Total',
  84. data: [1000, 1500, 1300, 1700, 1600, 1200]
  85. },
  86. {
  87. name: '本月(kw/h)',
  88. type: 'line',
  89. // stack: 'Total',
  90. data: [1200, 1800, 1400, 1350, 1100, 1500]
  91. },
  92. ]
  93. };
  94. return option;
  95. }
  96. },
  97. }
  98. </script>
  99. <style scoped>
  100. #echarts {
  101. width: 320rem;
  102. height: 200rem;
  103. margin: 10rem;
  104. }
  105. </style>