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

<script>
export default {
    name: "ERight1",
    data() {
        return {
            data: [40, 38.5, 48.2, 43.6, 42.8, 55.6, 44.6],
        };
    },
    mounted() {
        this.drawChart();
    },
    methods: {
        drawChart() {
            // 基于准备好的dom，初始化echarts实例
            let myChart = this.$echarts.init(
                document.getElementById("ERight1")
            );
            // 指定图表的配置项和数据
            let option = {
                // backgroundColor: "#0D1943",
                title: {
                    text: "牧场销售情况",
                    left: "4%",
                    top: "4%",
                    textStyle: {
                        fontSize: 24,
                        color: "#fff"
                    },
                },
                grid: {
                    x: "5%",
                    y: "18%",
                    x2: "8%",
                    y2: "5%",
                    containLabel: true,
                },
                tooltip: {
                    trigger: "axis",
                    textStyle: {
                        fontSize: 25,
                        color: "#fff"
                    }
                },
                xAxis: {
                    data: [
                        "周一",
                        "周二",
                        "周三",
                        "周四",
                        "周五",
                        "周六",
                        "周日",
                    ],
                    axisLine: {
                        show: true,
                        lineStyle: {
                            type: "solid",
                            color: "#fff", //左边线的颜色
                            width: "2", //坐标线的宽度
                        },
                    },
                    axisLabel: {
                        textStyle: {
                            color: "#fff",
                            fontSize: 20,
                        },
                    },
                    name: "(时间)",
                    nameTextStyle: {
                        fontSize: 20,
                        color: "#fff",
                    },
                    axisLine: {
                        lineStyle: {
                            color: "#38375d",
                            width: 2,
                        },
                    },
                },
                yAxis: {
                    splitLine: { show: false },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            type: "solid",
                            color: "#fff", //左边线的颜色
                            width: "2", //坐标线的宽度
                        },
                    },
                    axisLabel: {
                        textStyle: {
                            color: "#fff",

                            fontSize: 20,
                        },
                    },
                    name: "(万元)",
                    nameTextStyle: {
                        fontSize: 20,
                    },
                    axisLabel: {
                        textStyle: {
                            color: "#fff",
                            fontSize: 20,
                        },
                    },
                },
                series: [
                    {
                        //真实数据所在
                        name: "销售统计",
                        type: "pictorialBar",
                        symbol: "rect",
                        itemStyle: {
                            color: "#0369df",
                            barBorderRadius: 3,
                        },
                        label: {
                            show: true, //开启显示
                            position: "top", //在上方显示
                            textStyle: {
                                //数值样式
                                color: "#fff",
                                fontSize: 20,
                            },
                            formatter: "{c}",
                        },
                        symbolRepeat: true,
                        symbolSize: [57, 6],
                        symbolMargin: 3,
                        data: this.data,
                        markLine: {
                            data: [{ type: "average", name: "平均值", label: {fontSize: 20} }],
                        },
                    },
                    {
                        type: "pictorialBar",
                        symbol: "rect",
                        itemStyle: {
                            color: "#022a62",
                            barBorderRadius: 3,
                        },
                        symbolRepeat: true,
                        symbolSize: [57, 6],
                        symbolMargin: 3,
                        z: -10,
                        data: [...this.data].fill(Math.max(...this.data)),
                    },
                ],
            };
            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
        },
    },
};
</script>

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