Version
5.4.3
Link to Minimal Reproduction
Steps to Reproduce
option = {
tooltip: {
trigger: 'axis'
},
grid: {
left: '3%',
right: '5%',
bottom: '15%',
containLabel: true
},
toolbox: {
feature: {
dataZoom: {
yAxisIndex: 'none'
},
restore: {},
saveAsImage: {}
},
right: '3%'
},
dataZoom: [
{
type: 'slider',
filterMode: 'weakFilter',
showDataShadow: true
}
],
legend: {
show: false
},
xAxis: {
type: 'time',
axisLabel: {
showMinLabel: true,
showMaxLabel: true
}
},
yAxis: {
type: 'value',
name: 'mbps'
},
series: [
{
type: 'line',
smooth: true,
name: 'video estimated bandwidth',
data: [
[1670233630410, 4.032],
[1670233630561, 4.032],
[1670233630571, 4.032],
[1670233630652, 4.032],
[1670233631600, 4.032],
[1670233643032, 4.032],
[1670233643062, 1.008],
[1670233643062, 3.024],
[1670233643062, 4.032],
[1670234848824, 4.032]
]
}
]
};
Current Behavior
When type = line and the x-axis has more than one of the same data, the linking order does not follow the order of the incoming data.
Expected Behavior
In my case,
series: [
{
type: 'line',
smooth: true,
name: 'video estimated bandwidth',
data: [
[1670233630410, 4.032],
[1670233630561, 4.032],
[1670233630571, 4.032],
[1670233630652, 4.032],
[1670233631600, 4.032],
[1670233643032, 4.032],-------------------------------------
[1670233643062, 1.008], ---↑ they should be connected. ↑
[1670233643062, 3.024], ↑
[1670233643062, 4.032], ------------------------------------↑ but they are connected
[1670234848824, 4.032]
]
}
]
Environment
- OS: Macos 13.5 (22G74)
- Browser: Chrome 116.0.5845.140 (Official Build) (arm64)
- Framework: React@18
Any additional comments?
No response
3条答案
按热度按时间9rbhqvlz1#
FIX #19062
CLOSE #19062
does you want it to be like this:
if yes then it was happening becase of data[][0](x-axis values) has multiple same value
i changed data to :
data: [
[1, 4.032],
[2, 4.032],
[3, 4.032],
[4, 4.032],
[5, 4.032],
[6, 4.032],
[7, 1.008],
[8, 3.024],
[9, 4.032],
[10, 4.032]
]
tnkciper2#
Yeah, I know in this case, the chart is correct. But in my needs, there will be the same data, under this premise, the data connection order of the chart is not correct.
kmb7vmvb3#
you can use a function to add value of same key
function sumValuesByKey(data: number[][]): number[][] {
const resultMap = new Map<number, number>();
for (const [key, value] of data) {
if (resultMap.has(key)) resultMap.set(key, resultMap.get(key)! + value);
else resultMap.set(key, value);
}
const resultArray: number[][] = [];
for (const [key, value] of resultMap) {
resultArray.push([key, value]);
}
return resultArray;
}