Chart Label expression with field1 divide field2 always return zero.


I have a Stacked Chart and want to display the value with percentage.

This is the dataset

The Chart's label will become BLANK if using expression: String.valueOf((double)$F{cnt}/$F{total})


However if I change to String.valueOf((double)$F{cnt}/1000)

It works, so how to field1 divide field2?

It is so wried since this is very simple calculation and can be perform easily in SSRS or BIRT, but why so complicate in jasper report?


leo.cheung's picture
Joined: Sep 19 2019 - 7:27pm
Last seen: 1 week 3 days ago

1 Answer:


Hava you already tried to limit the number of decimal places?

So something like this:

String.format ("%.2f", ($F{cnt}/$F{total}))

?? Perhaps just the long string when dividing your numbers just doesn't fit into the bar chart elements?!?

hth + regards


C-Box's picture
Joined: Jul 19 2006 - 5:58pm
Last seen: 6 days 13 hours ago