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

Using custom formatter for xaxis affects tooltip #4743

Open
gsidhu opened this issue Oct 3, 2024 · 0 comments
Open

Using custom formatter for xaxis affects tooltip #4743

gsidhu opened this issue Oct 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@gsidhu
Copy link

gsidhu commented Oct 3, 2024

Description

When using a custom formatter function for the xaxis, the tooltip also displays the same formatted labels instead of the default values. This results in a situation where if you use a custom truncating function for the x-axis, the tooltip labels also show truncated text.

The behaviour can be fixed by defining a formatter function for the tooltip as well. But this results in an arguably needless definition like: x: {formatter: function (val:string) {return val;}}.

I propose that this behaviour should be documented in the docs for the tooltip as already done for the y-axis: By default, these values will be formatted according [yaxis.labels.formatter](https://apexcharts.com/docs/options/yaxis/#formatter) function which will be overrided by this function if you define it.

Ideally, a similar notice should also be shown in the docs for xaxis and yaxis. Something like: "Setting a custom formatting function will change the tooltip text. Set the formatting function under tooltip.x/tooltip.y to override this behaviour."

Steps to Reproduce

  1. Create a line/bar chart with some data.
  2. Set a custom formatter function for the xaxis > labels.
  3. See that your custom formatting is displayed for both the x-axis labels and for tooltips.

Expected Behavior

Ideally, the tooltip label's formatting should be independent of the x-axis labels. In this case, the tooltip should display whatever the default x-axis labels are and not the formatted labels. Or the behaviour should be documented in the docs.

Actual Behavior

The tooltip displays formatted x-axis labels by default instead of showing the default values or the categories defined under xaxis.

Reproduction Link

https://codepen.io/buzodog/pen/KKOzqJE

@gsidhu gsidhu added the bug Something isn't working label Oct 3, 2024
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

1 participant