chart-gridDistribution.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <!-- **************************************NO.10 收集点*************************************** -->
  2. <template>
  3. <div class="chart-container">
  4. <div id="collection" style="width: 100%; height:23vh;">
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import * as echarts from 'echarts';
  10. import {getWgfb} from '@/api/bigdata.js'
  11. export default {
  12. name: 'collection',
  13. data() {
  14. return {
  15. count: 0,
  16. data :[]
  17. }
  18. },
  19. mounted() {
  20. this.wgfb()
  21. },
  22. methods: {
  23. wgfb() {
  24. let that = this
  25. getWgfb().then(resp => {
  26. // alert("网格分布")
  27. that.data = Array.isArray(resp.data) && resp.data.length > 20 ? resp.data.splice(0,20) : resp.data
  28. this.myEcharts()
  29. })
  30. },
  31. // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=UDNqxg4NZdRORp80
  32. myEcharts() {
  33. var chartDom = document.getElementById('collection');
  34. var myChart = echarts.init(chartDom);
  35. var color = ['#0E7CE2', '#FF8352', '#E271DE', '#F8456B', '#00FFFF', '#4AEAB0'];
  36. var option;
  37. let bgColor = '#fff';
  38. let title = '总量';
  39. let echartData = this.data;
  40. let formatNumber = function (num) {
  41. let reg = /(?=(\B)(\d{3})+$)/g;
  42. return num.toString().replace(reg, ',');
  43. };
  44. let total = echartData.reduce((a, b) => {
  45. return a + b.value * 1;
  46. }, 0);
  47. option = {
  48. color: color,
  49. series: [
  50. {
  51. type: 'pie',
  52. radius: ['55%', '70%'],
  53. center: ['50%', '50%'],
  54. data: echartData,
  55. hoverAnimation: false,
  56. itemStyle: {
  57. normal: {
  58. borderWidth: 1,
  59. },
  60. emphasis: {
  61. borderColor: bgColor,
  62. borderWidth: 2,
  63. shadowBlur: 8,
  64. borderColor: "#00ffff",
  65. shadowColor: "#00ffff",
  66. },
  67. },
  68. labelLine: {
  69. normal: {
  70. length: 20,
  71. length2: 10,
  72. lineStyle: {
  73. color: '#356781',
  74. },
  75. },
  76. },
  77. label: {
  78. normal: {
  79. formatter: (params) => {
  80. return '{icon|●}{name|' + params.name + '}{value|' + formatNumber(params.value) + '}';
  81. },
  82. rich: {
  83. icon: {
  84. fontSize: 10,
  85. },
  86. name: {
  87. fontSize: 10,
  88. padding: [0, 3, 0, 4],
  89. color: '#23c9ea',
  90. },
  91. value: {
  92. fontSize: 10,
  93. color: '#ffffff',
  94. },
  95. },
  96. },
  97. },
  98. },
  99. ],
  100. };
  101. option && myChart.setOption(option);
  102. },
  103. },
  104. }
  105. </script>
  106. <style rel="stylesheet/scss" lang="scss" scoped>
  107. .chart-container {
  108. width: 100%;
  109. height: auto;
  110. position: relative;
  111. padding-bottom: 10px;
  112. display: flex;
  113. }
  114. </style>