<template>
  <div>
    <Chart :cdata="cdata" />
  </div>
</template>

<script>
  import Chart from "./chart.vue";
  import {
    httpPost,
    httpGet
  } from "../../../../api";
  import RegisterDevice from "../../../../api/allFun.js";
  export default {
    data() {
      return {
        cdata: {
          xData: [
            "电量(0-20%)",
            "电量(20-40%)",
            "电量(40-60%)",
            "电量(60-80%)",
            "电量(80-100%)",
          ],
          seriesData: [{
              value: 0,
              name: "电量(0-20%)"
            },
            {
              value: 0,
              name: "电量(20-40%)"
            },
            {
              value: 0,
              name: "电量(40-60%)"
            },
            {
              value: 0,
              name: "电量(60-80%)"
            },
            {
              value: 0,
              name: "电量(80-100%)"
            },
          ],
        },
      };
    },
    components: {
      Chart,
    },
    mounted() {
      this.getcard();
    },
    methods: {
      // 获取门卡概况
      getcard() {
        RegisterDevice.getAnalysis("", -1, (callback) => {
          this.cdata.seriesData[0].value = callback.batteryLevel1;
          this.cdata.seriesData[1].value = callback.batteryLevel2;
          this.cdata.seriesData[2].value = callback.batteryLevel3;
          this.cdata.seriesData[3].value = callback.batteryLevel4;
          this.cdata.seriesData[4].value = callback.batteryLevel5;
        })
      },
    },
  };
</script>

<style lang="scss" scoped>
</style>
