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

[question] How to display band as selected (controlled) #15019

Closed
jvskriubakken opened this issue Oct 18, 2024 · 3 comments
Closed

[question] How to display band as selected (controlled) #15019

jvskriubakken opened this issue Oct 18, 2024 · 3 comments
Labels
component: charts This is the name of the generic UI component, not the React module! support: commercial Support request from paid users

Comments

@jvskriubakken
Copy link

jvskriubakken commented Oct 18, 2024

The problem in depth

I'm looking for a way to select an x value in bar chart. I'm thinking of highlighting the x band in the same way it's done when hovering.

Screenshot 2024-10-18 at 14 57 49

The idea is to visualize which month is selected inside the chart. In the image above you see a month selector in the upper right corner. As the user changes the month I want to highlight that month in the chart (more or less in the same manner it's done when hovering the bars/bands along the x-axis).

Maybe I need to write a custom component, that displays just like the hovering backdrop on x axis band?

Your environment

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: charts highlight band
Order ID: #54140

@jvskriubakken jvskriubakken added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels Oct 18, 2024
@github-actions github-actions bot added the component: charts This is the name of the generic UI component, not the React module! label Oct 18, 2024
@alexfauquette
Copy link
Member

Maybe I need to write a custom component, that displays just like the hovering backdrop on x axis band?

I'm not sure about what you mean by "select an x value in bar chart"

You can control the highlight state: https://mui.com/x/react-charts/highlighting/#controlled-highlight

If you want something that look similar to the hover effect, I can recommend you to creat your subcomponent using the band scales

https://mui.com/x/react-charts/components/#scales

Here is the code of the axis highlight. It probably do too many stuff compared to what you're looking for but can be an example. https://github.com/mui/mui-x/blob/master/packages/x-charts/src/ChartsAxisHighlight/ChartsAxisHighlight.tsx

@jvskriubakken
Copy link
Author

Thank for the guidance! I will try it out!

@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 20, 2024
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@jvskriubakken How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

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! support: commercial Support request from paid users
Projects
None yet
Development

No branches or pull requests

2 participants