Skip to content

[charts] Update zoom slider design #17682

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

Merged

Conversation

bernardobelchior
Copy link
Member

@bernardobelchior bernardobelchior commented May 5, 2025

Part of #15383.

Update zoom slider to follow the designs:

image

Implementation:

image image

Copy link

github-actions bot commented May 5, 2025

Thanks for adding a type label to the PR! 👍

@bernardobelchior bernardobelchior added enhancement This is not a bug, nor a new feature component: charts This is the name of the generic UI component, not the React module! labels May 5, 2025
@mui-bot
Copy link

mui-bot commented May 5, 2025

Copy link

codspeed-hq bot commented May 5, 2025

CodSpeed Performance Report

Merging #17682 will not alter performance

Comparing bernardobelchior:update-zoom-slider-design (47aab94) with master (31dccb6)

Summary

✅ 8 untouched benchmarks

@bernardobelchior bernardobelchior force-pushed the update-zoom-slider-design branch from f4f3118 to ba7b621 Compare May 5, 2025 10:31
@bernardobelchior bernardobelchior marked this pull request as ready for review May 5, 2025 12:03
Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

Looks nice, I did not took time to deeply review the slider implementation update. But I like the constants you introduced 👍

const data = Array.from({ length: dataLength }).map((_, i) => ({
x: i,
y: 50 + Math.sin(i / 5) * 25,
}));
const series2Data = Array.from({ length: dataLength }).map((_, i) => ({
x: i,
x: i + 10,
Copy link
Member

Choose a reason for hiding this comment

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

If your issue is the fact that initially both series perfectly overlap, the easiest might be to modify the frequency, with something like Math.sin(i / 10)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that was the idea. I'll see if that looks better

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks good 👍

@@ -62,8 +62,6 @@ You can provide an overview and allow the manipulation of the zoomed area by set

{{"demo": "ZoomSlider.js"}}

Optionally, you can set the `zoom.slider.size` property to customize the zoom slider's size, that is, the height on an x-axis and the width on a y-axis.
Copy link
Member

Choose a reason for hiding this comment

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

I assume you removed this option because the size might vary according to the presence or not of the preview.

If yes, I would be in favor of keeping it, and adapting the default value according to the presence (or not) of a preview (when we introduce it).

This size does not need to be the size of the slider itself, but the size allocated to render the slider.

Basically here you would keep all you constants, and use the ZOOM_SLIDER_SIZE as a default value for zoom.slider.size. Such that users could create smaller/larger sliders and use adapt this value

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this option because the size is now kind of fixed. If we increase the size, how do we scale all the components of the slider?

and use the ZOOM_SLIDER_SIZE as a default value for zoom.slider.size. Such that users could create smaller/larger sliders and use adapt this value

And center the slider in that size? Yeah, I could do that. We would need to have a minimum value, though, to avoid bleeding onto other elements of the chart. We could remove the internal concept of margin in that case.

Copy link
Member

Choose a reason for hiding this comment

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

We could remove the internal concept of margin in that case.

For me you can keep all the rest as it is.

The component renders a fixed size slider, but the size available for the slider can be customized.

For now the only usage would be if a user create his own super small slider and then need to set zoom.slider.size = 10.

But I assume with time we will make the creation of custom slider easier and easier so it worths keeping this entry point

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense. I'll bring that code back in a follow-up where we allow the slider to be customized using a slot.

Copy link
Member Author

Choose a reason for hiding this comment

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

PR: #17736

Comment on lines 424 to 425
{ "name": "ZOOM_SLIDER_MARGIN", "kind": "Variable" },
{ "name": "ZOOM_SLIDER_SIZE", "kind": "Variable" }
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to export those values?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it was an oversight

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 5, 2025
Copy link

github-actions bot commented May 5, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@bernardobelchior bernardobelchior force-pushed the update-zoom-slider-design branch from f272e5d to 47aab94 Compare May 5, 2025 16:20
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 5, 2025
@bernardobelchior bernardobelchior merged commit 94211fd into mui:master May 6, 2025
22 checks passed
@bernardobelchior bernardobelchior deleted the update-zoom-slider-design branch May 7, 2025 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants