Jump to content

Problem with scriptlet and barchart


jaapandre

Recommended Posts

I want to create a stacked bar chart with 3 categories (negative, neutral, positive), but I have for instance scores from 1-10 or 1-5, so I need to combine/recode the value to get the right series expression (and use it for group expression).

If i compute this value in the report itself (1):

<variable name="valueRecoded" class="java.lang.String" resetType="Group" resetGroup="value">
        <variableExpression><![CDATA[($F{val}.equals("1") || $F{val}.equals("2") ? "2" :
    ($F{val}.equals("4") || $F{val}.equals("5") ? "4": $F{val})
    )]]></variableExpression>

The barchart is created as it should (using a barchartCustomizer for percentages, colors etc).

However I want to use a scriptlet to be more flexible (see attachment 2). It contains some exotic code, but at the end it sets the variable "valueRecoded".

However if I generate the report (jrxml in attachment 3), the count value is not reset anymore. Which results in the barchart according to attachment 1, the unrecoded values: 6,3,9, which should be recoded to 2,1,3 resulting in bars of equal sizes (and 33,3% as label).

The full code is also available via https://github.com/Nivocer/webenq/tree/5671-barchart/java/src

I'm using jasper report 4.5 (it also doesn't work on 4.1). I tried several options to reset the value and several options when to calculate the valueRecoded (afterReportInit, etc).

I hope somebody can help

 

Jaap-Andre

(1) I guess the resetType=group resetGroup=value is not needed here

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...