chart-eventTrend.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <!-- **************************************NO.6 矿坑*************************************** -->
  2. <template>
  3. <div class="chart-container">
  4. <div id="pit" style="width: 100%; height:24vh;">
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import * as echarts from 'echarts';
  10. import {getSjqs} from '@/api/bigdata'
  11. export default {
  12. name: 'pit',
  13. data() {
  14. return {
  15. count: 0,
  16. data_sjqs_month:[],
  17. data_sjqs_num:[]
  18. }
  19. },
  20. mounted() {
  21. this.sjqs()
  22. },
  23. methods: {
  24. // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=udduEFcFiEYEEj4Q
  25. sjqs(){
  26. let that = this
  27. getSjqs().then(resp=>{
  28. that.data_sjqs_month = resp.data.month
  29. that.data_sjqs_num = resp.data.num
  30. console.log(that.data_sjqs_month)
  31. console.log(that.data_sjqs_num)
  32. that.myEcharts()
  33. })
  34. },
  35. myEcharts() {
  36. let that = this
  37. var chartDom = document.getElementById('pit');
  38. var myChart = echarts.init(chartDom);
  39. var color = ['#02CDFF', '#62FBE7', '#7930FF','#ef5f9d','#ecb935'];
  40. var option;
  41. option = {
  42. xAxis: {
  43. data:that.data_sjqs_month,
  44. },
  45. yAxis: {
  46. axisLabel: {
  47. fontSize: 10,
  48. color: '#999',
  49. verticalAlign: 'bottom',
  50. formatter: function (value, index) {
  51. return `${value.toFixed(2)}`;
  52. },
  53. },
  54. },
  55. series: [
  56. {
  57. type: 'line',
  58. lineStyle: {
  59. color: '#C22F43',
  60. width: 1,
  61. type: 'solid',
  62. },
  63. areaStyle: {
  64. color: {
  65. type: 'linear',
  66. x: 0,
  67. y: 0,
  68. x2: 0,
  69. y2: 1,
  70. colorStops: [
  71. {
  72. offset: 0,
  73. color: 'rgba(194, 47, 67, 1.0)',
  74. },
  75. {
  76. offset: 1,
  77. color: 'rgba(194, 47, 67, 0.03)',
  78. },
  79. ],
  80. global: false,
  81. },
  82. origin: 'start',
  83. },
  84. opacity: 0.2,
  85. shadowColor: 'rgba(194, 47, 67)',
  86. shadowBlur: 0,
  87. shadowOffsetX: 0,
  88. data: that.data_sjqs_num
  89. },
  90. ],
  91. };
  92. option && myChart.setOption(option);
  93. },
  94. },
  95. }
  96. </script>
  97. <style rel="stylesheet/scss" lang="scss" scoped>
  98. .chart-container {
  99. width: 100%;
  100. height: 100%;
  101. position: relative;
  102. padding-bottom: 10px;
  103. display: flex;
  104. }
  105. </style>