Truncate label text but show full text on hover #270
-
We're using react-charts for customer dashboards in our app. Is there a way to truncate the label text in the bar chart (so it does not go beyond the width of the chart container, for example) whilst also allowing a user to see the full text on hover? In other tools (like chartjs for example) you can truncate with slice and it will only apply that to the visible label, but when you hover it will show the full label. It would be great if we could do something similar or if anyone could suggest the best way to go about this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
You should be able to use |
Beta Was this translation helpful? Give feedback.
You should be able to use
options.formatters
to change the formatter for specific rendering points of the labels. It's not documented yet, but this should be enough to get you started: https://github.com/tannerlinsley/react-charts/blob/beta/src/utils/buildAxis.linear.ts#L182-L203