<template>
  <div class="histogram-wrap clearfix">
    <ul class='count-list' ref="count-list">
        <li>
          <div class="content-part">
            <div class="right-top" ref="rightTop1">
              <span class="count" ref='rightDataTop'>
              <span  class="product">{{data[0].name}}</span>
              </span>
              <span class="text">{{data[0].text}}</span>
            </div>
          </div>
        </li>
        <li>
          <div class="content-part">
            <div class="right-top"  ref="rightTop2">
              <span class="count" ref='rightDataTop'>
               <span  class="product">{{data[1].name}}</span>
              </span>
              <span class="text">{{data[1].text}}</span>
            </div>
          </div>
        </li>

        <li>
          <div class="content-part">
            <div class="right-top"  ref="rightTop3">
              <span class="count" ref='rightDataTop'>
              <span  class="product">{{data[2].name}}</span>
              </span>
              <span class="text">{{data[2].text}}</span>
            </div>
          </div>
        </li>

        <li>
          <div class="content-part">
            <div class="right-top"  ref="rightTop4">
              <span class="count" ref='rightDataTop'>
              <span  class="product">{{data[3].name}}</span>
              </span>
              <span class="text">{{data[3].text}}</span>
            </div>
          </div>
        </li>
    </ul>
      
  </div>
</template>
<script>
  import { countUpAnimate } from '@utils/animate'
  import staticPath from '@utils/static-path'
  import Visualizer from '@utils/audio-vis'
  import audioEffect from './audio-effect.js'
  export default {
    name: 'bs-chart-number-v',
    props: {
       data: {
         type: Array,
        default () {
          return [{
              name: '',
              text: '最富有的团队'
            }, {
              name: '',
              text: '本月创收最多团队'
            },
            {
              name: '',
              text: '被点赞最高团队'
            },
            {
              name: '',
              text: '被点赞最高个人'
            }
            ]
        }
      }
    },
    computed: {
      // maxCount () {
      //   return Math.max(...this.data.map(item => {
      //     return item.count
      //   }))
      // }
    },
    mounted () {
      this.createAudioVisiable()
    },
    methods: {
      createAudioVisiable () {
          var visTop1 = new Visualizer()
          visTop1.config({
            audioUrl: staticPath.audioPath,
            container: this.$refs.rightTop1,
            draw: audioEffect
          })
        var visTop2 = new Visualizer()
          visTop2.config({
            audioUrl: staticPath.audioPath,
            container: this.$refs.rightTop2,
            draw: audioEffect
          })

           var visTop3 = new Visualizer()
          visTop3.config({
            audioUrl: staticPath.audioPath,
            container: this.$refs.rightTop3,
            draw: audioEffect
          })

           var visTop4 = new Visualizer()
          visTop4.config({
            audioUrl: staticPath.audioPath,
            container: this.$refs.rightTop4,
            draw: audioEffect
          })
      }
    }
  }
</script>

<style scope>
  /* 容器 */
  .histogram-wrap {
    height: 100%;
  }
  .histogram-wrap .left-part,
  .histogram-wrap .left-part {
    width: 65%;
    float: left;
    border-right: 15px solid transparent;
    box-sizing: border-box;
    height: 100%;
    overflow: hidden;
  }
  .count-list{
    width:100%;
  }
  /* 左侧柱状图 */
  .count-list li {
    display: block;
    position: relative;
    padding-left: 20px;
    float:left;
    width:23%;
    height:100%;
  }
  .item-label {
    width: 55px;
    display: block;
    float: left;
    text-align: right;
    position: absolute;
    left: 0;
    font-size: 12px;
    color: #8788A1;
    line-height: 32px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  @keyframes rectShadowSpread {
    from {
      width: 0%;
    }
    to {
      width: 100%;
    }
  }
  /* 右侧图 */
  .histogram-wrap .content-part {
    width: 100%;
    height: 100%;
    padding: 10px;
    box-sizing: border-box;
  }
  .content-part .right-top,
  .content-part .right-bottom{
    width: 100%;
    height: 100%;
    position: relative;
    box-sizing: content-box;
  }

  .content-part .right-top canvas,
  .content-part .right-bottom canvas{
    position: absolute;
    left: 0;
    top: 0;
  }
  .content-part .right-bottom {
    border-top: 4px solid transparent;
  }
  .content-part .right-top {
    border-bottom: 4px solid transparent;
  }
  .content-part .product,
  .content-part .text{
    color: #FEC003;
    text-align: center;
    display:block;
    position: relative;
    z-index: 2;
  }
  .content-part .product {
    padding-top: 16px;
  }
  .content-part .product {
    font-size: 24px;
    padding: 0 2px;
  }
  .content-part .text {
    font-size: 14px;
    line-height: 28px;
  }
</style>