Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Charts: Is it possible to get axis categories in the Tooltip formatter?

Donald Smith
7 years ago Jul 21, 2015 2:51pm
Guillermo Alvarez
7 years ago Jul 25, 2015 9:08am
Guillermo Alvarez
7 years ago Jul 25, 2015 9:20am

Also if you want to avoid setting the id and doing get('x-axis'), you can take a look at chart.axes array

And I think you should be using point.index as the category array index, because this.point.x is the category value which might be a string

tooltip.setFormatter("function() { "
                + " var index = this.point.index; "
                + " var chart = this.series.chart; "
                + " var start = chart.axes[0].categories[index]; "
                + " var end = chart.axes[0].categories[index + 1]; "
                + " return '[' + start + ',' + end + ')'; }");

Hope it helped!

Donald Smith
7 years ago Jul 27, 2015 1:15pm
Guillermo Alvarez
7 years ago Jul 27, 2015 3:01pm