【Echarts动态图时序图series传入5个数据, formatter却多返回了5个0,导致第一次渲染5个0回来】
下面我是实现一个排行榜,使用echarts动态时序图,
首次渲染,只渲染一次
发现给seires传入5条数据,x和y轴都是5个,formatter返回了10条数据回来,其中多了5个0。
下面是options。
const option = {
xAxis: {
max: 'dataMax',
axisLabel: {
show: false,
},
splitLine: {
show: false,
},
},
yAxis: {
type: 'category',
data: ['a', 'b', 'c', 'd', 'e'],
inverse: true,
max: 4,
axisLabel: {
show: true,
fontSize: 12,
formatter: (value, index) => '{'+index+'|} {s|' + value + '}',
rich: richObject
},
},
series: [
{
realtimeSort: true,
name: 'X',
type: 'bar',
data: [12, 34, 56, 78, 90],
label: {
show: true,
precision: 1,
valueAnimation: true,
formatter: (params) => {
console.log('=value:', params.value);
if (!params.value) {
return `0`
}
return params.value;
},
},
showBackground: true,
animation: true
}
],
legend: {
show: false
},
};
Y轴data:['a', 'b', 'c', 'd', 'e']
X轴data:[12, 34, 56, 78, 90]
series formatter输出value,
=value:12
=value:34
=value:56
=value:78
=value:90
=value:0
=value:0
=value:0
=value:0
=value:0