apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.28k stars 19.61k forks source link

[Bug] Stacked bars do not work on time x axis when data is not fully synchronized #20254

Open kianj2 opened 1 month ago

kianj2 commented 1 month ago

Version

5.5.1

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?c=bar-stack&lang=ts&code=PYBwLglsB2AEC8sDeAoWszGAG0iAXMmuhgE4QDmFApqYQOQCGAHhAM73EC-ANMcwEFWbQqhIYAniGoNIAW2qd0vYhKHtRxdGCkzY9AG6NsAV0Xc-6NrQjURsANpai47boYAjRqXqXXbMEYAYwBrBgAzLF9ndAATRkDCBwdoagB3WAARBOoACnoAJgAGAoAWAFoigEZKqoAVavwioqaigC16AEoeWAKAXT7nFXExVx1pT29o11gA4LD9SOBp13jExxiSFPSsnPzistrahpbm1o7u2Cq-vxntjOywPMKSiurjxrPmi57r29d7rsnvtXkdqg0Cq1zl1foMZnCSFxiIMuABuIA

Steps to Reproduce

  1. View chart

Current Behavior

Rendering of series breaks (see first bar in the linked example) and bars are not stacked but instead overlapping.

Expected Behavior

Series should stack where timestamps overlap. When timestamps do not overlap the stack should only consider data that exists at the given timestamp.

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

I have seen this comment in a similar issue. That comment advises to preprocess the data so that null values are written where timestamps do not overlap. However, if there is a lot of data it would be nice to avoid this preprocessing. In addition, it feels reasonable to assume that stacking will only occur where timestamps are the same even without preprocessing the data.

The documentation mentions that time and category axis are not supported, but I am assuming this applies to the y axis since the apache echarts stacked bar examples use category axis and it works fine. This would imply to me that time x axis is supported for stacking.

Am I missing something here? Is the preprocessing the intended way to use bar stacking? I feel that the functionality I described where preprocessing isn't needed sounds reasonable.

I opened a new issue because this seems slightly different than the linked one. To me, the linked one is saying stacking bars on a time axis does not work at all. Here, it seems that stacking bars on a time axis can sometimes work but sometimes breaks. And according to the documentation, it does not say that it is unsupported.

gggdomi commented 1 month ago

I agree. Sure I can do the pre-processing, but this is just confusing. No one reasonably expects this data to output this graph. Some may say it's not a bug, but it will look like a bug to any fresh eyes. And be reported as such, and lower trust in the lib. Plus it makes the lib less convenient, for very basic use-cases.

Capture d’écran 2024-08-31 à 16 21 58

This is the natural output for the given data:

Capture d’écran 2024-08-31 à 16 29 26

kianj2 commented 2 weeks ago

Commenting to increase visibility on this issue. This is an important use case to my team and it also seems like a likely use case for others.