Wednesday, June 27, 2012

BIRT 4.2 Released


BIRT 4.2 is now available and with this release many improvements and new features are available. BIRT 4.2 now provides a new Excel data source that supports multi-sheet data sets, derived measures are now available on cubes, better filter support with aggregates that allows cumulative data to include or exclude filtered rows, and support for an OSGi or POJO runtime.  In addition BIRT now supports a Donut chart type and the build process has been modified to add Maven support for the BIRT engines.

To read more about these and other new features for BIRT, see the BIRT 4.2 New and Notable.

Wednesday, June 20, 2012

BIRT Area Chart Modifications


BIRT supplies a very robust and extensible chart engine, that can be used standalone or in conjunction with the report engine.  Currently the chart engine supports fourteen different main chart types and many sub-types.  Charts can be emitted in PNG, JPG, BMP, SVG within reports and can be also emitted to SWT, PDF and Swing outside of the report engine.    Virtually every area of the chart engine is also extensible, from adding new chart types to new output formats.  These are done with Eclipse extension points.  In addition the chart engine supports client side interactivity and server side event scripting.  Both of which have been discussed on the site before.
BIRT Chart Scripting Overview


One of the most often used chart types is the Area chart. 

Simple Area Chart


While this type of chart is an effective visualization, we often get questions on how to extend the Area chart to the extents of the plot.  In this post we will put together an example that illustrates one way of extending the covered area.

As discussed extensively in the post referenced above, the chart can be modified using script event handlers.  These handlers can be written in Java or JavaScript.  With certain chart types the render engine renders to the center of a data point intersection.  The Area and Line Charts are examples of the types of charts that exhibit this behavior.  To extend the area chart, a beforeDrawSeries event can be implemented to change the x location of the first and last data point to cover more area.  This approach will work for both 2D and 2D with depth types of charts.  The beforeDrawSeries event is fired for each runtime series and once for the category series.  So in the script you must first check that the locations you are going to modify are for the right series.  If you are not using optional grouping this check is as simple as just getting the series identifier.  This identifier is set as the series title in the third tab of the chart wizard.
Series Identifier
So in the beforeDrawSeries event handler you can check the series identifier by calling the following code.
if( series.getSeriesIdentifier() == "Series 1" ){}

The chart renderer stores all the data point information in a data point hints array.  This array can be retrieved in the beforeDrawSeries event handler by calling:

var dpharray = seriesRenderer.getSeriesRenderingHints().getDataPoints();


Each data point element in the array stores information like the category value, orthogonal value, and x/y location values that the renderer will use to draw the chart.  To get the x location of the area chart we first call the getLocation method and then the getX method.  This needs to be done for the first and last data points in the array.  You can set the x value using the setX method on the location object.  You can also get the width of a data point by calling the getSize method.  This method returns the width show in red in the following diagram.
The getSize method

Using the above methods we can subtract half the width from the first data point x value and add half the width to the x value of the last data point value.  The complete script is shown below.

function beforeDrawSeries( series, seriesRenderer, context )
{      
      if( series.getSeriesIdentifier() == "Series 1" ){
      var dpharray = seriesRenderer.getSeriesRenderingHints().getDataPoints();
                  var xval = dpharray[0].getLocation().getX();
                  var wid = dpharray[0].getSize();
                  dpharray[0].getLocation().setX(xval-(wid/2));
                  var xval = dpharray[dpharray.length-1].getLocation().getX();
                  dpharray[dpharray.length-1].getLocation().setX(xval+(wid/2));  

      }

}

A before and after example 2D with depth chart is shown below.
Before Example


After Example

This example is available on Birt-Exchange.

Friday, May 11, 2012

Add Values to a BIRT Chart

When building reports that contain Charts, the BIRT data engine is responsible for creating the chart series data points. These data points are generally tied to BIRT data sets or cubes. While these mechanisms handle a lot of the grouping an aggregation of the data to be charted it may be desirable to add some manual data points to the chart. Fortunately this can be done with a fairly simple chart script event handler. If you have not done any chart scripting before, you may want to read over this post on scripting.

