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

<script>
export default {
    name: "ELeft1",
    data() {
        return {};
    },
    mounted() {
        this.drawChart();
    },
    methods: {
        drawChart() {
            // 基于准备好的dom，初始化echarts实例
            let myChart = this.$echarts.init(
                document.getElementById("ELeft1")
            );
            // 指定图表的配置项和数据
            let option = {
                title: {
                    text: "价格走势",
                    left: "20%",
                    top: "5%",
                    textStyle: {
                        fontSize: 30,
                        color: "#fff",
                    },
                },
                color: ["#FF5A74"],
                tooltip: {
                    trigger: "axis",
                    textStyle: {
                        fontSize: 20,
                        color: "#fff",
                    },
                },
                grid: {
                    x: "5%",
                    y: "18%",
                    x2: "10%",
                    y2: "5%",
                    containLabel: true,
                },
                calculable: true,
                xAxis: {
                    name: "(时间)",
                    nameTextStyle: {
                        fontSize: 20,
                        color: "#fff",
                    },
                    type: "category",
                    data: ["四月", "五月", "六月", "七月", "九月"],
                    textStyle: {
                        fontSize: 20,
                        color: "#fff",
                    },
                    axisLabel: {
                        textStyle: {
                            fontSize: 20,
                            color: "#fff",
                        },
                    },
                },

                yAxis: {
                    name: "(元/kg)",
                    nameTextStyle: {
                        fontSize: 20,
                        color: "#fff",
                    },
                    type: "value",
                    axisLabel: {
                        textStyle: {
                            fontSize: 20,
                            color: "#fff",
                        },
                    },
                    scale: true,
                    min(val) {
                        return Number((val.min * 0.7).toFixed(0));
                    },
                },
                series: [
                    {
                        name: "公羊",
                        type: "line",
                        barWidth: "30%",
                        data: [72, 73, 72, 76, 74],
                        markLine: {
                            data: [{ type: "average", name: "平均值", label: {fontSize: 20} }],
                        },
                    },
                ],
            };
            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
        },
    },
};
</script>

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