<template>
    <div class="chart_b">
        <div id="chart_b" style="width: 100%;height:400px;"></div>
    </div>
</template>

<script>
export default {
    name: "chart_b",
    props: {},
    data() {
        return {};
    },
    created() {},
    mounted() {
        this.drawChart();
    },
    methods: {
        drawChart() {
            // 基于准备好的dom，初始化echarts实例
            let myChart = this.$echarts.init(
                document.getElementById("chart_b")
            );
            // 指定图表的配置项和数据
            let option = {
                color: ["#3398DB"],
                tooltip: {
                    trigger: "axis",
                    axisPointer: {
                        // 坐标轴指示器，坐标轴触发有效
                        type: "shadow" // 默认为直线，可选为：'line' | 'shadow'
                    }
                },
                grid: {
                    left: "10%",
                    right: "10%",
                    bottom: "3%",
                    containLabel: true
                },
                yAxis: [
                    {
                        type: "category",
                        data: ["断奶母猪", "已产母猪", "待产母猪", "未用产床", "已用产床", "产床总数"],
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                xAxis: [
                    {
                        type: "value"
                    }
                ],
                series: [
                    {
                        name: "数量",
                        type: "bar",
                        barWidth: "60%",
                        data: [52, 200, 334, 390, 330, 220],
                        encode: {
                            // Map the "amount" column to X axis.
                            y: "amount",
                            // Map the "product" column to Y axis
                            x: "product"
                        }
                    }
                ]
            };
            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
        }
    }
};
</script>

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