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][RFC] Tooltip deprecation path #15095

Closed
Tracked by #13820
alexfauquette opened this issue Oct 24, 2024 · 1 comment
Closed
Tracked by #13820

[charts][RFC] Tooltip deprecation path #15095

alexfauquette opened this issue Oct 24, 2024 · 1 comment
Labels
breaking change component: charts This is the name of the generic UI component, not the React module! RFC Request For Comments

Comments

@alexfauquette
Copy link
Member

alexfauquette commented Oct 24, 2024

The history during v7

Customizing the tooltip has been a long battle with multiple attempts

Initially, the tooltip had 3 places to override:

  • slots.popper: The wrapper component that take car of tooltip position
  • itemContent: The content to display if we show the tooltip for a specific item
  • axisContent: The content to display if we show the tooltip for a specific axis

The two last have been deprecated in favor of slots.itemContent and slots.axisContent for consistency.

It appeared that slots was not optimal for tooltip for two reasons:

  1. It was confusing for users to know which slots is used, and what they can get from its props.
  2. People needed extra information to customize their tooltip.

The last solution

We propose to provide a new composition approach (see docs examples)

With this solution we export useItemTooltip and useAxisTooltip. They provide the basics data needed to reproduce our tooltip.

If additional data is required, they can use additional hooks to select data from the container. For example:

function CustomTooltip() {
  const axisData = useAxisTooltip();
  const highlightedItem = useHighlighted(); // Not sure this hook exist yet

 return (
   // A tooltip with a special effect for the series currently highlighted.
  )
}

Breaking changes

Option 1

I would personally be in favor of dropping at the same time slots.popper, itemContent, slots.itemContent, axisContent, and slots.axisContent. And rely on composition

<BarChart>
  <ChartsAxisTooltip />
</BarChart>


<BarChart>
  <ChartsItemTooltip />
</BarChart>

<BarChart>
  <UserCusstomTooltip />
</BarChart>

But the step might be too big for the users.

Option 2

Another option is to remove the itemContent, and axisContent. Deprecate the slots.itemContent and slots.axisContent, encouraging users to set them to null and use composition as a transition period.

It's less breaking change forced to do, but the DX looks crap.

Option 3

Remove all current way to customize tooltip, and provide a slots.tooltip that override the default one.

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 24, 2024
@alexfauquette alexfauquette changed the title tooltip.itemContent & tooltip.axisContent [charts][RFC] Tooltip deprecation path Oct 24, 2024
@alexfauquette alexfauquette added breaking change RFC Request For Comments component: charts This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 24, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: charts This is the name of the generic UI component, not the React module! RFC Request For Comments
Projects
None yet
Development

No branches or pull requests

2 participants