How convert Pie3D to HTML5 Pie

Can somebody convert Pie chart to HTML5 one? How can you convert this type of chart if there are more than 1 series in pie?
 
i.e. I have Pie3D
<pie3DChart>
<chart theme="aegean">
    <reportElement x="583" y="97" width="350" height="180" uuid="57f9d143-e18d-4f2d-a001-e4b09f76da72"/>
    <chartTitle/>
    <chartSubtitle/>
    <chartLegend/>
</chart>
<pieDataset>
    <pieSeries>
        <keyExpression><![CDATA["XX"]]></keyExpression>
        <valueExpression><![CDATA[$F{Call_TotalXX}]]></valueExpression>
        <labelExpression><![CDATA[$F{CallPCentXX}.toString()+"%"]]></labelExpression>
    </pieSeries>
    <pieSeries>
        <keyExpression><![CDATA["YY"]]></keyExpression>
        <valueExpression><![CDATA[$F{Call_TotalYY}]]></valueExpression>
        <labelExpression><![CDATA[$F{CallPCentYY}.toString()+"%"]]></labelExpression>
    </pieSeries>
</pieDataset>
<pie3DPlot>
    <plot/>
    <itemLabel color="#000000" backgroundColor="#FFFFFF"/>
</pie3DPlot>
 
 
 
 
How convert if to HTML5 Pie, if this type of chart has only 1 Mesure?
andrqxa's picture
106
Joined: Apr 6 2012 - 5:16am
Last seen: 5 years 4 months ago

1 Answer:

There is no direct way of feeding two values per record into a single series in HTML5 charts.  You can contact the Jaspersoft commercial support and file a feature request (or bug if you consider it so).

Depending on your exact use case, there might be some workarounds.

For instance, if you only need to feed two values (that is a single record) into the chart, you can create a subdataset and pass a data source with two records to it.  That is something like:

<subDataset name="ChartDataset">

<field name="key"/>

<field name="value" class="java.lang.Integer"/>

</subDataset>

 
...
<multiAxisData>

<multiAxisDataset>

<dataset>

<datasetRun subDataset="ChartDataset">

<dataSourceExpression>new net.sf.jasperreports.engine.data.JRMapCollectionDataSource([[key: "a", value: 5], [key: "b", value: 10]])</dataSourceExpression>

</datasetRun>

</dataset>

</multiAxisDataset>

<dataAxis axis="Rows">

<axisLevel name="Key">

<labelExpression><![CDATA["Key"]]></labelExpression>

<axisLevelBucket class="java.lang.String">

<bucketExpression><![CDATA[$F{key}]]></bucketExpression>

</axisLevelBucket>

</axisLevel>

</dataAxis>

<multiAxisMeasure name="Measure" class="java.lang.Integer" calculation="Nothing">

<labelExpression><![CDATA["Measure"]]></labelExpression>

<valueExpression><![CDATA[$F{value}]]></valueExpression>

</multiAxisMeasure>

</multiAxisData>

 
Note that the example uses Groovy expressions for the sake of list and map literals.
 
If you need to feed several records into a single chart, something similar can be achieved by collecting the value into a list.  That would be more tedious though.
 
Regards,
Lucian Chirita
lucianc's picture
42480
Joined: Jul 17 2006 - 1:10am
Last seen: 2 days 13 hours ago
Feedback
randomness