visualMap[i]-piecewise.pieces以0分段问题
One-line summary [问题简述]
我想实现以0为分界线,实现大于0的部分做处理,小于0的部分做处理
,但是
pieces: [{
lte: 0,
color: 'rgba(0,0,255,0.6)'
}, {
gt: 0,
color: 'rgba(255,0,0,0.6)'
}]
报错。
Version & Environment [版本及环境]
- ECharts version [ECharts 版本]:echart3
- Browser version [浏览器类型和版本]:chrome
- OS Version [操作系统类型和版本]:win
Expected behaviour [期望结果]
ECharts option [ECharts配置项]
option = {
title: {
text: '到期损益'
},
tooltip : {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
legend: {
data:['到期损益']
},
visualMap: {
top: 10,
right: 10,
pieces: [{
// gt: -500,
lte: 0,
color: 'rgba(0,0,255,1)'
}, {
gt: 0,
// lte: 500,
color: 'rgba(255,0,0,1)'
}]
,
outOfRange: {
color: '#999'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
boundaryGap : false,
splitLine:{
show:true
},
data:[7,8,9,10,11,12,13]
}
],
yAxis : [
{
type : 'value'
}
],
series : [
{
name:'到期损益',
type:'line',
stack: '总量',
areaStyle: {normal: {
}},
data:[90,80,-10,90,10,-50,-40]
}
]
}
Other comments [其他信息]
如果把 pieces: [{ // gt: -500, lte: 0, color: 'rgba(0,0,255,1)' }, { gt: 0, // lte: 500, color: 'rgba(255,0,0,1)' }] 注释掉的两行打开任意一行就可以显示,但是不能实现我就想以0分隔两段吗?
https://github.com/apache/incubator-echarts/blob/master/src/component/visualMap/PiecewiseModel.js#L372 stops is empty array will cause this problem.
遇到同样的问题,只能讨巧,中间加一个范围很小的分段 pieces = [ { min: top, color: '#FF0000' }, { min: top - 0.001, max: .top, color: '#00BB58' }, { max: top - 0.001, color: '#00BB58' }]
This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.
This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!
@mmfjx's workaround is valid - Demo Code
