chart-firecontrol.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <!-- **************************************NO.18 消防*************************************** -->
  2. <template>
  3. <div class="chart-container">
  4. <div id="chartPitG2" style="width: 100%; height:25vh; ">
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import * as echarts from 'echarts';
  10. import {getG2} from '@/api/bigdata'
  11. export default {
  12. name: 'chartPitG2',
  13. data() {
  14. return {
  15. source: [],
  16. count: 0
  17. }
  18. },
  19. mounted() {
  20. // this.myEcharts1();
  21. this.getG2()
  22. },
  23. methods: {
  24. getG2() {
  25. let that = this
  26. getG2().then(res => {
  27. this.source = res.data
  28. console.log("水利工程资源统计", res.data)
  29. that.myEcharts1()
  30. })
  31. },
  32. // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=f46x0t0c7883X-D6
  33. myEcharts1() {
  34. var chartDom = document.getElementById('chartPitG2');
  35. var myChart = echarts.init(chartDom);
  36. var option;
  37. option = {
  38. tooltip: {
  39. trigger: 'axis',
  40. axisPointer: {
  41. type: 'shadow'
  42. }
  43. },
  44. grid:{
  45. top:'15%',
  46. left:'10%',
  47. right:'10%',
  48. buttom:'15%',
  49. },
  50. xAxis: {
  51. type: 'category',
  52. axisLine: {
  53. lineStyle: {
  54. color: 'rgba(255,255,255,0.12)',
  55. },
  56. },
  57. axisLabel: {
  58. margin: 10,
  59. color: '#e2e9ff',
  60. textStyle: {
  61. fontSize: 10
  62. },
  63. },
  64. axisTick:{
  65. show:false,
  66. },
  67. // data: ['双辽市', '梨树县', '伊通县', '铁东区', '铁西区']
  68. data: this.source.name
  69. },
  70. yAxis: {
  71. nameTextStyle:{
  72. color:'#fff',
  73. },
  74. type: 'value',
  75. axisLine: {
  76. show:false,
  77. lineStyle: {
  78. color: 'rgba(255,255,255,0.12)'
  79. },
  80. },
  81. axisLabel: {
  82. show:false,
  83. formatter: '{value}',
  84. color: '#e2e9ff',
  85. },
  86. splitLine: {
  87. lineStyle: {
  88. color: 'rgba(255,255,255,0.12)'
  89. }
  90. },
  91. axisTick:{
  92. show:true,
  93. lineStyle:{
  94. color:'#fff',
  95. },
  96. },
  97. },
  98. series: [{
  99. itemStyle:{
  100. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  101. offset: 0,
  102. color: 'rgba(0,244,255,1)'
  103. }, {
  104. offset: 1,
  105. color: 'rgba(0,77,167,1)'
  106. }], false),
  107. barBorderRadius: 10,
  108. opacity:0.8
  109. },
  110. barWidth:10,
  111. label:{
  112. show:true,
  113. position:['0','-20'],
  114. color:'#fff',
  115. },
  116. // data: [120, 200, 150, 80, 70],
  117. data: this.source.value,
  118. type: 'bar',
  119. }]
  120. };
  121. option && myChart.setOption(option);
  122. },
  123. },
  124. }
  125. </script>
  126. <style rel="stylesheet/scss" lang="scss" scoped>
  127. .chart-container {
  128. width: 100%;
  129. height: auto;
  130. position: relative;
  131. padding-bottom: 10px;
  132. display: flex;
  133. flex-direction: column;
  134. }
  135. </style>