Toggle navigation
柱状图数据不同分配不同颜色
By
X***s
2018-12-03 09:30:26
脚本
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 = { textStyle: { color: '#fff' //全局的文字颜色 }, backgroundColor: '#070d18',//统计图的背景色 title: { text: '全班英语成绩统计',//统计图的名称 textStyle: { color: '#fff' //名称的颜色 }, }, tooltip: {//提示框 trigger: 'axis',//提示框提示方式,axis为一般的统计图 formatter: '英语成绩:{c}',//提示框提示的信息 }, grid: {//统计图的边缘距离 left: '3%', right: '4%', bottom: '12%', top: '10%', containLabel: true//边缘距离是否包含坐标轴刻度的宽高 }, legend: {//图例 data: ['百分比'],//图例名称 textStyle: { color: '#fff'//图例文字颜色 }, }, xAxis: [{//X轴 type: 'category',//坐标轴类型,图中都是中文字没有关联所以是离散类型 data: ['王健林', '马云', '李白', '周星驰', '潘晓婷', '理查德克莱德曼', '艾希诺夫斯诺夫斯基', '希尔瓦娜斯', '邱少云', '梁静茹', '黄秋生'], axisLabel: { rotate: 30,//名称旋转角度 show: true,//是否显示 interval:0 }, axisPointer: {//X轴上鼠标悬浮效果的指示器 type: 'shadow',//指示器类型为阴影指示器 label:{ show:false//文字是否显示 } }, }, ], yAxis: [{ type: 'value',//Y轴类型为连续的数据 splitLine: { //Y轴的线条 show: true, lineStyle: { color: '#2e3547' } }, splitNumber: 5, //y轴的分段数量 axisLabel: { formatter: '{value} 分' //y轴的数据单位 }, max:100 //y轴最大数值 }], series: [{ name: '百分比', //名称 type: 'bar', //柱状图类型 barWidth: '25%',//数据柱状宽度 data: [95, 80, 95, 59, 96, 100, 88, 75, 48, 75, 85], markLine: {//数据标准线 data: [{ name: '标准值为90', //数值名称 yAxis: 90, coord:['马云','潘晓婷']//数值大小 }, ], label: { normal: { show: false //是否显示数值 } }, lineStyle: { normal: { color: '#ea4548',//标准线颜色 width: 2//标准线宽度 } }, }, itemStyle: { //图形样式 normal: { barBorderRadius: [18, 18, 0, 0],//柱状圆角,左上,右上,右下,左下 color: function(params) { //柱状颜色 var index_color = params.value; //获取柱状数值 if (index_color <= 60) { //低于六十分 return new echarts.graphic.LinearGradient( 0, 0, 0, 1, [{ //颜色渐变,左,上,右,下 offset: 0, color: '#f86c4d' }, { offset: 0.5, color: '#e43446' }, { offset: 1, color: '#ed4d49' } ] ) } else if (index_color > 60 && index_color < 90) { return new echarts.graphic.LinearGradient( 0, 0, 0, 1, [{ offset: 0, color: '#e8eb15' }, { offset: 0.5, color: '#ebc017' }, { offset: 1, color: '#eba715' } ] ) } else if (index_color >= 90) { return new echarts.graphic.LinearGradient( 0, 0, 0, 1, [{ offset: 0, color: '#8dd76f' }, { offset: 0.5, color: '#43c798' }, { offset: 1, color: '#15beb1' } ] ) } } } }, }, ] };