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

[bug]: Tooltip order for stacked bar chart is reversed #6919

Open
2 tasks done
andro-bulj opened this issue Mar 13, 2025 · 2 comments
Open
2 tasks done

[bug]: Tooltip order for stacked bar chart is reversed #6919

andro-bulj opened this issue Mar 13, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@andro-bulj
Copy link

andro-bulj commented Mar 13, 2025

Describe the bug

The order of items in the stacked bar chart tooltip are reversed.
In the bar chart you can see light blue is on top and dark blue on bottom, but in the tooltip the orders are reversed.

I made a quick solution by passing optional reverseOrder boolean to ChartTooltipContent component and then reversing the order of payload before it is mapped (reverseOrder ? payload.slice().reverse() : payload).map. But I am not sure if this is the right solution.

Image

Affected component/components

Stacked Bar Chart

How to reproduce

  1. Go to https://ui.shadcn.com/charts
  2. Hover over a stacked bar chart
  3. Items in the tooltip do not represent the order as they are displayed in the chart

Codesandbox/StackBlitz link

No response

Logs

System Info

Google Chrome

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@andro-bulj andro-bulj added the bug Something isn't working label Mar 13, 2025
@theVedanta
Copy link

Would you have both the legend and the tooltip inverted then?

@shaunpearce
Copy link

I ended up just reversing the payload in the chart.jsx:

const reversedPayload = [...payload].reverse()

And then changing:

{reversedPayload.map((item, index) => {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants