Skip to content
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 visualization chart not expanded after legend toggle #9170

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wanglam
Copy link
Contributor

@wanglam wanglam commented Jan 10, 2025

Description

This PR fixes an issue where the chart was not expanding after hiding the legend. The root cause was that the VisLegend component was using vis.getUiState() as the uiState, which was different from the uiState in the VisualizationChart component. According to the code in visualization_chart, it was using this.props.uiState. Therefore, changes to vis.legendOpen were not triggering a re-render in VisualizationChart.

To resolve this issue, I added a uiState synchronization logic in src/plugins/visualizations/public/expressions/visualization_renderer.tsx. This logic compares the visState in vis and calls setState to ensure that the two uiState instances are the same. As a result, the chart will be resized correctly.

Issues Resolved

#9143

Screenshot

Testing the changes

  1. Import "Sample web logs" sample data
  2. Create a new dashboard with "(Line) Avg bytes over time"
  3. Update a close time range like "15 seconds ago", the chart will become no results like screenshot below
    image
  4. Update time range to very early like "15 years ago"
  5. Click "Toggle legend" on the bottom left, the chart should expanded after legend hide
    image

Changelog

  • fix: Visualization chart not expanded after legend toggle

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: Lin Wang <[email protected]>
Copy link
Contributor

❌ Empty Changelog Section

The Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 61.01%. Comparing base (e401613) to head (5b9eef4).

Files with missing lines Patch % Lines
...ions/public/expressions/visualization_renderer.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9170      +/-   ##
==========================================
- Coverage   61.02%   61.01%   -0.01%     
==========================================
  Files        3813     3813              
  Lines       91396    91398       +2     
  Branches    14439    14440       +1     
==========================================
  Hits        55771    55771              
- Misses      32067    32069       +2     
  Partials     3558     3558              
Flag Coverage Δ
Linux_1 29.08% <0.00%> (-0.01%) ⬇️
Linux_2 56.45% <ø> (ø)
Linux_3 38.03% <0.00%> (-0.01%) ⬇️
Linux_4 29.03% <ø> (ø)
Windows_1 29.09% <0.00%> (-0.01%) ⬇️
Windows_2 56.40% <ø> (ø)
Windows_3 38.03% <0.00%> (+<0.01%) ⬆️
Windows_4 29.03% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants