Issue DescriptionCustomer has a requirement to create a Pie Chart in JRXML report based on 3 dataset fields. They created such chart in Ad Hoc View by adding 3 columns into Rows. How to achieve the same result in JRXML report? | [toc] |
Resolution
By default, Pie Chart expects that slices are represented different values of a single column/field.
The requirements can be implemented by converting the threee values into a data source with three records
and sending the data source to a subdatatset.
Please find attached example, note that is uses Groovy as language for map literals.
Report main dataset returns 3 dummy values:
SELECT 5 as a, 8 as b, 4 as c
Subdataset "chartData" contains only a list of fields, key and vallue, without any query.
Pie Chart's dataset uses a DataSource expression to 'convert' values into records:
new net.sf.jasperreports.engine.data.JRMapCollectionDataSource([[key:"a",value:$F{a}],[key:"b",value:$F{b}],[key:"c",value:$F{c}]])
Solution tested with TIBCO JasperReports® Server v.6.4.0
Ref. Case 01530898
Recommended Comments
There are no comments to display.