Sunday 18 November 2018

Tip: HTML-5 bar chart 3D view in jaspersoft studio reports

Hi,

Set below advanced properties to get the 3D look and feel of HTML-5 bar chart in jaspersoft studio reports.

In chart advanced settings navigate to chart --> options3d and set the values for the properties as shown in below.


Sample output:
References: 
1) https://community.jaspersoft.com/wiki/advanced-chart-formatting
2) https://www.highcharts.com/demo/3d-column-interactive


JRXML ( Supports : 7.2 professional or later)
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 7.2.0.final using JasperReports Library version 6.6.0  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="1 Bar Chart" pageWidth="900" pageHeight="842" columnWidth="860" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e3eaa82e-0ebf-4040-9ffa-69e6d8f80d09">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="ireport.jasperserver.url" value="http://localhost:8080/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="superuser"/>
<property name="ireport.jasperserver.report.resource" value="/public/HTML_5_Advanced_2018_19/Bar/1_Bar_Chart_options3d_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/public/HTML_5_Advanced_2018_19/Bar/1_Bar_Chart_options3d"/>
<queryString>
<![CDATA[SELECT
    p.brand_name,
    SUM(sf7.store_sales) store_sales
FROM product p
INNER JOIN sales_fact_1997 sf7
    ON p.product_id=sf7.product_id
GROUP BY p.brand_name
ORDER BY store_sales DESC ,
  p.brand_name LIMIT 10]]>
</queryString>
<field name="brand_name" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="brand_name"/>
<property name="com.jaspersoft.studio.field.tree.path" value="product"/>
</field>
<field name="store_sales" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="store_sales"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<summary>
<band height="300" splitType="Stretch">
<componentElement>
<reportElement x="0" y="30" width="680" height="270" uuid="214b17e1-736c-4964-904a-3eb532865e08"/>
<hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="Column">
<hc:chartSetting name="default">
<hc:chartProperty name="title.text" value=""/>
<hc:chartProperty name="credits.enabled" value="false"/>
<hc:chartProperty name="credits.href" value=""/>
<hc:chartProperty name="credits.text" value=""/>
<hc:chartProperty name="yAxis.title.text" value=""/>
<hc:chartProperty name="chart.zoomType" value="xy"/>
<hc:chartProperty name="chart.options3d.enabled_customSimpleMode" value="true"/>
<hc:chartProperty name="chart.options3d.enabled">
<hc:propertyExpression><![CDATA[true]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="chart.options3d.alpha_customSimpleMode" value="true"/>
<hc:chartProperty name="chart.options3d.alpha">
<hc:propertyExpression><![CDATA[15]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="chart.options3d.beta_customSimpleMode" value="true"/>
<hc:chartProperty name="chart.options3d.beta">
<hc:propertyExpression><![CDATA[15]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="chart.options3d.depth_customSimpleMode" value="true"/>
<hc:chartProperty name="chart.options3d.depth">
<hc:propertyExpression><![CDATA[50]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="chart.options3d.viewDistance_customSimpleMode" value="true"/>
<hc:chartProperty name="chart.options3d.viewDistance">
<hc:propertyExpression><![CDATA[25]]></hc:propertyExpression>
</hc:chartProperty>
</hc:chartSetting>
<multiAxisData>
<multiAxisDataset/>
<dataAxis axis="Rows">
<axisLevel name="Level1">
<labelExpression><![CDATA["Level Label expression"]]></labelExpression>
<axisLevelBucket class="java.lang.Comparable">
<bucketExpression><![CDATA[$F{brand_name}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<dataAxis axis="Columns"/>
<multiAxisMeasure name="Measure1" class="java.lang.Number" calculation="Nothing">
<labelExpression><![CDATA["sales"]]></labelExpression>
<valueExpression><![CDATA[$F{store_sales}]]></valueExpression>
</multiAxisMeasure>
</multiAxisData>
<hc:series name="Measure1"/>
</hc:chart>
</componentElement>
</band>
</summary>
</jasperReport>

No comments:

Post a Comment