项目需求会有很多数据,所以要有滚动条来查看更多数据,看图片:
<!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>