<template>
    <div class="container">
        <div id="ELeft2" style="height:100%;"></div>
    </div>
</template>

<script>
export default {
    name: "ELeft2",
    data() {
        return {};
    },
    mounted() {
        this.drawChart();
    },
    methods: {
        drawChart() {
            // 基于准备好的dom，初始化echarts实例
            let myChart = this.$echarts.init(document.getElementById("ELeft2"));
            // 指定图表的配置项和数据
            let option = {
                title: {
                    text: "存栏羊等级",
                    left: "20%",
                    top: "5%",
                    textStyle: {
                        fontSize: 30,
                        color: "#fff",
                    },
                },
                tooltip: {
                    trigger: "item",
                    formatter: "{b}: {c} ({d}%)",
                    textStyle: {
                        fontSize: 20,
                        color: "#fff",
                    },
                },
                legend: {
                    orient: "horizontal",
                    bottom: 10,
                    data: ["特级", "一级", "二级", "三级"],
                    textStyle: {
                        fontSize: 20,
                        color: "#fff",
                    },
                },
                series: [
                    {
                        type: "pie",
                        // 内外圈厚度
                        radius: ["20%", "60%"],
                        label: {
                            formatter: "{d}%",
                        },
                        data: [
                            { value: 168, name: "特级" },
                            { value: 476, name: "一级" },
                            { value: 688, name: "二级" },
                            { value: 232, name: "三级" },
                        ],
                        color: ["#BA43F5", "#FF3C43", "#F5944C", "#8CE8FA"],
                        label: {
                            fontSize: 20,
                        },
                    },
                ],
            };
            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
        },
    },
};
</script>

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