nhtbtj.vue 2.3 KB

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