Jump to content
Changes to the Jaspersoft community edition download ×
  • Prompt for Category/Series in Chart Deployed to JasperReports Server


    Friendly User

    [toc on_off::hide=1]

    You have a created a report with a chart and deployed it to JasperReports Server. You want to have an input control to pop up before running a report on a server to let you specify what informtion out of three possible series - for example Product, Customer and Class - to display.

    Here is how you can do it.

    1. Create a parameter which will regulate the type of chart to choose and to use it afterwards as an input control. To do that in iReport Designer rightclick on Parameters in Report Inspector and click Add Parameter. Give it a name you want (for example type)

    2. Create a variable. To do that in iReport rightclick on Variables in Report Inspector and click Add Variable. Give it some name you like. Then you click "..." button near Variable expression. In the opened window you need to write down expression like I gave you. If you have some Java background it should be fairly easy for you. The general idea is to use operator ? to create IF-ELSE construct. Should be something like this:

    $P{type}==1 ? $F{field1} : $P{type}==2 ? $F{field2} : $F{field3}

    This will mean that if parameter $P{type} will equal 1 then your variable will become first field you want, if type is 2 then it'll become second field you want, etc.

    You need to upload the report to JasperReports Server afterwards using either JS web interface or using JasperReports Server Repository Navigator of iReport Designer. In general you create a new Report Unit and point it to use your newly created JRXML.  

    After you created a report with a chart you need to upload it to JasperReports Server. To do so in iReport Designer:

    1. Open your Repository Navigator (Window->Repository Navigator). Then add your JasperReports Server instance to it and connect to the server.
    2. Once connected go to folder you want. Right click on folder and click Add JasperReports Server Report, give it a name, source JRXML choose to be copied from currently opened report, select the datasource you need.
    3. Right click on the created report and click Add->Input control. Input control must have exactly the same name and id as parameter name you chose previously.
    4. In input control details set input control's type to Single Select List of Values. List of Values resource should be locally defined.
    5. Click on Edit List of Values. Give the list of values some name you want. In second tab add the number of values you want. First column defines how it will look like when you use input control in JasperReports Server. Second column defines what value it will correspond.

    So you will have something like:

    Group - 1
    Customer - 2
    Class - 3

    Save everything you did. Now when you run this report in JasperReports Server you will be prompted to select one of those values.


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...