Jaspersoft - Use subdatasource for a chart in subreport - jasper-reports

Scenario:
Main report with json datasource.
Subreport with two chart inside.
I'm able to subdatasource the subreport using a JRDataSourceExpression:
((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("response.graficiPercentuali.sostenibilita")
My question is:
Is possible to do the same thing for fill the charts in the subreport?
First chart should use for example:
((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("response.graficiPercentuali.sostenibilita.chart1")
The second one:
((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("response.graficiPercentuali.sostenibilita.chart2")
I have tried to right click on the Dataset of the chart in the Outline but the JRDataSourceExpression
is disabled. Probaly because in the Dataset Run I have main dataset..
How or where I can do that?
Thanks
Andrea

Related

How to create a vertical line chart from fields on detail record

Trying to create a vertical line chart from data in 4 separate fields per Detail record.
I know how to do it using Excel (see image), trying to figure out how to do it using Crystal Charts. Also, data is per detail record and I found that I can only insert a chart on a header or footer section.
I'm also not sure I'm using the correct verbiage as I can't seem to find an answer using google searches.
Thanks!
You can insert chart into crystalreport from insert --> chart and choose type of chart and data will show in chart, chart insert in header and footer report but will contain all data you choose, also you can insert chart into hadear and footer group if you use group.
Note: Attached picture from crystal report
You can insert a group to provide header/footer for each detail section.
Or, one of the Crystal Reports User Function Libraries listed here allows you to add special charts anywhere you wish within your report, feeding the data into the chart using formula logic.

Editing the column size inside subreport using jasper API

I have a jrxml file containing six subreports.
I need to programatically hide the columns displayed in these subreports.
I did search for a solution, but could not find a example for modifying the columns in subreports and I am unable to find a way with jasper API to pick the subreport from JasperReport class.
I did check dynamicreports API. But it seems subreport can't already have columns defined in it.

To add data table with Crystal charts

i am using Crystal 2008 and Would like to add data table just underneath attached to a Chart. This can be done very easily in Excel. Don't know how to do it in Crystal
please advise....much appreciated
The way your question is worded I'm not clear if you mean under as in "behind" or "below". It would help if you include a mockup drawing of what you're trying to accomplish.
If you mean "behind", the feature you're looking for is Section Underlay. This video gives a small demo of the feature to put a watermark image behind the report, but you can do the same thing with a chart, crosstab, or other object. The "World Sales Report" sample report has another example of this feature to put a table beside the chart.
If you mean "below", you can either just add sections and put your data fields there, or if that's not the type of table you're looking for, you may want to use a Crosstab object.

How to add a Pie Chart using another data source from main report data source

I want to add below of my report a pie chart that uses another data source from reports main data. I'm trying to add another source on my dataset but Crystal has a mechanism that linking relational fields, and if i link them rows are repeating on report and if i don't link then no data appearing on report. Any ideas?
In crystal reports, you can add subreport and one dataset with many datatable (main report data and pie chart data).
Right click on main report, insert subreport. Choose another datasource from main report. Clean all report items and add pie chart to this subreport using the datasource.
Its OK.

JasperReports empty chart at Report Group change

I am using JasperReports with iReport to generate reports from a MySQL data source. The reports I am attempting to generate use Report Groups to organize the information. Also, I have a chart that appears at the footer of each page displaying info for the current grouping. The chart's reset type is Group, and it is placed in the column footer to achieve this. Also, a new page is forced when the report group changes.
The problem that I am having is that when the Report Group changes, (at the last page of each grouping) I am left with an empty chart on that page. On the proceeding pages, the chart resumes with valid data.
Does anyone have any tips as to how I can fix this?
A good solution would have the chart displaying the data for the group.
An okay solution would have the chart hidden at the time of a report grouping change
In iReport Designer
Right Click On the Chart
Select Chart Data
Under Dataset tab, select 'Group' for 'Reset type'
Select the group for which you want to reset the chart for 'Reset group'