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

Add legend to zoomed in plots #1794

Merged
merged 7 commits into from
Jun 1, 2022
Merged

Add legend to zoomed in plots #1794

merged 7 commits into from
Jun 1, 2022

Conversation

mattseddon
Copy link
Member

@mattseddon mattseddon commented May 30, 2022

Closes #1782 by adding the relevant legend to zoomed-in plots (both Data Series & Trends).

Demo

Screen.Recording.2022-06-01.at.10.02.10.am.mov
Screen.Recording.2022-06-01.at.10.01.41.am.mov
Screen.Recording.2022-06-01.at.10.08.32.am.mov

Thanks to @sroy3 for assisting my mash potato brain with fixing some bugs in this PR!

@mattseddon mattseddon added the product PR that affects product label May 30, 2022
@mattseddon mattseddon self-assigned this May 30, 2022
@mattseddon mattseddon force-pushed the add-legend-to-zoomed branch from ed8d770 to 170100d Compare May 31, 2022 06:29
@mattseddon mattseddon marked this pull request as ready for review May 31, 2022 06:36
@mattseddon mattseddon marked this pull request as draft May 31, 2022 07:00
@mattseddon mattseddon marked this pull request as ready for review May 31, 2022 12:18
$schema: 'https://vega.github.io/schema/vega-lite/v5.json',
data: { name: 'values' },
encoding: {
color: {
Copy link
Member Author

Choose a reason for hiding this comment

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

[F] The change is to move the color out here so that we can overwrite it in the same way we do for Data Series plots.

@mattseddon mattseddon requested review from sroy3, rogermparent, shcheklein and wolmir and removed request for wolmir, shcheklein, sroy3 and rogermparent May 31, 2022 12:19
@mattseddon mattseddon marked this pull request as draft May 31, 2022 12:23
Copy link
Contributor

@sroy3 sroy3 left a comment

Choose a reason for hiding this comment

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

I know this isn't ready for review, but wanted to see if I could help on your bug

checkpoint plots will not render with their legend if they are the first plot that has been zoomed in the plots view

I pulled your branch and wasn't able to reproduce. Though removing all plots and adding them again, the legend is sometimes in all the plots:

Screen.Recording.2022-05-31.at.11.01.04.AM.mov

I think that this can be solved by applying the change I mentioned about removeLegendSuppression.

const handleZoomInPlot = useCallback(
(props: VegaLiteProps, id: string, refresh?: boolean) => {
if (!refresh) {
setZoomedInPlotWithLegend(props)
setZoomedInPlot(removeLegendSuppression(props))
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having removeLegendSuppression everywhere, can we just add its content to the VegaLite component on line 159?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is definitely the better way to go. I still have a couple of issues hanging around though:

  1. The Storybook is completely cooked. Legend's randomly turn up in plots on random stories.
  2. useEffect in <ZoomablePlot/> causes an infinite loop if you don't exclude disabling of the legend from the props comparison at the top of the function.

Will investigate more today with a fresher(-ish) mind. Thanks a lot for looking!

@mattseddon mattseddon marked this pull request as ready for review June 1, 2022 00:06
@mattseddon mattseddon enabled auto-merge (squash) June 1, 2022 18:46
@codeclimate
Copy link

codeclimate bot commented Jun 1, 2022

Code Climate has analyzed commit 0f7848f and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (85% is the threshold).

This pull request will bring the total coverage in the repository to 96.8% (0.0% change).

View more on Code Climate.

@mattseddon mattseddon merged commit 51e63cf into main Jun 1, 2022
@mattseddon mattseddon deleted the add-legend-to-zoomed branch June 1, 2022 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR that affects product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add legend upon plot saving
2 participants