Chart event handlers are fired on the server and can be written in Java or JavaScript. The event order is listed in the post described earlier. The before and after DatasetFilled events are fired first. These events are fired for every runtime series that will be plotted. For example if you have one bar series, these events will be fired once for the category series values and once for the bar series values. If you use optional grouping, these events will be fired for every optional group the data engine encounters. The afterDataSetFilled event handler is passed a reference to the current series and the data set that will be used by the chart engine. This is an ideal location to change values, check for nulls or add values to the chart.
Lets assume we have the following Chart:

Generic Chart
This chart contains one bar series with four data points. In this example the afterDataSetFilled event will be fired twice, once for the category values and once for the bar series values. We can then use the following script to add a value to the beginning and the end of the series.
function afterDataSetFilled(series, dataSet, icsc)
{
	importPackage( Packages.java.util );
	importPackage(Packages.java.lang);	
	importPackage( Packages.org.eclipse.birt.chart.model.type.impl );
	importPackage( Packages.org.eclipse.birt.chart.model.data.impl);
      var list = dataSet.getValues();
	var narray1 = new ArrayList( );

//Check Series Type
//SeriesImpl used for category series
//AreaSeriesImpl
//BarSeriesImpl
//BubbleSeriesImpl
//DialSeriesImpl
//DifferenceSeriesImpl
//GanntSeriesImpl
//LineSeriesImpl
//PieSeriesImpl
//ScatterSeriesImpl
//StockSeriesImpl

	
	if( series.getClass() == BarSeriesImpl ){
		narray1.add(new Double(40.6));
	}else{
		narray1.add("AddBefore");
	}	
	
	var llen =list.length;
    for ( i=0; i < llen; i++)
    {
		narray1.add(list[i]);
    }
//Chart Data Set Types
//BubbleDataSetImpl
//DateTimeDataSetImpl
//DifferenceDataSetImpl
//GanttDataSetImpl
//NumberDataSetImpl
//StockDataSetImpl
//TextDataSetImpl
    
	if( series.getClass() == BarSeriesImpl ){
		narray1.add(new Double(25.6));
		series.setDataSet(NumberDataSetImpl.create( narray1 ));
	}else{
		narray1.add("AddAfter");
		series.setDataSet(TextDataSetImpl.create( narray1 ));
	}	
   
}
The first thing this script does is to get the current values for the given series and creates a new ArrayList. Next it checks to see which series triggered this event. It does this by checking the series class. You could also check the series identifier. Once the series type is determined we add an initial value to the ArrayList, followed by adding all existing values to the ArrayList. Finally a last value is added to the ArrayList and a new chart data set is created. The type of chart data set that is created will depend on how you configured the chart and what type of chart you are using. The comments show additional options. In this example we are using a Text data set for the categories and a number data set for the bar series values. The output of the chart should now look like:
Chart After Script
This example is available for download at Birt-Exchange. For an example on adding a whole new series to a chart, see this post.

Thursday, April 19, 2012

BIRT Federal Survey

If you are currently designing applications using BIRT to support the US Federal government, then you should look into the latest survey competition hosted by Actuate. We want to know how you're working with BIRT and the creative ways it's being applied. Anyone using BIRT to develop tools and solutions for the government is eligible. Complete this short 10 minute survey describing your use of BIRT within the Federal government and send us a screenshot of the application by May 11, 2012. All qualified entries will receive a BIRT Rocks! sound activated T-shirt and will be eligible for a chance to win an iPad.



For more information, review the Federal BIRT Competition 2012 Rules and Conditions.

Friday, March 16, 2012

BIRT 3.7.2 New Features

A couple of weeks ago the Team released version 3.7.2 of BIRT. While this release was mainly focused on bug fixes, a few new features that were originally planned for Juno Release (June 2012) made it into the final build. In this post we walk through some of these features.

Enhanced Aggregate Filter Support


