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

Save smooth plot values across sessions #4220

Merged
merged 18 commits into from
Jul 14, 2023
Merged

Conversation

julieg18
Copy link
Contributor

@julieg18 julieg18 commented Jul 5, 2023

Demo

Screen.Recording.2023-07-11.at.2.51.42.PM.mov

Part of #3223

@julieg18 julieg18 added the product PR that affects product label Jul 5, 2023
@julieg18 julieg18 self-assigned this Jul 5, 2023
Copy link
Contributor Author

@julieg18 julieg18 left a comment

Choose a reason for hiding this comment

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

I can't figure out why the window's jest tests are failing (posted details in a comment) but everything else is ready to go

@julieg18 julieg18 marked this pull request as ready for review July 10, 2023 16:44
Copy link
Member

@mattseddon mattseddon left a comment

Choose a reason for hiding this comment

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

Few things to work through

@@ -30,6 +31,7 @@ export const ZoomablePlot: React.FC<ZoomablePlotProps> = ({
const { data, content: spec } = useGetPlot(section, id, createdSpec)
const dispatch = useDispatch()
const currentPlotProps = useRef<VegaLiteProps>()
const onPlotViewReady = useSetupSmoothPlot(id)
Copy link
Member

Choose a reason for hiding this comment

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

[C] I think this could have a more descriptive name.

Copy link
Member

Choose a reason for hiding this comment

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

[Q] Also, would it be a better idea to pass this in for smooth plots only instead of calling this for all zoomable plots? Unless I have missed something custom plots should never need to call useSetupSmoothPlot and having the hook floating around for all plots makes things harder to follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Code for smooth plots have now been moved to a react component, which is used for template plots only.

webview/src/plots/hooks/useSetupSmoothPlot.ts Outdated Show resolved Hide resolved
webview/src/plots/hooks/useSetupSmoothPlot.ts Outdated Show resolved Hide resolved
@@ -285,7 +297,8 @@ export class WebviewMessages {
nbItemsPerRow: this.plots.getNbItemsPerRowOrWidth(
PlotsSection.TEMPLATE_PLOTS
),
plots
plots,
smoothPlotValues: this.plots.getSmoothPlotValues()
Copy link
Member

Choose a reason for hiding this comment

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

[Q] What was the reason for keeping this separate from the plots data?

Copy link
Contributor Author

@julieg18 julieg18 Jul 11, 2023

Choose a reason for hiding this comment

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

Didn't think of it 🤦‍♀️.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ended up keeping it separate for now so we could watch for changes to values by just watching the values instead of snapshots which would cause unnecessary checks.

@@ -48,8 +48,9 @@ export const TemplatePlotsGrid: React.FC<TemplatePlotsGridProps> = ({

const addDisabled = useCallback(
(e: Event) => {
const disabledId = (e.currentTarget as HTMLFormElement).parentElement
?.parentElement?.parentElement?.id
const disabledId = (e.currentTarget as HTMLFormElement).closest(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added an extra wrapper for a ref so I changed this code to use closest instead of trying to adjust for another parentElement since this looks cleaner to me. Any reason why we weren't using closest in the first place though?

Copy link
Member

Choose a reason for hiding this comment

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

You would need to go back and check around #2747

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the info! Not seeing any comments on this particular line in the prs relating to this code, but my guess on why we were using parentElement is because it's technically faster since closest keeps checking up to the root. I don't think this code gets fired too often (only when user's mouse enters .vega-actions) so should be alright to use 🤔

@julieg18
Copy link
Contributor Author

Alright resolved/responded to comments and added a debounce timer for keyboard events (thanks for spotting that, @mattseddon!). Going to request reviews since the code has changed quite a bit!

@julieg18 julieg18 requested a review from mattseddon July 12, 2023 14:31
@julieg18 julieg18 enabled auto-merge (squash) July 14, 2023 13:03
@codeclimate
Copy link

codeclimate bot commented Jul 14, 2023

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

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

This pull request will bring the total coverage in the repository to 95.2%.

View more on Code Climate.

@julieg18 julieg18 merged commit e80961b into main Jul 14, 2023
@julieg18 julieg18 deleted the track-smooth-plot-values branch July 14, 2023 13:23
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.

2 participants