<template>
  <!-- 气站钢瓶投入 -->
  <div class="border" :style="{height: boxHeight}">
    <div class="card_box">
      <div class="title_trapezoid center_in">
        <span class="center_in">{{title}}</span>
      </div>
    </div>
    <div class="card_collect">
      <div id="putInto"></div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'wavyBlock',
    props: {
      title: {
        type: String,
        default: () => '文字',
      },
      boxHeight: {
        type: String,
        default: () => '95%',
      },
    },
    data() {
      return {}
    },
    mounted() {
      this.getEnterpriseCylinder()
    },
    methods: {
      getEnterpriseCylinder() {
        var chartDom = document.getElementById('putInto');
        var myChart = this.$echarts.init(chartDom);
        var option;
        var nameArr = ['高新','南明','云岩','花溪','汇川','红花岗','桐梓','道真','余庆','赤水','安顺','平坝'];
        const valueArr = [150, 60, 80, 180, 120, 160, 80, 40, 20, 30, 22, 13]
        option = {
          grid: {
            top: '10%',
            left: '12%',
            right: '5%',
            bottom: '12%'
          },
          tooltip: {
            trigger: 'axis',
            backgroundColor: '#3A4667',
            borderColor: '#3A4667',
            textStyle: {
              color: '#fff'
            },
            formatter: '{b} : {c}瓶',
            axisPointer: {
              type: 'cross',
              crossStyle: {
                color: '#999'
              }
            }
          },
          legend: {
            icon: 'rect',
            top: 10,
            right: 5,
            itemWidth: 10,
            itemHeight: 10,
            textStyle: {
              fontSize: 12, // 字体大小
              color: '#B3CFFF' // 字体颜色
            }
          },
          xAxis: {
            type: 'category',
            axisPointer: {
              type: 'shadow'
            },
            axisLine: {
              lineStyle: {
                color: 'rgba(112, 138, 198, 1)',
              },
            },
            axisLabel: {
              textStyle: {
                color: '#B3CFFF', // x轴文本颜色
                fontSize: 12
              },
              // rotate:30,
            },
            axisTick: {
              show: false
            },
            data: nameArr
          },
          yAxis: {
            type: 'value',
            splitLine: {
              show: true,
              lineStyle: {
                color: '#162647',
                type: 'solid'
              }
            },
            axisLabel: {
              formatter: '{value}瓶',
              textStyle: {
                color: '#B3CFFF', // x轴文本颜色
                fontSize: 12
              },
            },
            name: '',
            nameTextStyle: {
              color: '#B3CFFF',
              fontSize: 12,
            }
          },
          series: [{
              type: 'bar',
              name: '',
              barWidth: 16,
              itemStyle: {
                normal: {
                  color: new this.$echarts.graphic.LinearGradient(
                    0,
                    1,
                    0,
                    0,
                    [{
                        offset: 0,
                        color: 'rgba(123, 133, 255, 1)', // 0% 处的颜色
                      },
                      {
                        offset: 1,
                        color: 'rgba(96, 132, 255, 0)', // 100% 处的颜色
                      },
                    ],
                    false
                  ),
                }
              },
              data: valueArr
            },
          ]
        }
        myChart.setOption(option);
      }
    }
  }
</script>

<style lang="scss" scoped>
  .border {
    border: 1px solid #3077ca;
    margin: 0 10px 0 auto;
    border-radius: 4px;
    box-shadow: inset 0 0 40px rgba(48, 119, 202, 0.3);
  }


  .card_box {
    position: absolute;
    top: 0;
    left: calc(50% - 100px);
    right: 0;
  }

  .title_trapezoid {
    position: relative;
    color: #fff !important;
    width: 200px;
    height: 30px;
    text-align: center;
    z-index: 2;
  }

  .title_trapezoid span {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 200px;
    top: -1px;
    z-index: 2;
    font-size: 15px;
    line-height: 25px;
  }

  .title_trapezoid::before {
    border-bottom: 2px solid #2CD5FF;
    content: '';
    z-index: 1;
    width: 100%;
    height: 30px;
    background-image: linear-gradient(to top, #3077ca99, #3077ca7f, transparent);
    display: inline-block;
    position: absolute;
    left: 0;
    top: -1px;
    transform: perspective(100px) rotateX(150deg);
  }

  .card_collect {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    margin-top: 30px;
    height: calc(100% - 30px);
  }

  #putInto {
    width: 100%;
    height: 100%;
  }
</style>
