<template>
  <div id="four">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="title"> 科技服务 </el-col>
        <el-col :span="24" class="canvas">
          <div id="fourChart" style="height: 420px"></div>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import * as echarts from 'echarts';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: statistics } = createNamespacedHelpers('statistics');
export default {
  name: 'four',
  props: {},
  components: {},
  data: function () {
    return {};
  },
  created() {},
  mounted() {
    this.init();
  },
  methods: {
    ...statistics(['query']),
    async init() {
      let res = await this.query({ type: 'data' });
      if (this.$checkRes(res)) {
        console.log(res.data);
        var chartDom = document.getElementById('fourChart');
        var myChart = echarts.init(chartDom);
        var option;
        option = {
          // title: {
          //   text: '某站点用户访问来源',
          //   left: 'center',
          // },
          tooltip: {
            trigger: 'item',
          },
          legend: {
            top: '5%',
            left: 'center',
          },
          series: [
            {
              name: '科技服务',
              type: 'pie',
              radius: '60%',
              data: res.data,
              emphasis: {
                itemStyle: {
                  shadowBlur: 10,
                  shadowOffsetX: 0,
                  shadowColor: 'rgba(0, 0, 0, 0.5)',
                },
              },
            },
          ],
        };
        option && myChart.setOption(option);
      }
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  .title {
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    padding: 15px 0;
  }
}
</style>
