Jump to content
Changes to the Jaspersoft community edition download ×
  • Creating HTML5 Bubble Chart in Jasper Studio 6.2.1


    tchen
    • Features: Charts Version: v6.2, v6.2.1 Product: JasperReports® Library

    In order to create a bubble chart in Jasper Reports, user must have three measures all using numeric type data (Integer, Long, Double, and BigDecimal class). String and Date/Timestamp type cannot be used as the measure for the chart. The measures should be listed in the chart design in x, y, and z-axis order, where the filed value in each measure will represent x-axis, y-axis for the bubble coordinate in the chart and size for the bubble, respectively.

    It is also importance to set chart category to $V{REPORT_COUNT} in order to display individual bubble in the chart. Without the count, only one bubble per chart series will get displayed.
     

    <axisLevelBucket order="None" class="java.lang.Integer">
        <bucketExpression><![CDATA[$V{REPORT_COUNT}]]></bucketExpression>
    </axisLevelBucket>
    

     

    The following is a sample report JRXML file using HTML5 bubble chart:

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Created with Jaspersoft Studio version 6.2.1.final using JasperReports Library version 6.2.1  -->
    <!-- 2016-04-11T16:40:11 -->
    <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="test_bubble"
                  pageWidth="612"
                  pageHeight="792"
                  columnWidth="555"
                  leftMargin="20"
                  rightMargin="20"
                  topMargin="20"
                  bottomMargin="20"
                  uuid="896e8b63-5c37-4773-8d2a-5d255404ac1a">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JRSrepo.xml"/>
        <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
        <queryString language="SQL">
            <![CDATA[select 0.0 as category_val, 28448 as no_of_calls, '65' as pattern_total_calls_pct, 'customer2' as i_zone_name, 'ShortRingAnswer' as category, '4/6/16 9:00 PM' as end_time
    union
    select 0.0 as category_val, 28776 as no_of_calls, '66' as pattern_total_calls_pct, 'customer3' as i_zone_name, 'ShortRingAnswer' as category, '4/6/16 9:00 PM' as end_time
    union
    select 0.0 as category_val, 29581 as no_of_calls, '67' as pattern_total_calls_pct, 'customer4' as i_zone_name, 'ShortRingAnswer' as category, '4/6/16 9:00 PM' as end_time
    union
    select 0.0 as category_val, 32459 as no_of_calls, '74' as pattern_total_calls_pct, 'customer1' as i_zone_name, 'ShortRingAnswer' as category, '4/6/16 9:00 PM' as end_time
    union
    select 0.0 as category_val, 28689 as no_of_calls, '66' as pattern_total_calls_pct, 'customer3' as i_zone_name, 'ShortRingAnswer' as category, '4/6/16 8:30 PM' as end_time
    union
    select 0.0 as category_val, 28751 as no_of_calls, '66' as pattern_total_calls_pct, 'customer4' as i_zone_name, 'ShortRingAnswer' as category, '4/6/16 8:30 PM' as end_time
    union
    select 0.0 as category_val, 28879 as no_of_calls, '66' as pattern_total_calls_pct, 'customer2' as i_zone_name, 'ShortRingAnswer' as category, '4/6/16 8:30 PM' as end_time
    union
    select 0.0 as category_val, 32742 as no_of_calls, '75' as pattern_total_calls_pct, 'customer1' as i_zone_name, 'ShortRingAnswer' as category, '4/6/16 8:30 PM' as end_time]]>
        </queryString>
        <field name="category_val" class="java.lang.Double"/>
        <field name="no_of_calls" class="java.lang.Integer"/>
        <field name="pattern_total_calls_pct" class="java.lang.String"/>
        <field name="i_zone_name" class="java.lang.String"/>
        <field name="category" class="java.lang.String"/>
        <field name="end_time" class="java.lang.String"/>
        <background>
            <band splitType="Stretch"/>
        </background>
        <title>
            <band splitType="Stretch"/>
        </title>
        <pageHeader>
            <band splitType="Stretch"/>
        </pageHeader>
        <columnHeader>
            <band splitType="Stretch"/>
        </columnHeader>
        <detail>
            <band splitType="Stretch"/>
        </detail>
        <columnFooter>
            <band splitType="Stretch"/>
        </columnFooter>
        <pageFooter>
            <band splitType="Stretch"/>
        </pageFooter>
        <summary>
            <band height="500" splitType="Stretch">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
                <componentElement>
                    <reportElement x="0" y="0" width="570" height="400"
                                   uuid="fd0ecb90-49c1-4820-afbb-57073a49a6fb">
                        <property name="local_mesure_unitheight" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    </reportElement>
                    <hc:chart xmlns:hc="http://jaspersoft.com/highcharts"
                              xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd"
                              type="Bubble">
                        <hc:hyperlink hyperlinkType="Reference" hyperlinkTarget="Blank">
                            <hyperlinkReferenceExpression>
                                <![CDATA["http://www.december.com/html/spec/colorrgbadec.html"]]>
                            </hyperlinkReferenceExpression>
                        </hc:hyperlink>
                        <hc:chartSetting name="default">
                            <hc:chartProperty name="chart.plotBorderWidth">
                                <hc:propertyExpression><![CDATA[1]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="chart.zoomType">
                                <hc:propertyExpression><![CDATA["xy"]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="credits.enabled">
                                <hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="credits.href">
                                <hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="credits.text">
                                <hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="subtitle.style.color">
                                <hc:propertyExpression><![CDATA[new java.awt.Color(-15389789)]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="subtitle.text">
                                <hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="title.style.color">
                                <hc:propertyExpression><![CDATA[new java.awt.Color(-1233126)]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="title.text">
                                <hc:propertyExpression><![CDATA["Test Bubble Report"]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="xAxis.gridLineWidth">
                                <hc:propertyExpression><![CDATA[1]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="xAxis.title.text">
                                <hc:propertyExpression><![CDATA["Category"]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="yAxis.endOnTick">
                                <hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="yAxis.startOnTick">
                                <hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
                            </hc:chartProperty>
                            <hc:chartProperty name="yAxis.title.text">
                                <hc:propertyExpression><![CDATA["Number of Calls"]]></hc:propertyExpression>
                            </hc:chartProperty>
                        </hc:chartSetting>
                        <multiAxisData>
                            <multiAxisDataset/>
                            <dataAxis axis="Rows">
                                <axisLevel name="Level1">
                                    <labelExpression><![CDATA["Level Label expression"]]></labelExpression>
                                    <axisLevelBucket order="None" class="java.lang.Integer">
                                        <bucketExpression><![CDATA[$V{REPORT_COUNT}]]></bucketExpression>
                                    </axisLevelBucket>
                                </axisLevel>
                            </dataAxis>
                            <dataAxis axis="Columns">
                                <axisLevel name="series">
                                    <labelExpression><![CDATA[]]></labelExpression>
                                    <axisLevelBucket class="java.lang.String">
                                        <bucketExpression><![CDATA[$F{i_zone_name}]]></bucketExpression>
                                    </axisLevelBucket>
                                </axisLevel>
                            </dataAxis>
                            <multiAxisMeasure name="Measure1" class="java.lang.Double" calculation="Nothing">
                                <labelExpression><![CDATA[""]]></labelExpression>
                                <valueExpression><![CDATA[$F{category_val}]]></valueExpression>
                            </multiAxisMeasure>
                            <multiAxisMeasure name="Measure2" class="java.lang.Integer" calculation="Nothing">
                                <labelExpression><![CDATA["Value"]]></labelExpression>
                                <valueExpression><![CDATA[$F{no_of_calls}]]></valueExpression>
                            </multiAxisMeasure>
                            <multiAxisMeasure name="Measure3" class="java.lang.Integer" calculation="Nothing">
                                <labelExpression><![CDATA[""]]></labelExpression>
                                <valueExpression><![CDATA[new Integer($F{pattern_total_calls_pct})]]></valueExpression>
                            </multiAxisMeasure>
                        </multiAxisData>
                        <hc:series name="Measure1"/>
                        <hc:series name="Measure2"/>
                        <hc:series name="Measure3"/>
                    </hc:chart>
                </componentElement>
            </band>
        </summary>
    </jasperReport>

    User can test this report with any PostgreSQL data source. Here is the report output:

     

    tesbubblereport.png.e961cd7af4e9f6320dae7e2515544464.png
    =================++++++++++++++++++++++++++++++++++++++++++++++++++===============
    TTC-20160425-67878


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...