<script>
export default {
  data() {
    return {}
  },
  props: {
    height: Number,
  },
  mounted() {
    this.$nextTick(()=>{
      this.initChart()
    })
  },
  methods: {
    initChart() {
      let chart = this.$echarts.init(this.$refs.myChart)
      let option = {
        color: ['#80D4FF', '#A6A6FF', '#FFB580', '#FFDF80', '#79F2E8'],
        tooltip: {
          trigger: 'item'
        },
        legend: {
          bottom: '5%',
          left: '10%',
          right: '10%',
          icon: 'circle'
        },
        series: [
          {
            name: '用水量',
            type: 'pie',
            radius: ['40%', '70%'],
            center: ['50%','40%'],
            data: [
              { value: 1048, name: '自来水' },
              { value: 735, name: '中水' },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      chart.setOption(option)
    }
  }
}
</script>

<template>
  <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
</template>

<style lang="less" scoped>

</style>