Jump to content
We've recently updated our Privacy Statement, available here ×

Handle Map in I report from java for chart


dpriya.pratheep

Recommended Posts

I am using java and I Report and new to Ireport. Values to I report are passed through java. 

I handled only single values not array or group of values . 


Now I want to create a chart. with month on x-axis and running(auto increment) values on y-axis. Data are in Map in java , so i can pass Map to Ireport through parameters.How can use this to chart. 

I saw example are for SQ L query . 

My java code 

 

 

  1. Map> monthMap = ,>new ProjectCodeBiz().getProjectBudgetAndActualToMonth(projectId, year, period);  
  2.           
  3.   
  4. if (monthMap != null) {  
  5.                 Iterator monthIterator = monthMap.keySet().iterator();  ,>
  6.                 Integer monthKey;  
  7.                   
  8.                 Map sumMap;  ,>,>
  9.                 Iterator sumIterator;  ,>,>
  10.                 String sumKey;  
  11.                   
  12.                 while(monthIterator.hasNext()){  
  13.                     monthKey = (Integer) monthIterator.next();  
  14.                     parameters.put(MONTH, monthKey);  
  15.                     sumMap = monthMap.get(monthKey);  
  16.                     sumIterator = sumMap.keySet().iterator();  
  17.                     while(sumIterator.hasNext()){  
  18.                         sumKey = (String) sumIterator.next();  
  19.                         BigDecimal value = (BigDecimal)sumMap.get(sumKey);  
  20.                         parameters.put(sumKey, ObjectUtils.round(value));  
  21.                     }  
  22.                 }  
  23.             }  
  24.               
  25.             //Filling the reports with data  
  26.             jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,dataSource);

 

 

 

 

Usually i retrieve values like this in Ireport 

 

  1. CDATA[$P{REPORT_PARAMETERS_MAP}.get( "report_title" ) for parameters and  
  2. CDATA[$F{cp_labour_hour}for datasource.

 

sample output is 

Month: 1 
Key: Actual_Cost 
Value: 910.00 
Key: Actual_Sale 
Value: 0.00 
Key: Cost 
Value: 87300.00 
Key: Sale 
Value: 97991.25 
..... 
Month: 17 
Key: Actual_Cost 
Value: 910.00 
Key: Actual_Sale 
Value: 0.00 
Key: Cost 
Value: 92740.00 
Key: Sale 
Value: 104095.75 



Please anybody help me how to retrieve data from map? or If map can not handle in ireport any other way to handle this. 

My x-axis is for month should like this M 1, M 2, M 3 .... 
and y-axis 100,200,300 etc. 

what should i use for Series expression, X Value expression and Y value expression in i report chart properties? 

Using graph for four keys so X Y map is OK right? 

Please give me suggestions... 


Note: data are from two sources, that is why i am using parameter and data source. 
Thanks in advance
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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...