Issue in Vaadin Pie Chart while adding center title

Hello Team,
Im using latest vaadin version
I wanted to add the total title in center of my pie chart
so i do following hack

public void addCenterTitleInPieChart(Configuration chartConfig, int employeetotal){
DataSeries dataSeries = new DataSeries();
String totalLabel = String.format(“T=%,d”, employeetotal);
DataSeriesItem dataSeriesItem = new DataSeriesItem(totalLabel,0);
DataLabels dataLabels = new DataLabels();
dataLabels.setFormatter(“function() { return "T=”+String.format(“%,d”, employeetotal)+“"; }”);
Style dLStyle = new Style();
dLStyle.setFontSize(“0.75rem”); // if we make it too big, it’ll overlap on large values
dLStyle.setFontWeight(FontWeight.NORMAL); // default is bold
PlotOptionsPie plotOptions = new PlotOptionsPie();
plotOptions.setCenter(“50%”, “50%”);

if i put 0 in DataSeriesItem(emptotal,0) then center title in pie chart is T=total(NaN%)
if i put 100 in DataSeriesItem(emptotal,100) the center title is pie chart is T=total(100.000%)

Actually i just want to show T=total(100%)
i dont want decimals in it i tried diff solutions but it didnt works can any one helps me in it

If you don’t want decimals… why are you using %d in your format?

Edit: haven’t used format in a long time… just transform it to int/long before adding it to the formatter and you are good to go

Hello @quirky-zebra %d denotes number/int value

i tried so many solutions but still getting that 3 zeros after decimal :slightly_smiling_face:

(int) employeetotal?

yes its int value

something is wrong in dataseriesItem

dataLabels.setFormatter(“function() { return “T=”+String.format(”%,d", employeetotal)+“”; }");
this function is for the label of total T=102 not for the (100.000%) which is shown after it
it is coming automatically

I have a feeling that this isn’t a sever side problem and instead a client side / Highchart feature. Instead of using server side formatting you can try client side formatting in JS

Sounds like a hack indeed :slightly_smiling_face:

The setFormatter parameter is indeed a JS function. If you know the what you know on the server side, I’d just create the full string there and then use the simpler setFormat method.

Something like

String totalLabel = String.format(“T=%,d”, employeetotal);