3 Answers:
I have found the solution. May be it will help somebody.
In main report created parameter NAME_OF_MY_PARAMETER with type of net.sf.jasperreports.engine.JRDataSource
Created scriptlet
In scriptlet beforeReportInit() method received value of REPOT_CONNECTION parameter
Connection conn = (Connection) this.parametersMap.get("REPORT_CONNECTION").getValue();
Run query which I needed and received result (ArrayList in my cause)
Processed result and got ArrayList which I needed (i.e. added additional rows)
override setData method in scriptlet
public void setData(Map parameters, Map fields, Map variables, JRFillGroup[] groups) { super.setData(parameters, fields, variables, groups); JRFillParameter parameter = (JRFillParameter) parameters.get("NAME_OF_MY_PARAMETER"); parameter.setValue(JRMeasureDataSourceFactory.getDataSource(measures)); }
call setData in beforeReportInit method of scriptlet
In main report created subreport and as a DataSource of it set parameter NAME_OF_MY_PARAMETER
in subreport left its query as empty (or as select 1)
added field to subreport which had type and name which I need
created chart which I needed
I recommend that you create another table which will have empty rows missing in your customer's table. One way to do this is to use Jaspersoft ETL to extract rows from your customer table and to insert into your table. Another method is to create a bean object and insert necessary rows in the bean object and use this bean as your data source instead of jdbc.