chart-waterintake.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <!-- **************************************NO.15 取水口*************************************** -->
  2. <template>
  3. <div class="chart-container">
  4. <div id="chartPitG4" style="width: 100%; height:23vh;">
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import * as echarts from 'echarts';
  10. import {getG4} from '@/api/bigdata'
  11. export default {
  12. name: 'chartPitG4',
  13. data() {
  14. return {
  15. source: [],
  16. count: 0
  17. }
  18. },
  19. mounted() {
  20. // this.myEcharts()
  21. this.getG4()
  22. },
  23. methods: {
  24. getG4() {
  25. let that = this
  26. getG4().then(res => {
  27. this.source = res.data
  28. console.log("河流资源统计", res.data)
  29. that.myEcharts()
  30. })
  31. },
  32. // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=AQ8Ea8ewtkr0NVzH
  33. myEcharts() {
  34. var chartDom = document.getElementById('chartPitG4');
  35. var myChart = echarts.init(chartDom);
  36. var option;
  37. option = {
  38. color: ['#1890FF', '#12DDA1', '#F78048', '#FFB026', '#FD4D63', 'rgba(255,255,255,.5)'],
  39. tooltip: {
  40. trigger: 'item',
  41. padding: [10, 10, 10, 10],
  42. formatter: '{b} :<br/> {d}%',
  43. },
  44. series: [
  45. {
  46. name: '',
  47. type: 'pie',
  48. radius: ['36%', '66%'],
  49. center: ['50%', '50%'],
  50. label: {
  51. fontSize: 10,
  52. color: '#00a0e5',
  53. formatter: '{b} {c}',
  54. // 自定义富文本样式
  55. },
  56. labelLine: {
  57. show: true,
  58. // length: 6,
  59. // length2: 15
  60. },
  61. data: this.source,
  62. },
  63. {
  64. type: 'pie',
  65. radius: ['36%', '43%'],
  66. center: ['50%', '50%'],
  67. silent: true,
  68. data: [
  69. {
  70. name: '',
  71. value: 1,
  72. },
  73. ],
  74. },
  75. ],
  76. };
  77. option && myChart.setOption(option);
  78. },
  79. },
  80. }
  81. </script>
  82. <style rel="stylesheet/scss" lang="scss" scoped>
  83. .chart-container {
  84. width: 100%;
  85. height: auto;
  86. position: relative;
  87. padding-bottom: 10px;
  88. display: flex;
  89. }
  90. </style>