Toggle navigation
动态滚动柱状图
By
爱***n
2020-07-31 09:38:17
脚本
16
21
作品使用的第三方脚本
数据管理
上传数据
支持小于 5M 任意格式(csv, xlsx, json, xml, ...)的数据文件
上传后可以通过生成的文件链接异步获取托管的数据。
历史数据
0 条
无历史数据
代码修改记录
信息提示
保存作品
对当前截图不满意?你还可以
上传本地截图
重新截图
作品名称
作品描述
标签
geo
grid
legend
markLine
markPoint
bar
effectScatter
line
lines
map
timeline
title
toolbox
tooltip
visualMap
作品默认版本
最新
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
20:11:45
图表已生成
整理代码
刷新
代码
option = { backgroundColor: '#2c3e50', title: { top: 0, left: 0, text: "异常企业与罚款", subtext: "", textStyle: { color: "#fff" } }, tooltip: { trigger: "axis" // axisPointer: { // type: "cross", // crossStyle: { // color: "red" // } // } }, legend: { data: ["超标排放企业数", "超量排放企业数", "罚款总金额"], right: "0", icon: "circle", textStyle: { color: "#fff" } }, grid: { left: "2%", right: "2%", bottom: "0%", containLabel: true }, xAxis: [{ type: "category", data: [ "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" ], axisPointer: { type: "shadow" }, axisLabel: { textStyle: { color: "#fff" }, margin: 18 }, splitLine: { show: false }, axisLine: { // 改变x轴颜色 lineStyle: { color: "#fff" } }, axisTick: { //坐标轴刻度相关设置。 show: false } }], dataZoom: [ //滑动条 { xAxisIndex: 0, //这里是从X轴的0刻度开始 show: true, //是否显示滑动条,不影响使用 type: "slider", // 这个 dataZoom 组件是 slider 型 dataZoom 组件 startValue: 0, // 从头开始。 endValue: 8, // 一次性展示6个 height: 8, //组件高度 bottom: 18, borderColor: "rgba(43,48,67,.8)", fillerColor: "#19D4AE", showDataShadow: false, //是否显示数据阴影 默认auto backgroundColor: "#f4f6f8", showDetail: false, //即拖拽时候是否显示详细数值信息 默认true realtime: false, //是否实时更新 filterMode: "filter" } ], yAxis: [{ type: "value", nameTextStyle: { color: "#fff" }, name: "数量(个)", // min: 0, // max: 250, interval: 50, axisLabel: { formatter: "{value}", textStyle: { color: "#fff" } }, splitLine: { show: false }, axisLine: { // 改变x轴颜色 lineStyle: { color: "#fff" } }, axisTick: { //坐标轴刻度相关设置。 show: false } }, { type: "value", nameTextStyle: { color: "#fff" }, name: "金额(万)", // min: 0, // max: 25, interval: 5, axisLabel: { formatter: "{value}", textStyle: { color: "#fff" } }, splitLine: { show: false }, axisLine: { // 改变x轴颜色 lineStyle: { color: "#fff" } }, axisTick: { //坐标轴刻度相关设置。 show: false } } ], series: [{ name: "超标排放企业数", type: "bar", itemStyle: { normal: { color: "#96edc1" // barBorderRadius: [10, 10, 0, 0] } }, barMaxWidth: 20, data: [ 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3 ] }, { name: "超量排放企业数", itemStyle: { normal: { color: "#b6c2ff" // barBorderRadius: [10, 10, 0, 0] } }, barMaxWidth: 20, type: "bar", data: [ 2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3 ] }, { name: "罚款总金额", type: "line", smooth: true, yAxisIndex: 1, itemStyle: { normal: { color: "#FFE180" } }, data: [ 2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2 ] } ] }; setInterval(function() { // 每次向后滚动一个,最后一个从头开始。 if (option.dataZoom[0].endValue == 12) { option.dataZoom[0].endValue = 8; option.dataZoom[0].startValue = 0; } else { option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1; option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1; } myChart.setOption(option); }, 2000); window.addEventListener("resize", () => { // 自动渲染echarts myChart.resize(); });