The BIRT project currently provides an Aggregation Report Item. This Report Item supplies over 25 aggregate functions, like SUM, COUNT, TOPN, that can be used to analyze data. The Aggregation Report Item even provides an extension point to add your own functions. While this Report Item is very powerful it only aggregates the rows available to it. If you apply filters to the container element, the Aggregation Item will only aggregate the filtered rows. This is not always desired. In some cases users filter rows for display purposes only. In these cases, consumers of the data may still wish to have the filtered rows aggregated. To accommodate this feature a check box has been added to the Filter Editor. This checkbox “Recalculate Totals”, determines if aggregates will include the filtered out rows. If the box is checked the rows will be filtered out of aggregation elements. If the box is not checked, the filtered out rows will be included.


BIRT Filter Editor
This feature is available on all filter locations, including data sets, tables, crosstabs and charts. The reports attached to this post include examples for table, crosstab and chart filters.


Table and Crosstab Filter examples


Chart Filter Examples

Derived Cube Measure



BIRT provides a data cube element which appears in the Data Explorer view and allows the developer to build cubes based on existing data sets. These cubes are constructed using dimensions and measures and can be consumed by crosstab and chart report items. In prior releases of BIRT when adding measures to the cube the user was restricted to the data set elements and an aggregation function. With the release of BIRT 3.7.2, developers can now create derived measures in the cube which use other measures for calculating the new measure.



The Measure Editor has been enhanced to supply a check box to indicate whether the measure is derived. If the new measure is derived, new options are available in the expression builder to access the existing measures. For example, in the image above an average price per unit is calculated based on the Amount and Quantity measures. Once the measure is created it functions in the same fashion as existing measures including totaling capabilities.


Derived Cube Measure consumed by Crosstab

Relative Time Period Report Item


When using crosstabs to display time based data, scripting is often required to implement complex time period calculations. With this release BIRT now offers a new report item that will handle time period based calculations automatically when used within a crosstab. This report item “Relative Time Period” is located in the palette and can be dragged to the measure field of a crosstab. The new report item can also be placed by right clicking on any measure in an existing crosstab.


Insert Relative Time Period Report Item into Crosstab

The Relative Time Period report item supports 13 different periods, including Previous N Year, YTD, Current Quarter, Trailing NPeriods, and Next NPeriods.

Relative Time Period Aggregation Builder

This report item works very similar to an Aggregation Report item, but allows the aggregation to be grouped on given period(s) in relation to the current time dimension value. For example the following image depicts a crosstab that contains two measures (Amount and QTY) and two Relative Time Period Report Items (QTY to Date and Previous Qtr).


Relative Time Period Example

OSGi Runtime


With the introduction of BIRT 3.7, a new POJO runtime was delivered to help ease deploying of BIRT. While the new runtime is simpler in most cases some users prefer the OSGi based runtime. With the 3.7.2 release the OSGi runtime is also available for download. To download the OSGi based runtime select the “full BIRT 3.7.2 Download Page” link from the main BIRT downloads page.


BIRT Download Page

On the full download page select the Report Engine OSGi deployment link to download.

BIRT OSGi runtime link

The reports used in this post are available at BIRT Exchange.

Friday, March 02, 2012

BIRT at CeBIT 2012

The BIRT team will be participating with five other Eclipse member companies in the Eclipse theme island at CeBit this year (March 5-10 Hanover, Germany). There will be scheduled demos and an opportunity to speak with the experts. This event will take place in the Open Source Park in Hall 2, Block D58, Both 170. For more information on this event including the schedule check out this link.

The BIRT team will also be giving a free half-day Workshop (BIRT@CeBIT) on March 9. This Workshop will include presentations on BIRT technology, accelerating with ActuateOne, and Report Designer training. To see the agenda and register for this event go here.

Wednesday, February 08, 2012

Spring Framework and BIRT Integration

Many BIRT users also use the Spring Framework, and while we have blogged about different integration scenarios before, many of the newer features of both projects have not been discussed. In the last couple of weeks the BIRT and Spring teams have worked together to create some examples and an article (Spring Framework & BIRT) that describes the following integration options:

• Integrating the BIRT engines in Spring MVC
• Accessing Spring beans from the BIRT Viewer
• Using Spring Remoting to access Spring Beans from a BIRT report

These examples were built using the latest versions or BIRT( 3.7.1) and the Spring Framework(3.1.0).

Thanks to Josh Long, Spring Developer Advocate and the Spring team for working with us to put this content together.