Michael Kročka
Michael Kročka

Reputation: 665

Vaadin pie chart label formatter not working

I have a chart in Vaadin 8 with the following formatter for y axis labels:

chart.getConfiguration().getyAxis().getLabels()
    .setFormatter("function() { return this.point.name + ' sample'; }");

I can't seem to get it to work correctly, as the chart always displays only the point.name part and not the ' sample' part. I did the same for the tooltip where it works:

chart.getConfiguration().getTooltip()
        .setFormatter("function() { return this.point.name + ' sample'; }");

Screenshot for confirmation: enter image description here

Upvotes: 0

Views: 111

Answers (1)

Michael Kročka
Michael Kročka

Reputation: 665

After quite some time I found the answer, I had to set the label formatting function in the PlotOptionsPie object:

PlotOptionsPie plot = new PlotOptionsPie();
plot.setInnerSize("60%");  // hollow inside -> "donut" chart
plot.getDataLabels().setFormatter("function() { return this.point.name + ' sample'; }");
chart.getConfiguration().setPlotOptions(plot);

The result:

enter image description here

Upvotes: 0

Related Questions