echarts单行柱状图

25 篇文章 3 订阅
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>柱状图</title>
    <!-- 引入 echarts.js -->
    <script src="js/echarts.min.js"></script>
</head>

<body>
    <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
    <div id="main" style="width: 50%;height:38vh;"></div>
    <script type="text/javascript">
        // 基于准备好的dom,初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));

        // 指定图表的配置项和数据
        var option = {
            legend: {
                bottom:"0",
                textStyle: {
                    color: "#65ABE7",
                    fontSize: 10
                }
            },
            xAxis: {
                type: 'value',
                axisTick: {
                    show: false,
                },
                axisLine: {
                    show: false
                },
                splitLine:{
                    show:false
                },
                axisLabel:{
                    show:false
                }

            },
            yAxis: [
                {
                data: ["路板"],
                axisTick: {
                    show: false,
                },
                axisLine: {
                    show: false
                },
                splitLine:{
                    show:false
                },
                axisLabel:{
                    show:false
                }
            }
        ],
            series: [
                {
                    name: '产出数',
                    type: 'bar',
                    stack: '总量',
                    data: [34],
                    itemStyle: {
                        normal: {
                            color: '#63b2ee',
                            label: {
                                show: true, //显示
                                position: 'top', //在上方
                                textStyle: { //文字样式
                                    color: '#fc6d08',
                                    fontSize: 12
                                }
                            }
                        }
                    }
                },
                {
                    name: '在制品',
                    type: 'bar',
                    stack: '总量',
                    data: [45],
                    itemStyle: {
                        normal: {
                            color: '#76da91',
                            label: {
                                show: true, //显示
                                position: 'bottom', //在上方
                                textStyle: { //文字样式
                                    color: '#fc6d08',
                                    fontSize: 12
                                }
                            }
                        }
                    }
                },
                {
                    name: '未生产数',
                    type: 'bar',
                    stack: '总量',
                    data: [496],
                    itemStyle: {
                        normal: {
                            color: '#f8cb7f',
                            label: {
                                show: true, //显示
                                position: 'right', //在上方
                                textStyle: { //文字样式
                                    color: '#fc6d08',
                                    fontSize: 12
                                }
                            }
                        }
                    }
                }
            ]
           
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        window.onresize = function () {
            myChart.resize();
        }
    </script>
</body>

</html>

效果图:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值