chart-foamLiquid.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <!-- **************************************NO.14 泡沫液*************************************** -->
  2. <template>
  3. <div class="chart-container">
  4. <div id="foam" style="width: 100%; height:23vh;">
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import * as echarts from 'echarts';
  10. import {getPmy} from '@/api/bigdata'
  11. export default {
  12. name: 'foam',
  13. data() {
  14. return {
  15. count: 0,
  16. data_pmy_name:[],
  17. data_pmy_value:[]
  18. }
  19. },
  20. mounted() {
  21. this.pmy()
  22. },
  23. methods: {
  24. pmy() {
  25. let that = this
  26. getPmy().then(resp => {
  27. that.data_pmy_name = resp.data.name
  28. that.data_pmy_value = resp.data.value
  29. that.myEcharts()
  30. })
  31. },
  32. // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=daPJGrcYMpZanpxR
  33. myEcharts() {
  34. let that = this
  35. var chartDom = document.getElementById('foam');
  36. var myChart = echarts.init(chartDom);
  37. var zdslColorList = ['#D0A00E', '#34DA62', '#00C0E9', '#0096F3', '#33CCFF','#D0A00E', '#34DA62', '#00C0E9', '#0096F3', '#33CCFF','#D0A00E', '#34DA62', '#00C0E9', '#0096F3', '#33CCFF','#D0A00E', '#34DA62', '#00C0E9', '#0096F3', '#33CCFF','#D0A00E', '#34DA62', '#00C0E9', '#0096F3', '#33CCFF','#D0A00E', '#34DA62', '#00C0E9', '#0096F3', '#33CCFF'];
  38. var option;
  39. option = {
  40. grid: {
  41. top: '5%',
  42. left: '10%',
  43. right: '12%',
  44. bottom: '0',
  45. containLabel: true
  46. },
  47. tooltip: {},
  48. xAxis: {
  49. show: false,
  50. type: 'value'
  51. },
  52. yAxis: {
  53. type: 'category',
  54. inverse: true,
  55. data: that.data_pmy_name,
  56. axisLabel: {
  57. show: true,
  58. textStyle: {
  59. color: '#ADD6FF',
  60. fontSize: '12'
  61. }
  62. },
  63. splitLine: {
  64. show: false
  65. },
  66. axisTick: {
  67. show: false
  68. },
  69. axisLine: {
  70. show: false
  71. },
  72. },
  73. series: [
  74. {
  75. type: 'bar',
  76. barWidth: "10%",
  77. data: that.data_pmy_value
  78. }
  79. ],
  80. itemStyle: {
  81. color: function (params) {
  82. return zdslColorList[params.dataIndex]
  83. }
  84. }
  85. }
  86. option && myChart.setOption(option);
  87. },
  88. },
  89. }
  90. </script>
  91. <style rel="stylesheet/scss" lang="scss" scoped>
  92. .chart-container {
  93. width: 100%;
  94. height: auto;
  95. position: relative;
  96. padding-bottom: 10px;
  97. display: flex;
  98. }
  99. </style>