Friday, September 28, 2012
BIRT 4.2.1 Released
Posted by
Jason Weathersby
at
11:31 AM
17
comments
Monday, September 10, 2012
BIRT, Cassandra and Hector
While
BIRT offers many ways to connect to Cassandra, including using the Cassandra
JDBC driver, this post focuses on using a Scripted data source to call the
Hector Client Java client. A BIRT scripted
data source allows external Java classed to be called to retrieve data for a
BIRT report and can be written in Java or JavaScript. The examples below will use JavaScript. For this post we used the DataStax
community edition which is available here, and created a keyspace with the name users and a column
family named User. The User column
family contains three string columns for first name, last name and age. The script used to load the sample data is
available in the example download.
Set Designer Classpath
-
hector-core-version
.jar - hector-object-mapper-version
.jar - slf4j-api-version
.jar - libthrift-
version.jar - apache-cassandra-thrift-version
.jar - guava-rversion
.jar - commons-lang-version
.jar
Select the enable project specific settings checkbox and add the jars in the lib folder you created earlier.
Creating a Scripted Data Source using Hector
Deploying a Report that Uses the Hector API
Posted by
Jason Weathersby
at
8:24 AM
7
comments
Tuesday, July 31, 2012
Using a Global JS Function across BIRT Reports
BIRT provides a scripting model that allows
report customizations by implementing event handlers. These events can be written in Java or
JavaScript. This model is described on
the Eclipse Birt Site.
//external js function
function reverseMyString( MyString )
{
var rString = "";
for (i = 0; i < MyString.length; i++)
{
rString = MyString.substring(i, i+1) + rString;
}
return rString;
}
Posted by
Jason Weathersby
at
6:03 PM
18
comments
Wednesday, June 27, 2012
BIRT 4.2 Released
Posted by
Jason Weathersby
at
11:18 AM
1 comments
Wednesday, June 20, 2012
BIRT Area Chart Modifications
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));
Posted by
Jason Weathersby
at
9:35 AM
4
comments
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:
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.
Posted by
Jason Weathersby
at
1:47 PM
13
comments
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.
Posted by
Jason Weathersby
at
10:47 AM
0
comments





















