echarts带滚动条的一个案例

项目需求会有很多数据,所以要有滚动条来查看更多数据,看图片:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>首页</title>
    <link rel="stylesheet" href="./css/rest.css">
    <link rel="stylesheet" href="./css/index.css">
    <script src="./js/jquery.min.js"></script>
</head>
<body style="background: #00182e">
    <div class="box">
            <div id="f_domZom" style="width:440px;height: 800px;"></div>
    </div>
<script src="./js/echarts.min.js"></script>
<script src="./js/index.js"></script>
<script>
            var colorList = ['#0081fa', '#d77a94']
            var data = [
                ["汇聚数据", "实际汇聚类型", "剩余汇聚类型"],
                ["公*局", 2, 1],
                ["交**队", 3, 2],
                ["各*******单位", 1, 1],
                ["运*局", 3, 2],
                ["客*办", 2, 1],
                ["公*团", 2, 1],
                ["农*局", 1, 1],
                ["教*育", 1, 1],
                ["城***委", 2, 1],
                ["商*务", 5, 3],
                ["市*管***理局", 2, 1],
                ["卫**委", 2, 1],
                ["生**局", 1, 1],
                ["民***局", 1, 1],
                ["机***理局", 1, 1],
                ["一**通", 1, 1],
                ["互****业", 1, 1],
                ["机***车", 1, 1]
            ]
            var parking_charts = echarts.init(document.getElementById('f_domZom'));

            function autoEchart() {
                var parking_charts_option = {
                    color: colorList,
                    "dataset": {
                        "source": data,
                    },
                    "grid": {
                        "width": '90%',
                        "left": '8%',
                        "right": 40,
                        "bottom": 50,
                        "top": "10%",
                        // "containLabel": true
                    },

                    "xAxis": [{
                        "show": false,
                        position: 'top',
                    }],
                    "yAxis": [{
                        "type": "category",
                        //是否反向坐标轴    
                        "inverse": true,
                        "axisLabel": {
                            "color": "#fff",
                            "fontSize": 14,
                            "fontWeight": "normal",
                            align: 'left',
                            padding: [-80, 0, 0, 10]
                        },
                        max: 20,
                        "show": true,
                        "splitLine": {
                            "show": false,
                        },
                        "axisTick": {
                            "show": false
                        },
                        "axisLine": {
                            "show": false
                        }
                    }],
                    "tooltip": {
                        "show": false,
                        // "trigger": "axis",
                        // "axisPointer": {
                        //     "type": "shadow"
                        // },
                    },
                    "legend": {
                        "show": true,
                        "type": "scroll",
                        "top": 15,
                        "left": "center",
                        "textStyle": {
                            "color": 'white',
                            fontSize: 14
                        },
                    },
                    "series": [{
                        "type": "bar",
                        "name": "汇聚数据",
                        "itemStyle": {
                            "barBorderRadius": 10
                        },
                        "barGap": "50%",
                        barCateGoryGap: 20,
                        // "stack": "total",
                        "label": {
                            "color": "#fff",
                            "fontSize": 14,
                            // position: [0, '-20'],
                            "fontWeight": "normal",
                            "show": true,
                            // formatter: function(data) {
                            //     return chartName[data.dataIndex];
                            // }
                        },
                        "barMaxWidth": 22.22222222222222,
                        "barWidth": 22.22222222222222,
                        "animation": true
                    }, {
                        "type": "bar",
                        "name": "共享数据",
                        "itemStyle": {
                            "barBorderRadius": 10
                        },
                        "barGap": "50%",
                        barCateGoryGap: 20,
                        // "stack": "total",
                        "label": {
                            "color": "#fff",
                            "fontSize": 14,
                            // position: [0, '-20'],
                            "fontWeight": "normal",
                            "show": true,
                            // formatter: function(data) {
                            //     return chartName[data.dataIndex];
                            // }
                        },
                        "barMaxWidth": 22.22222222222222,
                        "barWidth": 22.22222222222222,
                        "animation": true
                    }],
                    "title": {
                        "show": false
                    },
                    // 滚动条
                    "dataZoom": [{
                        type: 'slider',
                        show: true,
                        "filterMode": "empty",
                        "disabled": false,
                        yAxisIndex: 0,
                        // top: '25%',
                        right: '5%',
                        // bottom: '15%',
                        width: 10,
                        start: 0,
                        end: 30,
                        handleSize: '0', // 滑动条的 左右2个滑动小块的大小
                        handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                        textStyle: {
                            color: "#fff"
                        },
                        fillerColor: '#3C62C0', // 拖动条的颜色
                        borderColor: "none",
                        backgroundColor: 'rgba(60, 98, 192, 0.302)',
                        showDetail: false // 即拖拽时候是否显示详细数值信息 默认true
                    }, ],
                }
                parking_charts.setOption(parking_charts_option);
            }
            autoEchart()
</script>
</body>
</html>

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值