<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>the empty quarter &#187; birt</title>
	<atom:link href="http://www.martinhammer.com/blog/index.php/tag/birt/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.martinhammer.com/blog</link>
	<description>Sorry, but you are looking for something that isn’t here.</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:33:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Script to get Report Viewer servlet mapping</title>
		<link>http://www.martinhammer.com/blog/index.php/2011/08/script-to-get-report-viewer-servlet-mapping/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2011/08/script-to-get-report-viewer-servlet-mapping/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 02:32:27 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[birt]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[servlet]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=659</guid>
		<description><![CDATA[Sometimes it may be useful to know inside the report which servlet mapping is used to run the report (e.g. frameset, run, preview). var sMapping = reportContext.getHttpServletRequest.getRequestURI(); var nPos = sMapping.lastIndexOf( "/" ) + 1; this.text = sMapping.substring( nPos ); You can place the above code inside a label to see the servlet mapping.]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Sometimes it may be useful to know inside the report which <a href="http://www.eclipse.org/birt/phoenix/deploy/viewerUsage2.2.php#servlets">servlet mapping</a> is used to run the report (e.g. frameset, run, preview).</p>
<p style="text-align: left;"><code><br />
var sMapping = reportContext.getHttpServletRequest.getRequestURI();<br />
var nPos = sMapping.lastIndexOf( "/" ) + 1;<br />
this.text = sMapping.substring( nPos );<br />
</code></p>
<p style="text-align: left;">You can place the above code inside a label to see the servlet mapping.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2011/08/script-to-get-report-viewer-servlet-mapping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BIRT 3.7 Released</title>
		<link>http://www.martinhammer.com/blog/index.php/2011/06/birt-3-7-released/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2011/06/birt-3-7-released/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 14:03:48 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[birt]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=657</guid>
		<description><![CDATA[BIRT 3.7, previously codenamed Indigo, was released on June 22. Here are the necessary links to find out more about this latest version: New and Notable for BIRT 3.7 Release BIRT 3.7.0 Download Page BIRT Project Plan]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">BIRT 3.7, previously codenamed Indigo, was released on June 22. Here are the necessary links to find out more about this latest version:</p>
<ul>
<li><a href="http://www.eclipse.org/birt/phoenix/project/notable3.7.php">New and Notable for BIRT 3.7 Release</a></li>
<li><a href="http://download.eclipse.org/birt/downloads/build.php?build=R-R1-3_7_0-201106151818">BIRT 3.7.0 Download Page</a></li>
<li><a href="http://wiki.eclipse.org/BIRT_Project_Plan">BIRT Project Plan</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2011/06/birt-3-7-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generic code to get BIRT report parameters dynamically (new and improved!)</title>
		<link>http://www.martinhammer.com/blog/index.php/2011/06/generic-code-to-get-birt-report-parameters-dynamically-new-and-improved/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2011/06/generic-code-to-get-birt-report-parameters-dynamically-new-and-improved/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 16:57:31 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[birt]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=635</guid>
		<description><![CDATA[In an earlier post we discussed a generic way to dynamically get the list of report parameters at run time without having to hardcode the parameter names in the script. As was correctly pointed out in the comments, the code did not work for parameter groups (and also cascading parameters). However, it is possible to [...]]]></description>
			<content:encoded><![CDATA[<p>In an <a title="Generic code to get BIRT report parameters dynamically" href="http://www.martinhammer.com/blog/index.php/2010/11/generic-code-to-get-birt-report-parameters-dynamically/">earlier post</a> we discussed a generic way to dynamically get the list of report parameters at run time without having to hardcode the parameter names in the script. As was correctly pointed out in the comments, the code did not work for parameter groups (and also cascading parameters). However, it is possible to modify the code to get it working even for those cases, and the change is not a huge one.</p>
<p>The main difference is we will use the method <a href="http://www.birt-exchange.com/be/documentation/BIRT_231/EngineJavadoc/model/api/org/eclipse/birt/report/model/api/ModuleHandle.html#getAllParameters%28%29">getAllParameters()</a> instead of <a href="http://www.birt-exchange.com/be/documentation/BIRT_231/EngineJavadoc/model/api/org/eclipse/birt/report/model/api/ModuleHandle.html#getParameters%28%29">getParameters()</a> of <a href="http://www.birt-exchange.com/be/documentation/BIRT_231/EngineJavadoc/model/api/org/eclipse/birt/report/model/api/ReportDesignHandle.html">ReportDesignHandle</a>. It seems that getParameters returns only the &#8220;top level&#8221; parameters, whereas getAllParameters flattens the groups and the nested as well as top level parameters. One thing to watch out for is that the return types of the two functions are different: <a href="http://download.oracle.com/javase/1.5.0/docs/api/java/util/List.html">java.util.List</a> (getAllParameters) vs. <a href="http://www.birt-exchange.com/be/documentation/BIRT_231/EngineJavadoc/model/api/org/eclipse/birt/report/model/api/SlotHandle.html">org.eclipse.birt.report.model.api.SlotHandle</a> (getParameters). Also, we have included a check for the class of the parameter entry in the list, in order to exclude the groups themselves. You can comment out the if statement in case you wish to see the group names as well.</p>
<p>Here is the updated working code:</p>
<p><code><br />
var sOutput = "";<br />
var parameterArray = reportContext.getDesignHandle().getAllParameters();<br />
var parameterCount = parameterArray.size();<br />
for( var i = 0; i &lt; parameterCount; i++ )<br />
{<br />
&nbsp;&nbsp;var sParClass = parameterArray.get( i ).getClass().toString();<br />
&nbsp;&nbsp;if( sParClass == "class org.eclipse.birt.report.model.api.ScalarParameterHandle" )<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;var sParName = parameterArray.get( i ).getFullName();<br />
&nbsp;&nbsp;&nbsp;&nbsp;var sParVal = reportContext.getParameterValue( sParName );<br />
&nbsp;&nbsp;&nbsp;&nbsp;sOutput = sOutput + sParName + " = " + sParVal + "\n";<br />
&nbsp;&nbsp;}<br />
}<br />
this.content = sOutput;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2011/06/generic-code-to-get-birt-report-parameters-dynamically-new-and-improved/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with the Palette in BIRT charts, Part 1</title>
		<link>http://www.martinhammer.com/blog/index.php/2011/06/working-with-the-palette-in-birt-charts-part-1/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2011/06/working-with-the-palette-in-birt-charts-part-1/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 14:31:45 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[birt]]></category>
		<category><![CDATA[charts]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=620</guid>
		<description><![CDATA[On this blog we have often talked about overriding the default behaviour of the BIRT chart palette by dynamically setting colours based on data values. However, it is perhaps worth looking in more detail at the palette itself to understand the default behaviour and appreciate how it can be tweaked. Each chart has a palette. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.martinhammer.com/blog/wp-content/uploads/2011/06/Screenshot-New-Chart-.png"><img class="size-medium wp-image-623 alignright" title="Format Chart tab of the Edit Chart wizard" src="http://www.martinhammer.com/blog/wp-content/uploads/2011/06/Screenshot-New-Chart--300x239.png" alt="Format Chart tab of the Edit Chart wizard" width="300" height="239" /></a>On this blog we have often talked about overriding the default behaviour of the BIRT chart palette by dynamically setting colours based on data values. However, it is perhaps worth looking in more detail at the palette itself to understand the default behaviour and appreciate how it can be tweaked.</p>
<p>Each chart has a palette. The palette determines the colours used for drawing the series in the chart. From the UI perspective, the palette options are accessed on the last tab of the Edit Chart dialog (Format Chart), the first selection in the tree on left-hand-side (Series). It is worth noting that a chart only has one palette, even if the chart contains multiple series.</p>
<p><a href="http://www.martinhammer.com/blog/wp-content/uploads/2011/06/Screenshot-Series-Palette-.png"><img class="alignleft size-medium wp-image-624" title="BIRT chart series palette" src="http://www.martinhammer.com/blog/wp-content/uploads/2011/06/Screenshot-Series-Palette--227x300.png" alt="BIRT chart series palette" width="227" height="300" /></a>By default there are 32 entries in the palette. They are used in the chart from top to bottom, i.e. in the default scenario the first category will be coloured blue, the next one red and so on. The Add and Remove buttons in the Series Palette dialog can be used to change the number of entries. What happens when the chart contains more categories than the list of palette entries? The answer is that the palette will wrap around, i.e. the 33rd category will be coloured in the same way as the first one. If the number of categories is known in advance, one can extend the palette using the Add button to create the necessary number of palette entries. (Naturally, one should question the design of such a chart, will the user really be able to extract any meaning from a chart with 32 or more different colours? In most cases, probably not.)</p>
<p>Each palette entry itself can be edited. Not only is it possible to set one of the predefined colours, on<a href="http://www.martinhammer.com/blog/wp-content/uploads/2011/06/Screenshot-Palette-Options.png"><img class="alignright size-full wp-image-625" title="BIRT chart palette editing a palette entry" src="http://www.martinhammer.com/blog/wp-content/uploads/2011/06/Screenshot-Palette-Options.png" alt="BIRT chart palette editing a palette entry" width="204" height="274" /></a>e can also set a custom colour, a linear gradient based on two colours or even an image file. It is also possible to specify different colour for positive and negative values.</p>
<p>As we already mentioned, the palette colours are applied top to bottom without any further logic, in particular they are not tied to the actual data point values themselves. Several common scenarios and scripting approaches for solving the issue have already been discussed on this blog: <a title="Setting BIRT chart series palette dynamically" href="http://www.martinhammer.com/blog/index.php/2010/01/setting-birt-chart-series-palette-dynamically/">Setting BIRT chart series palette dynamically</a>, <a title="Setting BIRT chart series palette dynamically, part 2 – area charts" href="http://www.martinhammer.com/blog/index.php/2010/02/setting-birt-chart-series-palette-dynamically-part-2-area-charts/">Setting BIRT chart series palette dynamically, part 2 – area charts</a>, <a title="Setting BIRT chart series palette dynamically, part 3 – stacked bar charts" href="http://www.martinhammer.com/blog/index.php/2010/09/setting-birt-chart-series-palette-dynamically-part-3/">Setting BIRT chart series palette dynamically, part 3 – stacked bar charts</a>.</p>
<p>In the second part of this article we will look at how the palette and related objects can be manipulated programmatically, i.e. through scripting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2011/06/working-with-the-palette-in-birt-charts-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open source BI: BIRT vs Jasper vs Pentaho</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/12/open-source-bi-birt-vs-jasper-vs-pentaho/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/12/open-source-bi-birt-vs-jasper-vs-pentaho/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 00:33:58 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[birt]]></category>
		<category><![CDATA[jasper]]></category>
		<category><![CDATA[pentaho]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=603</guid>
		<description><![CDATA[In case you missed these, Innovent Solutions (one of the corporate backers of Eclipse BIRT project) published papers comparing Jasper and Pentaho to BIRT. Naturally, they conclude that BIRT is top of the pile in open source reporting, however they do justify this conclusion and the papers make an interesting read. BIRT versus Jasper BIRT [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">In case you missed these, <a href="http://www.innoventsolutions.com">Innovent Solutions</a> (one of the <a href="http://www.eclipse.org/birt/phoenix/project/pmc.php#pmc">corporate backers</a> of Eclipse BIRT project) published papers comparing <a href="http://jasperforge.org/">Jasper</a> and <a href="http://www.pentaho.org/">Pentaho</a> to <a href="http://www.eclipse.org/birt/phoenix/">BIRT</a>. Naturally, they conclude that BIRT is top of the pile in open source reporting, however they do justify this conclusion and the papers make an interesting read.</p>
<ul style="text-align: left;">
<li><a href="http://www.innoventsolutions.com/birt-vs-jasper.html">BIRT versus Jasper</a></li>
<li><a href="http://www.innoventsolutions.com/birt-vs-pentaho.html">BIRT versus Pentaho</a></li>
<li><a href="http://www.innoventsolutions.com/birt-jasper-pentaho-comparison-matrix.html">OSS Reporting Comparison Matrix</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/12/open-source-bi-birt-vs-jasper-vs-pentaho/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generic code to get BIRT report parameters dynamically</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/11/generic-code-to-get-birt-report-parameters-dynamically/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/11/generic-code-to-get-birt-report-parameters-dynamically/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 14:42:00 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[birt]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=595</guid>
		<description><![CDATA[UPDATE: For an improved version of the code which works correctly with parameter groups and cascading parameters please see this updated post. Thank you to Stork for pointing out the problem with this code. The traditional way of accessing BIRT report parameters from script is through the expression ReportContext.getParameterValue( parameterName ). Naturally this method requires [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><strong>UPDATE:</strong> For an improved version of the code which works correctly with parameter groups and cascading parameters please see <a title="Generic code to get BIRT report parameters dynamically (new and improved!)" href="http://www.martinhammer.com/blog/index.php/2011/06/generic-code-to-get-birt-report-parameters-dynamically-new-and-improved/">this updated post</a>. Thank you to Stork for pointing out the problem with this code.</p>
<p style="text-align: left;">The traditional way of accessing BIRT report parameters from script is through the expression <a href="http://www.birt-exchange.com/be/documentation/BIRT_231/EngineJavadoc/enginescript/api/org/eclipse/birt/report/engine/api/script/IReportContext.html#getParameterValue%28java.lang.String%29">ReportContext.getParameterValue( parameterName )</a>. Naturally this method requires one to know the name of the parameter at design time (i.e. when writing the script), which is fine in most cases.</p>
<p style="text-align: left;">There are however situations in which a more generic approach is preferable. For example, one might wish to implement a usage statistics system, where each time a report is run certain information is persisted in a usage tracking database. This will include the name of the report, the time of execution and perhaps also the selected parameter values. The obvious difficulty is that different reports are likely to have different sets of parameters. In anything but the simplest and smallest set of reports, it would be impractical to edit the code individually for each report. On the contrary, the appropriate approach is to create a generic library component which can be maintained in one place and referenced from the reports.</p>
<p style="text-align: left;">The code below is a simple demonstration how the list of parameters and their values can be read dynamically at run-time. To see it working, simply paste it into the onPrepare method of a text element.</p>
<p><code><br />
var sOutput = "";<br />
var parameterArray = reportContext.getDesignHandle().getParameters();<br />
var paramaterCount = parameterArray.getCount();<br />
for( var i = 0; i &lt; paramaterCount; i++ )<br />
{<br />
&nbsp;&nbsp;var sParName = parameterArray.get( i ).getFullName();<br />
&nbsp;&nbsp;var sParVal = reportContext.getParameterValue( sParName );<br />
&nbsp;&nbsp;sOutput = sOutput + sParName + " = " + sParVal + "\n";<br />
}<br />
this.content = sOutput;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/11/generic-code-to-get-birt-report-parameters-dynamically/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Retrieve BIRT report name in script</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/11/retrieve-birt-report-name-in-script/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/11/retrieve-birt-report-name-in-script/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 14:33:02 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[birt]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=591</guid>
		<description><![CDATA[The following expression will dynamically get the file name of the report: reportContext.getReportRunnable().getReportName(); Two points to note: The expression actually returns the full report URI rather than just the name, i.e. something like file:/C:/BIRT/Report01.rptdesign. The URI is percent-encoded and so space characters will be returned as %20 and so on for other special characters, e.g. [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">The following expression will dynamically get the file name of the report:</p>
<p><code>reportContext.getReportRunnable().getReportName();</code></p>
<p style="text-align: left;">Two points to note:</p>
<ul style="text-align: left;">
<li>The expression actually returns the full report URI rather than just the name, i.e. something like <code>file:/C:/BIRT/Report01.rptdesign</code>.</li>
<li>The URI is <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Percent-encoding">percent-encoded</a> and so space characters will be returned as %20 and so on for other special characters, e.g. <code>file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps/birt-viewer/Report01.rptdesign</code>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/11/retrieve-birt-report-name-in-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting BIRT chart series palette dynamically, part 3 – stacked bar charts</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/09/setting-birt-chart-series-palette-dynamically-part-3/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/09/setting-birt-chart-series-palette-dynamically-part-3/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 13:09:49 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[birt]]></category>
		<category><![CDATA[charts]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=575</guid>
		<description><![CDATA[In what is rapidly becoming a mini-series, we have so far discussed how to set BIRT chart palette dynamically (based on category values) for pie charts and area charts. Today we cover stacked bar charts, i.e. bar charts with the Optional Grouping data element. Once again, let&#8217;s start with a quick recap. In what is [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">In what is rapidly becoming a mini-series, we have so far discussed how to set BIRT chart palette dynamically (based on category values) for <a href="http://www.martinhammer.com/blog/index.php/2010/01/setting-birt-chart-series-palette-dynamically/">pie charts</a> and <a href="http://www.martinhammer.com/blog/index.php/2010/02/setting-birt-chart-series-palette-dynamically-part-2-area-charts/">area charts</a>. Today we cover stacked bar charts, i.e. bar charts with the Optional Grouping data element.</p>
<p style="text-align: left;">Once again, let&#8217;s start with a quick recap. In what  is a fairly common scenario, one chooses the palette colours to match  with particular category values. For example, in the chart below “High”  is represented in green, “Mid” in orange and “Low” in red.</p>
<p style="text-align: center;"><img class="size-full wp-image-576 aligncenter" title="Stacked bar chart" src="http://www.martinhammer.com/blog/wp-content/uploads/2010/09/barchart_01.png" alt="Stacked bar chart with carefully selected=" /></p>
<p style="text-align: left;">However, if for a particular dataset one of the  of category values is not present, the palette colours are still used  in the same order, meaning the “Mid” area is now shown as red and “High”  as orange. This is confusing for the end user:</p>
<p style="text-align: center;"><img class="size-full wp-image-577 aligncenter" title="Stacked bar chart" src="http://www.martinhammer.com/blog/wp-content/uploads/2010/09/barchart_02.png" alt="Stacked bar chart with only two categories, palette colours are confusing" width="530" height="160" /></p>
<p style="text-align: left;">As in the previous examples, we solve this problem by adding a little bit of script to override the chart&#8217;s default behaviour.</p>
<p style="text-align: left;"><code><br />
function beforeDrawDataPoint( dph, fill, icsc )<br />
{<br />
&nbsp;&nbsp;var sValue = dph.getSeriesDisplayValue();<br />
&nbsp;&nbsp;// set( R, G, B, alpha )<br />
&nbsp;&nbsp;if( sValue == "1-Low" )<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 242, 88, 106, 255 );<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;else if( sValue == "2-Mid" )<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 232, 172, 57, 255 );<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;else if( sValue == "3-High" )<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 128, 255, 128, 255 );<br />
&nbsp;&nbsp;}<br />
}<br />
</code></p>
<p style="text-align: left;">We also need to override the <code>beforeDrawLegendItem</code> method, so that colours in the legend match the chart colours.</p>
<p style="text-align: left;"><code><br />
function beforeDrawLegendItem( lerh, bounds, icsc )<br />
{<br />
&nbsp;&nbsp;var sValue = lerh.getLabel().getCaption().getValue();<br />
&nbsp;&nbsp;var fill = lerh.getFill();<br />
&nbsp;&nbsp;// set( R, G, B, alpha )<br />
&nbsp;&nbsp;if( sValue == "1-Low" )<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 242, 88, 106, 255 );<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;else if( sValue == "2-Mid" )<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 232, 172, 57, 255 );<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;else if( sValue == "3-High" )<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 128, 255, 128, 255 );<br />
&nbsp;&nbsp;}<br />
}<br />
</code></p>
<p style="text-align: left;">The palette colours are now assigned dynamically based on actual category values. The rendered chart looks as shown below, independent of the colours selected in Chart Wizard and their order.</p>
<p style="text-align: center;"><img class="size-full wp-image-578 aligncenter" title="Stacked bar chart" src="http://www.martinhammer.com/blog/wp-content/uploads/2010/09/barchart_03.png" alt="Stacked bar chart with two categories and dynamically assigned palette colours" width="530" height="160" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/09/setting-birt-chart-series-palette-dynamically-part-3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Selectively hiding series labels in BIRT area chart</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/09/selectively-hiding-series-labels-in-birt-area-chart/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/09/selectively-hiding-series-labels-in-birt-area-chart/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 12:43:49 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[birt]]></category>
		<category><![CDATA[charts]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=534</guid>
		<description><![CDATA[Series labels can be shown in BIRT area charts by opening the Chart Wizard and navigating to the Format Chart tab, then selecting Series &#62; Value (Y) Series &#62; Show Series Labels checkbox. The result will look as shown in the screenshot below: Often there is one particular grouping (series) which is especially important and [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Series labels can be shown in BIRT area charts by opening the Chart Wizard and navigating to the Format Chart tab, then selecting Series &gt; Value (Y) Series &gt; Show Series Labels checkbox. The result will look as shown in the screenshot below:</p>
<p style="text-align: center;"><img class="size-full wp-image-569 aligncenter" title="Area chart with series labels" src="http://www.martinhammer.com/blog/wp-content/uploads/2010/09/arealabels_01.png" alt="Area chart with series labels shown for all series (default)" width="530" height="160" /></p>
<p style="text-align: left;">Often there is one particular grouping (series) which is especially important and we want to draw the report viewer&#8217;s attention to it by showing the labels for that series only. This cannot be achieved through the Chart Wizard UI but can be done with a bit of scripting.</p>
<p style="text-align: left;">The method which needs to be overriden is beforeDrawSeries. In this example, series labels will be shown for the &#8220;1-Low&#8221; series and hidden for the other ones.</p>
<p style="text-align: left;"><code><br />
function beforeDrawSeries( series, isr, icsc )<br />
{<br />
&nbsp;&nbsp;// get class of the renderer<br />
&nbsp;&nbsp;var type = isr.getClass().toString();<br />
&nbsp;&nbsp;// check for area chart renderer<br />
&nbsp;&nbsp;if( type == "class org.eclipse.birt.chart.render.Area" )<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;var val = isr.getSeriesRenderingHints().getDataPoints()[0].getSeriesDisplayValue();<br />
&nbsp;&nbsp;&nbsp;&nbsp;if( val == "1-Low" )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;series.getLabel().setVisible( true );<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;series.getLabel().setVisible( false );<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
}<br />
</code></p>
<p style="text-align: left;">The result looks as follows:</p>
<p style="text-align: center;"><img class="size-full wp-image-570 aligncenter" title="Area chart with series labels" src="http://www.martinhammer.com/blog/wp-content/uploads/2010/09/arealabels_02.png" alt="Area chart with series labels shown for one series only" width="530" height="160" /></p>
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/09/selectively-hiding-series-labels-in-birt-area-chart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keeping track of scripts in BIRT reports</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/08/keeping-track-of-scripts-in-birt-reports/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/08/keeping-track-of-scripts-in-birt-reports/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 14:21:38 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[birt]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=523</guid>
		<description><![CDATA[The ability to add custom scripts to report elements is a very powerful feature of BIRT. It allows the report developer to modify or override the default behaviour of the element; this blog features many examples of when this might be useful. However, as the number of scripts in a report increases, the report becomes [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><img class="alignright size-full wp-image-525" title="Outline fast view with Sripts item expanded" src="http://www.martinhammer.com/blog/wp-content/uploads/2010/08/BIRT_Eclipse_Scripts.png" alt="Outline fast view with Sripts item expanded" width="371" height="480" />The ability to add custom scripts to report elements is a very powerful feature of BIRT. It allows the report developer to modify or override the default behaviour of the element; this blog features <a href="http://www.martinhammer.com/blog/index.php/tag/birt/">many examples</a> of when this might be useful. However, as the number of scripts in a report increases, the report becomes harder and harder to maintain.</p>
<p>The Layout view or the Property Editor window do not indicate whether and what scripts exist on a particular element, and so it would seem the only way to check is to select the element and switch to the Script tab and look through the methods. Of course this would be incredibly tedious and impractical in a complex report.</p>
<p>Luckily, the Outline fast view has a Scripts item tucked away at the bottom of the list. When expanded, this shows all items in the report which contain custom scripts (expanding the item shows the overridden methods). Right-click brings up an option to go to the report element in the report Layout, and thus actually figure out which item it is referring to.</p>
<p>The deeper lesson is that one should use scripts only when necessary and if there is no other way to implement the required functionality. And of course thorough documentation also helps with maintenance&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/08/keeping-track-of-scripts-in-birt-reports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

