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.

Vaadin Charts 3.2 - Error setting yAxis categories on gauge

Alex Roig
5 years ago Nov 22, 2016 7:16pm
Guillermo Alvarez
5 years ago Nov 25, 2016 1:57pm

Hi,

Categories are for consecutive values 0,1.. That's why the rest of the values are skipped.
One possible solution for your problem is to use a label formatter.
I tried a simple and a bit hacky solution as a proof of concept and it worked:

Chart chart = new Chart(ChartType.GAUGE);
        Configuration conf = chart.getConfiguration();
        conf.setTitle("Wind Direction");
        YAxis yAxis = conf.getyAxis();
        yAxis.setMin(0);
        yAxis.setMax(360);
        yAxis.setTickInterval(22.5);
        yAxis.setEndOnTick(false);
        Labels labels = yAxis.getLabels();
        labels.setDistance(-20);
        labels.setFormatter("['N', 'NNE', 'NE', 'ENE','E', 'ESE', 'SE', 'SSE','S', 'SSW', 'SW', 'WSW','W', 'WNW', 'NW', 'NNW'][this.value/22.5]");
        ListSeries data = new ListSeries(68);
        conf.addSeries(data);

And it seems to work as expected. You can read more about formatter in vaadin docs

Hope this helps,

Guille

Alex Roig
5 years ago Dec 08, 2016 7:50pm
Guillermo Alvarez
5 years ago Dec 14, 2016 10:37am