<!-- **************************************NO.14 泡沫液*************************************** -->
<template>
  <div class="chart-container">
    <div id="foam" style="width: 100%; height:23vh;">
    </div>
  </div>
</template>

<script>
  import * as echarts from 'echarts';
  import {getPmy} from '@/api/bigdata'

  export default {
    name: 'foam',
    data() {
      return {
        count: 0,
        data_pmy_name:[],
        data_pmy_value:[]
      }
    },
    mounted() {
      this.pmy()

    },

    methods: {

      pmy() {
        let that = this
        getPmy().then(resp => {
          that.data_pmy_name = resp.data.name
          that.data_pmy_value = resp.data.value
          that.myEcharts()
        })
      },
      // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=daPJGrcYMpZanpxR
      myEcharts() {
        let that = this
        var chartDom = document.getElementById('foam');
        var myChart = echarts.init(chartDom);
        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'];
        var option;
        option = {
          grid: {
            top: '5%',
            left: '10%',
            right: '12%',
            bottom: '0',
            containLabel: true
          },
          tooltip: {},
          xAxis: {
            show: false,
            type: 'value'
          },
          yAxis: {
            type: 'category',
            inverse: true,
            data: that.data_pmy_name,
            axisLabel: {
              show: true,
              textStyle: {
                color: '#ADD6FF',
                fontSize: '12'
              }
            },
            splitLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            axisLine: {
              show: false
            },
          },
          series: [
            {
              type: 'bar',
              barWidth: "10%",
              data: that.data_pmy_value
            }
          ],
          itemStyle: {
            color: function (params) {
              return zdslColorList[params.dataIndex]
            }
          }
        }
        option && myChart.setOption(option);
      },

    },


  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .chart-container {
    width: 100%;
    height: auto;
    position: relative;
    padding-bottom: 10px;
    display: flex;
  }
</style>
