chart-fireGrade.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!-- **************************************NO.8 养殖场分布*************************************** -->
  2. <template>
  3. <div class="chart-container">
  4. <div id="fireGrade" style="width: 100%; height:23vh;">
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import { getEventCountGroupByFireRisk } from '@/api/bigdata'
  10. import * as echarts from 'echarts';
  11. export default {
  12. name: 'fireGrade',
  13. data() {
  14. return {
  15. count: 0
  16. }
  17. },
  18. mounted() {
  19. this.getEventCountGroupByFireRisk();
  20. },
  21. methods: {
  22. getEventCountGroupByFireRisk(){
  23. getEventCountGroupByFireRisk().then(resp => {
  24. this.myEcharts(resp.data);
  25. })
  26. },
  27. myEcharts(data) {
  28. var chartDom = document.getElementById('fireGrade');
  29. var myChart = echarts.init(chartDom);
  30. var color = ['#02CDFF', '#62FBE7', '#7930FF','#ef5f9d','#ecb935'];
  31. var option;
  32. option = {
  33. color:color,
  34. tooltip : {
  35. trigger: 'item',
  36. formatter: "{b}: {c}"
  37. },
  38. toolbox: {
  39. show : true,
  40. },
  41. series : [
  42. {
  43. type:'pie',
  44. roseType: true,
  45. radius : ['50%', '70%'],
  46. label: {
  47. show: true,
  48. formatter: "{b} {c}",
  49. textStyle: {
  50. fontSize: 10 ,
  51. }
  52. },
  53. data:data
  54. }
  55. ]
  56. };
  57. option && myChart.setOption(option);
  58. },
  59. },
  60. }
  61. </script>
  62. <style rel="stylesheet/scss" lang="scss" scoped>
  63. .chart-container {
  64. width: 100%;
  65. height: auto;
  66. position: relative;
  67. padding-bottom: 10px;
  68. display: flex;
  69. }
  70. </style>