本文共 936 字,大约阅读时间需要 3 分钟。
// 0, 0, 0, 1 代表右/下/左/上// offset 范围0-1 表示什么时候开始使用对应颜色color: new echarts.graphic.LinearGradient( 0, 0, 0, 1, [ { offset: 0, color: 'red'}, // 开始位置 // {offset: 0.5, color: 'green'}, { offset: 1, color: 'skyblue'} // 结束位置 ] )
示例 :
1,0,0,0 从右开始 (红色开始色)1,1,0,0 右上(红色开始色)
1,0,1,0 右左不存在, 所以不显示
空1,0,0,1 右下(红色开始色)
1,1,1,0 右上左(红色开始色) 效果等同 0,1,0,0
1,0,1,1 右左下(红色开始色) 效果等同 0,0,0,1
1,1,0,1 右上下(红色开始色) 效果等同 1,0,0,0
测试用代码
option = { xAxis: { type: 'category', data: ['渐变色'] }, yAxis: { }, series: [{ data: [120], type: 'bar', itemStyle:{ color:new echarts.graphic.LinearGradient( 1, 0, 0, 0, [ { offset: 0, color: 'red'}, // {offset: 0.5, color: 'green'}, { offset: 1, color: 'skyblue'} ] ) } }]};
转载地址:http://itrxi.baihongyu.com/