PieLocationChart.vue 2.07 KB
<template>
  <div :class="className" :style="{ height: height, width: width }" />
</template>

<script>
import echarts from "echarts";
require("echarts/theme/macarons"); // echarts theme
import resize from "./mixins/resize";

const animationDuration = 3000;

export default {
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: "chart",
    },
    width: {
      type: String,
      default: "100%",
    },
    height: {
      type: String,
      default: "300px",
    },
  },
  data() {
    return {
      chart: null,
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart();
    });
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$el, "macarons");

      this.chart.setOption({
        title: {
          text: "库位利用率",
          textStyle: {
          color: 'rgba(0, 0, 0, 0.7)',
          fontSize: '15',
          fontWeight:'bold'
        }
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)",
        },

        legend: {
          type: "scroll",
          orient: "vertical",
          right: 10,
          top: 20,

          bottom: "20",
          data: ["有货", "无货"],
         
        },
        series: [
          {
            name: "货位状态",
            type: "pie",
            radius: "55%",
            center: ["40%", "50%"],
            // data: data.seriesData,
            data: [
              {
                value: 10,
                name: "有货",
              },
              {
                value: 300,
                name: "无货",
              },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
            animationEasing: "cubicInOut",
            animationDuration: 2600,
          },
        ],
      });
    },
  },
};
</script>