-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Reordering echart props to fix confidence interval in Mixed Charts #30716
base: master
Are you sure you want to change the base?
fix: Reordering echart props to fix confidence interval in Mixed Charts #30716
Conversation
@geotab-data-platform I don't see this PR changing enforcing or updating the |
xaxis type defaults to "value" if not reordered and there are negative bound values. When its ordered properly, it uses "time". |
@villebro any updates? |
@vedantprajapati17 I am unable to properly review this PR due to the following:
Also, we would need a minimal unit test to validate that |
@geotab-data-platform please let me know if you need help with this. I'd love to pull this fix in, but in the absence of more clarity on how this fix works it will be difficult to merge this. |
Hi @villebro, Settings Used:Chart Type: Mixed Chart Current BehaviourAs you can see, the confidence interval ranges between (0,15) instead of (-10,5). After the fixSetting the same values we get the following response with correct confidence intervals (-10,5). When you do not reorder the props and send them to echarts as a json to generate the chart, the echarts package will default to an x axis that uses value and not time. Additionally, the props must be ordered in the that specific order as the behaviour will not be as expected otherwise and confidence bands will not be correct. |
Hi @villebro, any updates? |
Any updates on this MR? |
superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts
Outdated
Show resolved
Hide resolved
Running CI... 🤞 |
Seems like it passed? Failled to pull some images for 2 pipelines @rusackas |
Sorry for the delay. I think we're still just agonizing over how this works and whether it's safe to merge, or might just cause some other edge case to appear. If it's possible to add some form of tests (unit tests or end to end tests) that would help immensely. |
It's difficult to validate whether or not a canvas html component looks one way compared to another. Especially when all this function just reorders the series that is being sent. ie no data is removed or added. I can add unit tests validating that the order is changed correctly? @rusackas |
I think the unit test would help... at least it would harden the feature against someone accidentally changing the code in a way that reverts the functionality. |
/testenv up |
tests added |
fix(echarts): confidence interval does not display correctly for mixed time series charts with negative values
SUMMARY
The root cause of this problem lies within the order of the arguments sent to the echarts library. When working with time-series data, Echarts enforces specific constraints on how the x-axis bounds are configured. These constraints include:
In other words, the Echarts Library accepts input in this specific format and will malfunction otherwise. Superset does not create the Echarts modal with the options in this order.
xaxis.type
option must be explicitly set to'time'
.upper
andlower
bound values must be equal to the lower bound.upper
bound must be defined before thelower
bound in the options object.Currently, the code in Superset that generates the Echarts configuration does not adhere to this required format, leading to the observed malfunction. This pull request rectifies this issue by reordering the
upper
andlower
bound arguments before they are passed to the Echarts library.What is currently being sent
What should actually be sent
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
create a mixed chart on the explore menu using confidence intervals where the names__yhat_lower bound is negative at least once.
Verify that confidence Intervals behave as Intended.
names__yhat: trend/point estimate
names__yhat_lower: lower confidence level
names__yhat_upper: upper confidence level
ADDITIONAL INFORMATION
Fixes #30554