<template>
  <div id="rose-chart">
    <div class="rose-chart-title">烘房出香情况</div>

    <div class="water-level-chart-details">
      本班次出香<span>354</span>车
    </div>

<!--    <dv-charts :option="option" />-->
    <dv-capsule-chart :config="config" style="width:300px;height:200px" />
  </div>
</template>

<script>
export default {
  name: 'RoseChart',
  data () {
    return {
      option: {},
      config: {
        data: [
          {
            name: '合格',
            value: 362
          },
          {
            name: '不合格',
            value: 10
          },

        ],
        colors: ['#3dd96a', '#fc0541'],
        unit: '单位',
        showValue: true
      }
    }
  },
  methods: {
    createData () {
      const { randomExtend } = this

      this.option = {
        // title: {
        //   text: '畅销饮料占比饼状图'
        // },
        series: [
          {
            type: 'pie',
            data: [
              { name: '可口可乐', value: 93 },
              { name: '百事可乐', value: 32 },
              // { name: '哇哈哈', value: 65 },
              // { name: '康师傅', value: 44 },
              // { name: '统一', value: 52 },
            ],
            insideLabel: {
              show: true
            }
          }
        ]
        // series: [
        //   {
        //     type: 'pie',
        //     radius: '50%',
        //     roseSort: false,
        //     data: [
        //       { name: '合格', value: randomExtend(200, 300) },
        //       { name: '不合格', value: randomExtend(5, 10) },
        //
        //     ],
        //     insideLabel: {
        //       show: false
        //     },
        //     outsideLabel: {
        //       formatter: '{value}',
        //       labelLineEndLength: 20,
        //       style: {
        //
        //         fill: '#fff'
        //       },
        //       labelLineStyle: {
        //         stroke: '#fff'
        //       }
        //     },
        //     roseType: true
        //   }
        // ],
        // color: ['#5fec4f', '#fa3600']
      }
    },
    randomExtend (minNum, maxNum) {
      if (arguments.length === 1) {
        return parseInt(Math.random() * minNum + 1, 10)
      } else {
        return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10)
      }
    }
  },
  mounted () {
    const { createData } = this

    createData()

    setInterval(createData, 30000)
  }
}
</script>

<style lang="less">
#rose-chart {
  width: 30%;
  height: 100%;
  background-color: rgba(6, 30, 93, 0.5);
  border-top: 2px solid rgba(1, 153, 209, .5);
  box-sizing: border-box;

  .rose-chart-title {
    height: 50px;
    font-weight: bold;
    text-indent: 20px;
    font-size: 20px;
    display: flex;
    align-items: center;
  }

  .dv-charts-container {
    height: calc(~"100% - 50px");
  }
  .water-level-chart-details {
    height: 15%;
    display: flex;
    justify-content: center;
    font-size: 17px;
    align-items: flex-end;

    span {
      font-size: 35px;
      font-weight: bold;
      color: #58a1ff;
      margin: 0 5px;
      margin-bottom: -5px;
    }
  }
}
</style>
