Thursday, 13 June 2019

HTML5(high charts) Scatter plot visualization demo in jasper reports (7.1.1 pro)

Sample output



SQL and data preparation 

create table scatterplot_jasper_highcarts(gender_series text, measure1 integer , measure2 float)

select * from scatterplot_jasper_highcarts

INSERT INTO scatterplot_jasper_highcarts (gender_series,measure1,measure2) VALUES
('f',35000.00,350.53)
,('m',35000.00,256.03)
,('f',45000.00,315.36)
,('m',45000.00,162.11)
,('f',50000.00,260.12)
,('f',50000.00,220.54)
,('f',50000.00,274.39)
,('f',50000.00,189.90)
,('m',50000.00,216.15)
,('m',50000.00,218.36)


INSERT INTO scatterplot_jasper_highcarts (gender_series,measure1,measure2) VALUES
('m',50000.00,214.47)
,('m',50000.00,172.80)
,('f',50000.00,183.29)
,('m',55000.00,323.93)
,('f',60000.00,219.95)
,('f',60000.00,204.66)
,('f',60000.00,208.88)
,('f',60000.00,216.76)
,('m',60000.00,239.10)
,('m',65000.00,208.76)
;



JRXML ( developed on 7.1.1 professional) 

<?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="Benchmarking Avg. Deductible is &lt;450k" pageWidth="620" pageHeight="440" whenNoDataType="AllSectionsNoDetail" columnWidth="620" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isIgnorePagination="true" uuid="ea6e0229-23a6-43f3-bec9-122a187df2a5">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="explore - postgres"/>
<property name="ireport.jasperserver.url" value="http://localhost:8080/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="superuser"/>
<property name="ireport.jasperserver.reportUnit" value="/Explore/Plot_All_data_points_explore"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.report.unit.description" value="IllustrativeRenewalPackage"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.jasperreports.highcharts.interactive" value="false"/>
<property name="ireport.jasperserver.report.resource" value="/Explore/Plot_All_data_points_explore_files/main_jrxml"/>
<queryString>
<![CDATA[select * from scatterplot_jasper_highcarts]]>
</queryString>
<field name="gender_series" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="gender_series"/>
<property name="com.jaspersoft.studio.field.tree.path" value="scatterplot_jasper_highcarts"/>
</field>
<field name="measure1" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="measure1"/>
<property name="com.jaspersoft.studio.field.tree.path" value="scatterplot_jasper_highcarts"/>
</field>
<field name="measure2" class="java.lang.Double">
<property name="com.jaspersoft.studio.field.label" value="measure2"/>
<property name="com.jaspersoft.studio.field.tree.path" value="scatterplot_jasper_highcarts"/>
</field>
<title>
<band height="440" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<componentElement>
<reportElement x="0" y="0" width="620" height="440" uuid="61f9bb70-9738-4a8e-bb56-2be60b25ee72"/>
<hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="Scatter" evaluationTime="Report">
<hc:chartSetting name="default">
<hc:chartProperty name="credits.enabled" value="false"/>
<hc:chartProperty name="credits.href" value=""/>
<hc:chartProperty name="credits.text" value=""/>
<hc:chartProperty name="chart.zoomType" value="xy"/>
<hc:chartProperty name="legend.enabled_customSimpleMode" value="true"/>
<hc:chartProperty name="legend.enabled">
<hc:propertyExpression><![CDATA[true]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="plotOptions.series.marker.radius">
<hc:propertyExpression><![CDATA[6]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="title.text" value="Scatter plot demo"/>
</hc:chartSetting>
<multiAxisData>
<multiAxisDataset/>
<dataAxis axis="Rows">
<axisLevel name="Level1">
<labelExpression><![CDATA["Level Label expression"]]></labelExpression>
<axisLevelBucket class="java.lang.Comparable">
<bucketExpression><![CDATA[$V{REPORT_COUNT}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<dataAxis axis="Columns">
<axisLevel name="&quot;gender&quot;">
<labelExpression><![CDATA[]]></labelExpression>
<axisLevelBucket class="java.lang.Comparable">
<bucketExpression><![CDATA[$F{gender_series}]]></bucketExpression>
<labelExpression><![CDATA["gender"]]></labelExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<multiAxisMeasure name="measure1" class="java.lang.Number" calculation="Nothing">
<labelExpression><![CDATA["measure1"]]></labelExpression>
<valueExpression><![CDATA[$F{measure1}]]></valueExpression>
</multiAxisMeasure>
<multiAxisMeasure name="measure2" class="java.lang.Number" calculation="Nothing">
<labelExpression><![CDATA["measure2"]]></labelExpression>
<valueExpression><![CDATA[$F{measure2}]]></valueExpression>
</multiAxisMeasure>
</multiAxisData>
<hc:series name="measure1"/>
<hc:series name="measure2"/>
</hc:chart>
</componentElement>
</band>
</title>
</jasperReport>

No comments:

Post a Comment