apache / apache/echarts

[Bug] Chart with multiple line serieses is missing datapoints depending on dataset declaration order

Open
#20,949 3 comments 1 reaction 0 assignees View on GitHub
bug en pending
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### Version

5.6.0

### Link to Minimal Reproduction

https://codesandbox.io/p/sandbox/basic-line-chart-srp85k

### Steps to Reproduce

We have a simple chart with two line serieses.
Both X and Y axis use `"value"` as their `type` (it can also be shown that type `"date"` for Y axis would result in same issue).

* Series 1 uses 'smallX' and 'smallY' as its dataset source, where the small dataset consists of only 3 points.
* Series 2 uses 'largeX' and 'largeY' as its dataset source, where the large dataset consists of 13 points.

Depending on the ordering of the dataset entries (i.e. whether `smallX` and `smallY` are declared before `largeX` and `largeY` (or not), the second series renders only its first 3 points from the large dataset, rather than 13 points.

To hotfix around this problem, the largest dataset has to be defined first.
This issue should be addressed by rendering all datapoints independent of the dataset declaration order.

```js
// Does not render all datapoints
option = {
xAxis: {
type: 'value'
},
yAxis: {
type: 'value'
},
series: [
{
type: 'line',
encode: {
x: 'smallX',
y: 'smallY'
}
},
{
type: 'line',
encode: {
x: 'largeX',
y: 'largeY'
}
}
],
dataset: [
{
source: {
// Order of dataset lengths is crucial here!
smallX: [10, 20, 30],
smallY: [3.141, 7, 5],
largeX: [9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],
largeY: [1, 2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15]
}
}
]
};
```

```js
// Does render all datapoints
option = {
xAxis: {
type: 'value'
},
yAxis: {
type: 'value'
},
series: [
{
type: 'line',
encode: {
x: 'smallX',
y: 'smallY'
}
},
{
type: 'line',
encode: {
x: 'largeX',
y: 'largeY'
}
}
],
dataset: [
{
source: {
// Ordering from high to lower dataset lengths is crucial here!
largeX: [9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],
largeY: [1, 2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15],
smallX: [10, 20, 30],
smallY: [3.141, 7, 5]
}
}
]
};
```

### Current Behavior

Second line series does not render all datapoints depending on declaration order and length of first dataset. This issue also occurs for charts with more than two line serieses.

![Image](https://github.com/user-attachments/assets/a58a69b9-7c5c-4e21-b8d0-baa294f2e048)

### Expected Behavior

All line series should render their full dataset independent of dataset declaration order and length.

![Image](https://github.com/user-attachments/assets/471608bd-7e2e-4545-8e27-b9f152b91a83)

### Environment

```markdown
- OS: All
- Browser: All
- Framework: All
```

### Any additional comments?

Thanks for providing and contributing to this great library 😄

Best regards
Markus

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.