echars 柱状图 配置

先来图片,本文配置的是下图红圈内的柱状图
不要diss我说这个可视化界面多low,我只是个无辜的前端,我也觉得low,但是大佬们喜欢,我有啥办法,嘿嘿
在这里插入图片描述
引入依赖

<script type="text/javascript" src="js/echarts.js"></script>

挂载节点

 <div id="chart-line-bar" class="chart-area"></div>

配置

        //话务个时段统计 -- 左侧柱状图
        function TrafficTimeLeft(xdata, ydata) {
            console.log(xdata, ydata)
            var myChartLeft = echarts.init(document.getElementById('chart-line-bar')); //左侧柱状图
            // 指定图表的配置项和数据
            var optionLeft = {
                title: {
                    text: '话务各时段统计',
                    x: 'left',
                    textStyle: {//标题颜色
                        color: "#fff",
                        fontSize:'12px'
                    }
                },
                backgroundColor: 'rgba(4,27,76,0.43)',
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器,坐标轴触发有效
                        type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
                    }
                },
                grid: {
                    top: '18%',
                    left: '7%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis: {
                    type: 'category',
                    data: xdata,
                    //设置坐标轴字体颜色和宽度
                    axisLine: {
                        lineStyle: {
                            color: "#80B8D4",
                        }
                    },
                    axisLabel: {
                        interval: 0,
                        rotate: 30
                    },
                    axisTick: {
                        alignWithLabel: true
                    }
                },
                yAxis: {
                    type: 'value',
                    //设置坐标轴字体颜色和宽度
                    axisLine: {
                        lineStyle: {
                            color: "#80B8D4",
                        }
                    },
                    splitLine: { show: false },
                    // name: '话务各时段统计'
                },
                series: [
                    {
                        name: '话务统计',
                        type: 'bar',
                        barWidth: '45%',
                        data: ydata,
                        itemStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
                                    offset: 0,
                                    color: "#1268f3" // 0% 处的颜色
                                }, {
                                    offset: 0.6,
                                    color: "#08a4fa" // 60% 处的颜色
                                }, {
                                    offset: 1,
                                    color: "#01ccfe" // 100% 处的颜色
                                }], false),
                                label: {
                                    show: true, //开启显示
                                    position: 'top', //在上方显示
                                    textStyle: { //数值样式
                                        color: '#fff',
                                        fontSize: 12
                                    }
                                }
                            },
                        },
                    }
                ],
            };
            // 使用刚指定的配置项和数据显示图表。
            myChartLeft.setOption(optionLeft);
        }
        //暂无接口,模拟数据
        var xdata = ['00:00', '02:00', '04:00', '06:00', '08:00', '10:00', '12:00', '14:00', '16:00', '18:00', '20:00', '22:00'];
        var ydata = [30, 21, 13, 38, 72, 80, 72, 101, 53, 81, 90, 80];
        TrafficTimeLeft(xdata, ydata);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值