Reputation: 514
I'm using jasper ireport 4.0.1 for developing. And I need to realize a bar graph being shown according to the imported 2 parameter one is for the used and the other is the total value. I want the left part of this bar represented in red color and the length will be changed according to the proportion of the used value out of the total also the used value need to be shown on this part of bar and the rest of the bar in green colour with the length regarding the total minus by the used value. How can I realize that, any help will be appreciated!
Let say the total value is 45
If the used value is 24 then the bar graph will show as follow
If the used value is 44 then the bar graph will looks like this
Regards,
Upvotes: 0
Views: 1928
Reputation: 3119
You can achieve that by defining 2 parameters:
Then you add a stacked bar chart with 3 series:
$F{<field>}
, value expression $F{<value>}
$F{<field>}
, value expression $F{<value>} < $P{proportion} ? $P{max} - $F{<value>} : 0
$F{<field>}
, value expression $F{<value>} >= $P{proportion} ? $P{max} - $F{<value>} : 0
Upvotes: 1