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

[docs] Improve slots definitions for charts #12408

Merged
merged 4 commits into from
Mar 14, 2024

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Mar 11, 2024

Fix #12268
Fix #10352

  • First commit ass some slots definition for the tooltip and axis
  • Second commit is the result of yarn proptypes & yarn docs:api
  • Third commit is adding a section in tooltip to show how to use those slots

@alexfauquette alexfauquette added docs Improvements or additions to the documentation component: charts This is the name of the generic UI component, not the React module! labels Mar 11, 2024
@mui-bot
Copy link

mui-bot commented Mar 11, 2024

Deploy preview: https://deploy-preview-12408--material-ui-x.netlify.app/

Updated pages:

Generated by 🚫 dangerJS against 5d2cf1e

@kelseywarshawsky
Copy link

This is really helpful! Sorry I'm just a random person on the internet but you happened to push this right as I was trying to use slots for a pie chart.

I have a custom tooltip - wondering how I can make that tooltip have an arrow? I think I can figure it out somehow but I am not finding it well documented

@alexfauquette
Copy link
Member Author

@kelseywarshawsky
It's not a Tooltip but a Popper (the naming is missleading 🙈) so the arrow does not exist in the default component.

What interest you is here: https://github.com/mui/mui-x/blob/master/packages/x-charts/src/ChartsTooltip/ChartsTooltip.tsx/#L143-L161

Basically if you use the slots.tooltip with a components that support same props as the MUI Tooltip (especially open, placement, anchorEl) then you can add your own arrow

For example

function MyCustomChartsTooltip({open, placement, anchorEl}) {
	return <Popper open={open} placement={placement} anchorEl={anchorEl}>
			<ArrowElement placement={placement} anchorEl={anchorEl} />
			{children}
</Popper>
}

Copy link
Member

@michelengelen michelengelen left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

@alexfauquette alexfauquette merged commit acea8ee into mui:next Mar 14, 2024
17 checks passed
@alexfauquette alexfauquette deleted the clarify-tooltip branch March 14, 2024 10:31
thomasmoon pushed a commit to thomasmoon/mui-x that referenced this pull request Sep 9, 2024
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! docs Improvements or additions to the documentation
Projects
None yet
4 participants