-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix bars turning green issue when switching from a graph with empty data #20436
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
Conversation
|
| App Name | WordPress |
|
| Flavor | Jalapeno | |
| Build Type | Debug | |
| Version | pr20436-02daa2b | |
| Commit | 02daa2b | |
| Direct Download | wordpress-prototype-build-pr20436-02daa2b.apk |
|
| App Name | Jetpack |
|
| Flavor | Jalapeno | |
| Build Type | Debug | |
| Version | pr20436-02daa2b | |
| Commit | 02daa2b | |
| Direct Download | jetpack-prototype-build-pr20436-02daa2b.apk |
| dataSet.color = ContextCompat.getColor(context, R.color.blue_50) | ||
| dataSet.setGradientColor( | ||
| ContextCompat.getColor( | ||
| context, | ||
| R.color.blue_50 | ||
| ), ContextCompat.getColor( | ||
| context, | ||
| R.color.blue_50 | ||
| ) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be a bug from the chart library. Although we're updating dataSet of the BarChart, BarCharts BarChartRenderer is still using gradient colors from the previous chart.
I see a minor side effect of setting gradient colors again here. It causes the chart to render gradient color as a single color, an unnecessary process from the performance perspective.
May I suggest a simpler alternative solution? By setting the shader to null, we can prevent BarChartRenderers from drawing gradient. Wdyt?
| dataSet.color = ContextCompat.getColor(context, R.color.blue_50) | |
| dataSet.setGradientColor( | |
| ContextCompat.getColor( | |
| context, | |
| R.color.blue_50 | |
| ), ContextCompat.getColor( | |
| context, | |
| R.color.blue_50 | |
| ) | |
| ) | |
| chart.renderer.paintRender.shader = null | |
| dataSet.color = ContextCompat.getColor(context, R.color.blue_50) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @irfano thanks for the suggestion! Yes, I agree that it's an issue with the library itself. I was concerned about the unnecessary process as well but noticed that BarChartViewHolder uses a similar workaround (lines 233-241 and 256-264):
ContextCompat.getColor(
context,
R.color.stats_bar_chart_top
), ContextCompat.getColor(
context,
R.color.stats_bar_chart_top
)
)
I can go ahead and update the usage in TrafficBarChartViewHolder, but do you think it's a good idea to update these other occurrences as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we can update it on both places. I tested my suggestion and didn't notice any issues.
|
Hi @irfano, I pushed the changes we discussed above so it's ready if you'd like to take another look. Thanks! |
|
irfano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍🏻






Fixes #20413
This PR fixes an issue where bars for all graphs would turn a
gradient greenafter navigating to a graph with empty data. Only categories with no data should display thegradient greenbars and all other categories with data should havebluebars.To Test:
mobile.blogsite for testing which currently has0 commentsin the month view.viewsor any other category with data. The bars should change toblueand not remaingradient green.Video of bug occurring after clicking
likesorcomments(empty data) and then navigating back toviewsorvisitors:Screen_Recording_20240305_141423_Jetpack.Beta.mp4
Regression Notes
Potential unintended areas of impact
What I did to test those areas of impact (or what existing automated tests I relied on)
What automated tests I added (or what prevented me from doing so)
PR Submission Checklist:
RELEASE-NOTES.txtif necessary.Testing Checklist (strike-out the not-applying and unnecessary ones):