Toggle navigation
数量统计水平柱状图
By
可***联
2020-12-16 07:46:34
脚本
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
图表已生成
整理代码
刷新
代码
var category= [{ name: "1", value: 2 }, { name: "2", value: 7 }, { name: "3", value: 8 } ]; // 类别 var total = 30; // 数据总数 var datas = []; category.forEach(value => { datas.push(value.value); }); option = { backgroundColor: 'trasparent', xAxis: { max: total, splitLine: { show: false }, axisLine: { show: false }, axisLabel: { show: false }, axisTick: { show: false }, }, grid: { left: 100, top: 100, // 设置条形图的边距 right: 150, bottom: 100 }, yAxis: [{ type: "category", inverse: false, data: ["三级防线", "二级防线", "一级防线"], axisLine: { show: false }, axisTick: { show: false }, axisLabel: { verticalAlign: "bottom", align: "left", padding: [10, 10, 30, 10], textStyle: { fontSize: 14, color: "white" }, formatter(value, index) { return value; } } }], series: [ { // total count bar type: "pictorialBar", itemStyle: { normal: { color: "#07314a" } }, symbolRepeat: "fixed", symbolMargin: 2, symbol: "roundRect", symbolClip: true, symbolSize: [5, 18], symbolPosition: "start", symbolOffset: [3, -4], symbolBoundingData: this.total, data: [total, total, total], z: 2, animationEasing: "elasticOut" }, { // current count bar type: "pictorialBar", itemStyle: { normal: { color: "#70faf2" } }, symbolRepeat: "fixed", symbolMargin: 2, symbol: "roundRect", symbolClip: true, symbolSize: [5, 18], symbolPosition: "start", symbolOffset: [3, -4], symbolBoundingData: this.total, data: datas, z: 2, animationEasing: "elasticOut", }, { // label type: "pictorialBar", symbolBoundingData: total, itemStyle: { normal: { color: "none" } }, label: { normal: { formatter: (params) => { var text; text = '{f| ' + params.data + '个}'; return text; }, rich: { f: { color: "#ffffff" } }, position: 'right', distance: 10, // 向右偏移位置 show: true } }, data: datas, z: 0, }, { name: "外框", type: "bar", barGap: "-130%", // 设置外框粗细 data: [total, total, total], barWidth: 45, itemStyle: { normal: { barBorderRadius: [5, 5, 5], color: "transparent", // 填充色 barBorderColor: "#1588D1", // 边框色 barBorderWidth: 0, // 边框宽度 } }, z: 0 } ] }