以下在移动端中发现的问题:
1、移入图标后,几秒后失去焦点
_timer && clearTimeout(_timer);
_timer = setTimeout(()=>{
myChart.dispatchAction({
type: 'updateAxisPointer',
currTrigger: 'leave'
})
},2000)
2、设置选中竖直线样式
axisPointer: {
type: 'line',
snap:false,
lineStyle: {
color: '#6C7480',
width:0.5
},
},
3、如果想准确的设置几个等分,单单设置splitNumber 是不行的,这个属性只是个预估值,会随着数据变化而变化,准确的做法是设置min max ,然后设置interval:(max-min)/(需要几等份);
4、设计中常常会遇到参数位置,忽上忽下,忽左忽右,这时候就需要结合formatter rich 这2个属性同时使用,
比如,markPoint 这个属性上设置了最大值和最小值,防止锚点上的值超出图标,做法是将x轴3等分,左边部分锚点是右对齐,中间部分居中,右边部分左对齐;
formatter: function (params){
const _length = ${state.chartsAll['line']?.length ?? 0} -1;
const minIndex = _length*0.3;
const maxIndex = _length*0.9;
const index = params.data['coord'][0];
let key ='c';
if(index < minIndex){
key = 'a'
}
if(index > maxIndex){
key = 'b'
}
return '{'+key+'|'+splitThousands(params.value,2)+'}';
},
rich:{
a: {
width: '100%',
align: 'left',
},
b: {
width: '100%',
align: 'right',
},
c: {
width: '100%',
align: 'center',
},
...
},