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

donal

Members
  • Posts

    7
  • Joined

  • Last visited

donal's Achievements

Rookie

Rookie (2/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. I avoid that problem by have style's associated with all elements. That way you can just change the style definition and all report elements which use it are updated. I keep the styles external to the report design jrxml file so that I can reuse them amongst reports.
  2. Hi Lucian, Thanks a lot for your help on this, I really appreciate it. Yes I am doing something different, I had made a change to allow subreport return variables to be used in a master reports chart (http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=48456&res=41) and as a result datasets were no longer being calculated properly. I updated my other post with the additional changes required to keep data sets working. Regards, Donal
  3. If you make the changes above you also need to make the following changes below, otherwise datasets will no longer be calculated if they use a dataset run Code://JRFillDatasetRun.java protected void detail() throws JRScriptletException, JRException { dataset.scriptlet.callBeforeDetailEval(); dataset.calculator.calculateVariables();//calculate datasets dataset.calculator.calculateDataSets(); dataset.scriptlet.callAfterDetailEval(); }
  4. Hi Lucian, Thanks for the example. Unfortunantly when I run chart.jrxml I get an empty document. Looking at chart.jrxml I don't see anything unusual, other than for the field definitions in your dataset your provided a description, something I didn't do. I made this change but no luck, (however curirously the field description must match the field name?) My JRDataSource is backed by a bean collection. If you wouldn't mind I've included the bean, dataset and chart definition below, do you see any issues with my implementation? Using a JRDataSource would have been the most elegant solution to my reporting requirements. A dataset would work, however any sql I need would have to be dependant on report parameters, as they are not available the only approach I have is to generate the sql outside the report and to transform it with a report template so that it's available at compile time, something I've had to do a lot in my use of jasperreports. If you have an example of using a bean backed JRDataSource as a charts dataset, for a bar chart, using a dtd, I would appreciate it. Thanks again, Donal Code://bean definitionpublic class ReportTotalBean{ private String name; private Long value; public ReportTotalBean(String name, Long value) { this.name = name; this.value = value; } public String getName() { return name; } public Long getValue() { return value; } public void setName(String name) { this.name = name; } public void setValue(Long value) { this.value = value; }}//create the bean and put into parameter map for report List<ReportTotalBean> beans = new ArrayList<ReportTotalBean>(); for(int i = 0; i < 2; i++){ ReportTotalBean bean = new ReportTotalBean("Bean"+i, Long.valueOf(100+i)); beans.add(bean); } JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(beans); parameters.put("TEST_DATA_SOURCE", dataSource);//subdataset definition <subDataset name="SubDataset1" > <field name="name" class="java.lang.String"> <fieldDescription><![CDATA[name]]></fieldDescription> </field> <field name="value" class="java.lang.Long"> <fieldDescription><![CDATA[value]]></fieldDescription> </field> </subDataset>//chart definition <barChart> <chart evaluationTime="Report" hyperlinkTarget="Self" customizerClass="com.l7tech.server.ems.standardreports.UsageSummaryChartCustomizer" renderType="image" > <reportElement x="0" y="0" width="820" height="130" key="element-1"/> <box></box> <chartLegend textColor="#000000" backgroundColor="#FFFFFF" > </chartLegend> </chart> <categoryDataset> <dataset> <datasetRun subDataset="SubDataset1"> <dataSourceExpression><![CDATA[$P{TEST_DATA_SOURCE}]]></dataSourceExpression> </datasetRun> </dataset> <categorySeries> <seriesExpression><![CDATA["# Successful Requests"]]></seriesExpression> <categoryExpression><![CDATA[$F{name}]]></categoryExpression> <valueExpression><![CDATA[$F{value}]]></valueExpression> <itemHyperlink > </itemHyperlink> </categorySeries> </categoryDataset> <barPlot isShowLabels="true" > <plot orientation="Horizontal" /> <categoryAxisFormat> <axisFormat > </axisFormat> </categoryAxisFormat> <valueAxisFormat> <axisFormat > </axisFormat> </valueAxisFormat> </barPlot> </barChart>
  5. after doing some more testing I'm wondering if datasets which use a JRDataSource work at all with charts, has anybody gotten this to work? Is it really a limitation that a query in a dataset definition, can't reference parameters / variables in the same report?
  6. Hi, I cannot get a chart to display data from a dataset. I have a report with no subreports ,1 data set defined and 1 chart. The chart needs to use a java bean data source so I have defined a dataset and I have specified that the chart uses this data set as it's subdataset. (I'm using iReport 3.0.0). The java bean data source is supplied by a report scriptlet. The data set must not be created until the end of the report, so the chart has had it's evaluation time set to 'Report'. Ive done the following testing: I have printed out statements from within the scriptlet's method for providing the data source: the data source is getting created at the end of the report and all values it requires are available. I have iterated through the data source using next() and all expected values are there. I have provided a chart customizer and retireved the datasetrun from the JRChart and confirmed that the name matches the dataset I provided via iReport. The chart has the following properties: Eval time: Report, Subdataset: (my data set name), data source expression: ((my scriptlet class name)$P{REPORT_SCRIPTLET}).getChartDataSource(), Dataset reset type: Report, Dataset increment type: None (I have tried various combinations of these) The datasource is created using: JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(beans); The dataset has two fields: name, which is the category expression and value, which is the value expression. Any help would be appreciated, Thanks Donal
  7. Hi, From what I can see, it's not possible to use sub report return variables as part of a charts data set. The problem seems to stem from sequence of events for each row of data in a master report. Variables are calculated, then datasets, then subreports and finally subreport variables are placed into variables. As a result I could see no means of somehow getting subreport variables into the dataset as it is created. The lifecycle methods of JRDefaultScriptlet are only at the start of an event, there are 'before' and 'after', however they still come before the subreport is ran, as such I could see no way at all of keeping my report, which contains a subreport, which contains another subreport, and to use the return values in a summary chart in the master report. I made the following changes to the source, this is working for me in my narrow use of jasperreports, I'm interested to know what features this breaks and what others think. I separated out the evaluation of variables and datasets from within the Calculators calculateVariables method and introduced a new method calculateDataSets(). This new method calculateDataSets() is called from JRVerticalFiller's fillDetail() method, after fillColumnBand has been called, see code below. So the solution seems to be simply separating the calculation of variables from datasets, allowing for return variables to be processed before datasets are processed. I'm sure it's quite likely this will cause other problems. There were no tests with the source so I could not see what features this would break. Code: Post Edited by Donal Armstrong at 11/13/08 21:28
×
×
  • Create New...