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] Persist chart legend filters #92

Merged
merged 7 commits into from
Nov 17, 2023
Merged

Conversation

2Steaks
Copy link
Collaborator

@2Steaks 2Steaks commented Nov 16, 2023

What?

This PR fixes an issue where uPlot is losing it's state every render, in this case it relates to series that are being shown/hidden.

Why?

Every time fresh data is streamed into the application it is overwriting the series data, along with their options to show/hide

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (go run mage.go lint) and all checks pass.
  • I have run tests locally (go run mage.go test) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

@2Steaks 2Steaks requested a review from szkiba November 16, 2023 11:22
@2Steaks 2Steaks self-assigned this Nov 16, 2023
@2Steaks 2Steaks marked this pull request as draft November 16, 2023 11:23
@2Steaks 2Steaks marked this pull request as ready for review November 16, 2023 12:55

export const useOptions = ({ plot, theme, width }: CreateOptionsProps): Options => {
const [series, setSeries] = useState<Series[]>(plot.series)
const newPlot = { ...plot, series: mergeSeries(plot.series, series) }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szkiba this might be overkill, is it possible for plot.series to change over time?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea (uPlot documentation is a little bit limited)

@2Steaks 2Steaks merged commit 58baef2 into master Nov 17, 2023
9 checks passed
@szkiba szkiba deleted the fix/persist-chart-legend branch June 7, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants