Recent posts

You are browsing Enabling End User Reporting

Demo of using BIRT with ClearQuest Tomorrow

Tomorrow, November 19th, Actuate and IBM are co-presenting an online webinar on working with BIRT reports with IBM ClearQuest and I am doing the demo portion.  I plan to show BIRT reports inside the ClearQuest client, the ability to schedule and distribute those reports in the Actuate iServer Express, and interact with the reports using the Interactive Viewer.  There is still time to register if you want to attend.


Test Drive Web Reporting Capabilities on BIRT Exchange

We’ve added a new live report environment to BIRT Exchange so you can play around with a number of products that make BIRT reports more interactive.

You can try out the BIRT Designer for End Users, that allows you to create BIRT reports over the web, or the Interactive Viewer that allows you to change the formatting of a BIRT report as you view it.

We’ll also be using this environment to host reports that illustrate design concepts that we refer to in DevShare entries or Forum posts.

Check it out here.


Webinar: Using the Web-Based BIRT Report Designer

This Friday, July 11th, Rob Murphy from Actuate will be demonstrating how to use the web-based BIRT report designer.  This webinar is part of the BIRT Exchange webinar series which are only 30 minutes in length every other week.

Sign up for the webinar or get more information at BIRT Exchange.

The webinar will be recorded and available at the same link above a few days after the webinar.


BIRT Chart Scripting: Dynamic Markers

I had the opportunity this week to dig into chart scripting a bit.  I needed to create some y-axis marker lines (like the picture below shows) on a chart but didn’t know where the marker lines needed to be drawn until run-time.  I also wanted to dynamically color the bars of the chart if they pass one of the marker lines.

birt_chart_scripting1.gif

You can add Marker Lines and Marker Ranges in the chart wizard, but it won’t take an expression for the value so I had to add some script in a chart event to push the number in at runtime. 

birt_chart_scripting2.gif

The first thing I did was create some global variables to hold the value I needed for each marker line.  In my example, I needed to get the locations of the marker lines from a dataset field.  There are lots of places you could put this code below, but I put it in the onCreate() event of the table.  You don’t have to display your data in a table just to get a chart so you could also set these global variables in a dataset script event if you like.  I added my chart to the table header area and then bound my chart to the container data so the chart would change as the table was filtered as you’ll see at the bottom of this post.  The code example below creates 3 global variables from table row data in the onCreate() event of the table.

reportContext.setPersistentGlobalVariable("min_val",this.getRowData().getColumnValue(”Minimum”));
reportContext.setPersistentGlobalVariable(”ok_val”,this.getRowData().getColumnValue(”Satisfactory”));
reportContext.setPersistentGlobalVariable(”great_val”,this.getRowData().getColumnValue(”Outstanding”));

Once you have filled the global variables with values, you can access them in your chart events.  The code below adds 3 markers to the Y Axis of the chart, and sets the caption and color for each marker.

function beforeGeneration(chart, icsc)
{
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl);
var chart = icsc.getChartInstance();
var yAxis = chart.getAxes().get(0).getAssociatedAxes().get(0);
var min_value = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("min_val");
var ok_value = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable(”ok_val”);
var great_value = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable(”great_val”);

min_ml = MarkerLineImpl.create(yAxis, NumberDataElementImpl.create(min_value));
min_ml.getLabel().getCaption().setValue(”Minimum”);
min_ml.getLineAttributes().getColor().set(255,0,0);

ok_ml = MarkerLineImpl.create(yAxis, NumberDataElementImpl.create(ok_value));
ok_ml.getLabel().getCaption().setValue(”Satisfactory”);
ok_ml.getLineAttributes().getColor().set(0,255,0);

great_ml = MarkerLineImpl.create(yAxis, NumberDataElementImpl.create(great_value));
great_ml.getLabel().getCaption().setValue(”Outstanding”);
great_ml.getLineAttributes().getColor().set(0,0,255);
}

birt_chart_scripting3.gif

I now had 3 marker lines on my chart but I also wanted to color the bars that pass the marker lines.  For this, I found an example from this blog post that helped me figure out how to get the marker values from the axis.  The code below gets the value of each marker line and then compares those values against the value of each datapoint.  When a datapoint value crosses a marker line, the color of the bar is changed.

function beforeDrawDataPoint(dph, fill, icsc) {
chart =  icsc.getChartInstance();
min_marker = chart.getAxes().get(0).getAssociatedAxes().get(0).getMarkerLines().get(0).getValue().getValue();
ok_marker = chart.getAxes().get(0).getAssociatedAxes().get(0).getMarkerLines().get(1).getValue().getValue();great_marker = chart.getAxes().get(0).getAssociatedAxes().get(0).getMarkerLines().get(2).getValue().getValue();

if (dph.getOrthogonalValue() <= min_marker) {
  fill.set(255,0,0);
} else if (dph.getOrthogonalValue() <= ok_marker) {
  fill.set(0,255,0);
} else if (dph.getOrthogonalValue() <= great_marker) {
  fill.set(0,0,255);
} else {
  fill.set(255,255,0);
}
}

birt_chart_scripting4.gif

I now had the bars colored like I wanted and since I bound the chart to the table data, the chart automatically changes as the table is filtered.  In the example below, I filtered the report by the month column selecting everything from 03-07 to 08-07 and the chart changes from 12 bars to 7 bars as shown below.

 birt_chart_scripting5.gif  birt_chart_scripting6.gif

This report example was created with BIRT 2.2.0 and can be downloaded from: http://www.birt-exchange.com/modules/wfdownloads/singlefile.php?cid=2&lid=276


Authors