Kuku
Kuku

Reputation: 514

Regarding Jasper report bar chart

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

enter image description here

If the used value is 44 then the bar graph will looks like this

enter image description here

Regards,

Upvotes: 0

Views: 1928

Answers (1)

MrsTang
MrsTang

Reputation: 3119

You can achieve that by defining 2 parameters:

  • max: maximum value
  • proportion: value when it should switch between blue and green.

Then you add a stacked bar chart with 3 series:

  • Series1: series expression: "RED", category expression $F{<field>}, value expression $F{<value>}
  • Series2: series expression: "BLUE", category expression $F{<field>}, value expression $F{<value>} < $P{proportion} ? $P{max} - $F{<value>} : 0
  • Series3: series expression: "GREEN", category expression $F{<field>}, value expression $F{<value>} >= $P{proportion} ? $P{max} - $F{<value>} : 0

report output

Upvotes: 1

Related Questions