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

[charts] Explanation of tooltip value formatting #12442

Closed
mAllenBond opened this issue Mar 13, 2024 · 3 comments · Fixed by #12700
Closed

[charts] Explanation of tooltip value formatting #12442

mAllenBond opened this issue Mar 13, 2024 · 3 comments · Fixed by #12700
Assignees
Labels
docs Improvements or additions to the documentation enhancement This is not a bug, nor a new feature recipe support: docs-feedback Feedback from documentation page

Comments

@mAllenBond
Copy link

mAllenBond commented Mar 13, 2024

Related page

https://next.mui.com/x/react-charts/tooltip/

Kind of issue

Missing information

Issue description

Use case:

I have a chart, and I have axis values, and I want to embellish those values in the tooltip, which seems like a pretty common use case. I achieved this via axisContent.axis in slotProps.

Example sandbox here

Screenshot

Screenshot 2024-03-13 at 10 43 37 AM

Issue:

What I haven't seen is any information in the docs explaining how to do exactly this, or even if the approach in the sandbox example is correct (As an aside, I get a type error when doing this in my dev env, and the object it expects for the axis seems incorrectly typed). The information around overriding/customizing tooltips in general is pretty opaque, but I'm pretty certain this is a very common use case.

I think a simple demo around this and some docs would be really helpful.

Context

Add a documentation snippet for customizing/embellishing axis content in the tooltip in MUI Chart Tooltip docs without overriding the whole tooltip component, ALA Sandbox

Search keywords: charts tooltip

@mAllenBond mAllenBond added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: docs-feedback Feedback from documentation page labels Mar 13, 2024
@michelengelen michelengelen added docs Improvements or additions to the documentation enhancement This is not a bug, nor a new feature recipe and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 14, 2024
@michelengelen michelengelen changed the title [docs] Explanation of tooltip value formatting [charts] Explanation of tooltip value formatting Mar 14, 2024
@michelengelen
Copy link
Member

Hey @mbond-SCW and thanks for raising this issue.
I did add this to our board for the team to take a look!
Thanks again! 🙇🏼

@alexfauquette
Copy link
Member

You might be interested by the feature in #12172 and documented here: https://next.mui.com/x/react-charts/axis/#axis-formatter

Basically your axis.valueFormatter will get a context in second argument allowing you to to

axis.valueFormatter = (value, context) => 
  context.location === 'tooltip' ?
    `Id do what I want ${value}`
    : value.toString()

But I agree documenting it in the tooltip page is a good idea

Copy link

github-actions bot commented Apr 8, 2024

⚠️ 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.

@mbond-SCW: 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
docs Improvements or additions to the documentation enhancement This is not a bug, nor a new feature recipe support: docs-feedback Feedback from documentation page
Projects
None yet
4 participants