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: setPointFormatter doesn't work #4709

Closed
gpsfl opened this issue Feb 21, 2023 · 3 comments
Closed

Charts: setPointFormatter doesn't work #4709

gpsfl opened this issue Feb 21, 2023 · 3 comments
Labels

Comments

@gpsfl
Copy link

gpsfl commented Feb 21, 2023

Description

I added a custom point formatter function to a series tooltip, but it has no effect.

Expected outcome

The tooltip should be formatted according to the function

Minimal reproducible example

final Chart myChart = new Chart(ChartType.LINE);

ListSeries series = new ListSeries("Tokyo", 49.9, 71.5, 106.4);

SeriesTooltip seriesTooltip = new SeriesTooltip();
seriesTooltip.setPointFormatter("function() { return this.x + ' km²' }"); // <-- Custom formatter

PlotOptionsSeries options = new PlotOptionsSeries();
options.setTooltip(seriesTooltip);
series.setPlotOptions(options);

// Tooltip element needs to be configured on chart
myChart.getConfiguration().setTooltip(new Tooltip());

myChart.getConfiguration().addSeries(series);

Steps to reproduce

  1. Add the example from above
  2. Hover over a data point in the chart

Environment

Vaadin version(s): 23.3.2
OS: Windows 10

Browsers

Chrome

@gpsfl
Copy link
Author

gpsfl commented Feb 21, 2023

Probably related to the following commit:
vaadin/web-components@3402ea3

The data series are sent as an array, but the new method will only inflate objects.

@echarlus
Copy link

I've encountered the same issue.
If you set the formatter to a Tooltip configured at the chart, level it works. If you set it at the Series level then it does not work.
That's a real pain.

@ugur-vaadin
Copy link
Contributor

Closing as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants