<?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; charts</title>
	<atom:link href="http://www.martinhammer.com/blog/index.php/tag/charts/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>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>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>Setting BIRT chart series palette dynamically, part 2 – area charts</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/02/setting-birt-chart-series-palette-dynamically-part-2-area-charts/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/02/setting-birt-chart-series-palette-dynamically-part-2-area-charts/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 14:08:23 +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=453</guid>
		<description><![CDATA[In a previous post we described how to set the series palette dynamically for a pie chart. A slightly different approach is required for area charts. Let&#8217;s recap on the problem at hand: in what is a fairly common scenario, one chooses the palette colours to match with particular category values. For example, in the [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">In a <a href="http://www.martinhammer.com/blog/index.php/2010/01/setting-birt-chart-series-palette-dynamically/">previous post</a> we described how to set the series palette dynamically for a pie chart. A slightly different approach is required for area charts.</p>
<p style="text-align: left;">Let&#8217;s recap on the problem at hand: in what is a fairly common scenario, one chooses the palette colours to match with particular category values. For example, in the chart below &#8220;High&#8221; is represented in green, &#8220;Mid&#8221; in orange and &#8220;Low&#8221; in red.</p>
<p><img class="aligncenter size-full wp-image-455" title="Area chart with three categories" src="http://www.martinhammer.com/blog/wp-content/uploads/2010/02/dynpal05.png" alt="Area chart with three categories" width="530" height="170" /></p>
<p style="text-align: left;">However, if for a particular dataset of the of category values is not present, the palette colours are still used in the same order, meaning the &#8220;Mid&#8221; area is now shown as red and &#8220;High&#8221; as orange. This is confusing for the end user.</p>
<p><img class="aligncenter size-full wp-image-456" title="Area chart with only two categories, palette colours are confusing" src="http://www.martinhammer.com/blog/wp-content/uploads/2010/02/dynpal06.png" alt="Area chart with only two categories, palette colours are confusing" width="530" height="170" /></p>
<p style="text-align: left;">Once again we can solve this issue with some scripting of the chart. In this approach, we will override the <code>beforeDrawSeries</code> method to check for category value and set the fill colour based on that:</p>
<p><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;// get global counter<br />
&nbsp;&nbsp;&nbsp;&nbsp;// 1* forces conversion to int<br />
&nbsp;&nbsp;&nbsp;&nbsp;var i = 1 * icsc.getExternalContext().getScriptable().getPersistentGlobalVariable( "seriesCounter" );<br />
&nbsp;&nbsp;&nbsp;&nbsp;// get category value<br />
&nbsp;&nbsp;&nbsp;&nbsp;var val = isr.getSeriesRenderingHints().getDataPoints()[0].getSeriesDisplayValue();<br />
&nbsp;&nbsp;&nbsp;&nbsp;// set fill colour based on category value<br />
&nbsp;&nbsp;&nbsp;&nbsp;if( val == "1-Low" )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isr.getSeriesDefinition().getSeriesPalette().getEntries()[i].set( 242, 88, 106, 128 );<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if( val == "2-Mid" )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isr.getSeriesDefinition().getSeriesPalette().getEntries()[i].set( 232, 172, 57, 128 );<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if( val == "3-High" )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isr.getSeriesDefinition().getSeriesPalette().getEntries()[i].set( 128, 255, 128, 128 );<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;// increment global counter<br />
&nbsp;&nbsp;&nbsp;&nbsp;i = i + 1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;// "" forces conversion to string<br />
&nbsp;&nbsp;&nbsp;&nbsp;icsc.getExternalContext().getScriptable().setPersistentGlobalVariable( "seriesCounter", "" + i );<br />
&nbsp;&nbsp;}<br />
}<br />
</code></p>
<p style="text-align: left;">You may have noticed that a global variable <code>seriesCounter</code> is used to hold the reference to the current series. This is because the <code>beforeDrawSeries</code> method is called several times, once for each category value present in the data. Another bit of code is therefore required to define the <code>seriesCounter</code> variable in the <code>initialize</code> method of the report:</p>
<p><code><br />
reportContext.setPersistentGlobalVariable( "seriesCounter", "0" );<br />
</code></p>
<p style="text-align: left;">One more point to note is that <code>reportContext.setPersistentGlobalVariable</code> only accepts string values, hence the &#8220;hack&#8221; to convert between a number and a string every time the value is retrieved or stored.</p>
<p><img src="http://www.martinhammer.com/blog/wp-content/uploads/2010/02/dynpal07.png" alt="Area chart with only two categories, palette colours dynamically set" title="Area chart with only two categories, palette colours dynamically set" width="530" height="170" class="aligncenter size-full wp-image-457" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/02/setting-birt-chart-series-palette-dynamically-part-2-area-charts/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Setting BIRT chart series palette dynamically</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/01/setting-birt-chart-series-palette-dynamically/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/01/setting-birt-chart-series-palette-dynamically/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 18:05:03 +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=420</guid>
		<description><![CDATA[BIRT series palette is static by default, meaning colours are applied in the specified order without being tied to the actual category values. This is ok in most cases, however consider the following scenario. In our data we expect three category values, &#8220;1-Low&#8221;, &#8220;2-Mid&#8221; and &#8220;3-High&#8221; and the chart series palette has been set to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">BIRT series palette is static by default, meaning colours are applied in the specified order without being tied to the actual category values. This is ok in most cases, however consider the following scenario. In our data we expect three category values, &#8220;1-Low&#8221;, &#8220;2-Mid&#8221; and &#8220;3-High&#8221; and the chart series palette has been set to reflect this. Red colour is first in the list, so it will used for the first category value (&#8220;1-Low&#8221;) etc.:</p>
<p><img src="http://www.martinhammer.com/blog/wp-content/uploads/2010/01/dynpal01-150x150.png" alt="Chart series palette" title="dynpal01" width="150" height="150" class="aligncenter size-thumbnail wp-image-449" /></p>
<p style="text-align: left;">With all three category values in the dataset everything works as expected:</p>
<p><img class="aligncenter size-full wp-image-436" title="dynpal02" src="http://www.martinhammer.com/blog/wp-content/uploads/2010/01/dynpal02.png" alt="Pie chart with static palette colours and all categories" width="278" height="159" /></p>
<p style="text-align: left;">However, suppose that for a particular dataset the value &#8220;1-Low&#8221; is not present (perhaps a month when the business is performing well?). In this case the palette colours will still be applied in the same order starting with red, leading to inconsistency and quite possibly confusing the users:</p>
<p><img class="aligncenter size-full wp-image-437" title="dynpal03" src="http://www.martinhammer.com/blog/wp-content/uploads/2010/01/dynpal03.png" alt="Pie chart with colours from a static palette" width="287" height="150" /></p>
<p style="text-align: left;">This problem can be overcome by dynamically scripting the series colours based on the category value. Two methods need to be scripted, one for the chart itself and the other for the legend (otherwise the chart and the legend will not match!).</p>
<p><code><br />
function beforeDrawDataPoint( dph, fill, icsc )<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;var sValue = dph.getBaseDisplayValue();<br />
&nbsp;&nbsp;&nbsp;&nbsp;if( sValue == "1-Low" )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 242, 88, 106, 255 );<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if( sValue == "2-Mid" )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 232, 172, 57, 255 );<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if( sValue == "3-High" )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 128, 255, 128, 255 );<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
</code><br />
<code><br />
function beforeDrawLegendItem( lerh, bounds, icsc )<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;var sValue = lerh.getLabel().getCaption().getValue();<br />
&nbsp;&nbsp;&nbsp;&nbsp;var fill = lerh.getFill();<br />
&nbsp;&nbsp;&nbsp;&nbsp;if( sValue == "1-Low" )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 242, 88, 106, 255 );<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if( sValue == "2-Mid" )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 232, 172, 57, 255 );<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if( sValue == "3-High" )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fill.set( 128, 255, 128, 255 );<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
</code></p>
<p style="text-align: left;">The <code>set</code> method can take either three integer parameters with values between 0 and 255 for Red, Green, Blue or four integer parameters (RGB + Alpha channel for opacity). After including the above scripts the chart is generated with the correct colours for the category values:</p>
<p><img class="aligncenter size-full wp-image-438" title="dynpal04" src="http://www.martinhammer.com/blog/wp-content/uploads/2010/01/dynpal04.png" alt="Pie chart with colours dynamically reflecting category values" width="284" height="159" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/01/setting-birt-chart-series-palette-dynamically/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Setting BIRT chart title dynamically</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/01/setting-birt-chart-title-dynamically/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/01/setting-birt-chart-title-dynamically/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 12:55:10 +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=416</guid>
		<description><![CDATA[It is possible to set the title of a chart dynamically, for example based on parameter values, using a little bit of scripting. The example below assumes that two parameters are defined (&#8220;Year&#8221; and &#8220;Month&#8221; with values such as &#8220;2010&#8243; and &#8220;Jan&#8221;). function beforeGeneration( chart, icsc ) { &#160;&#160;&#160;&#160;var sYear = icsc.getExternalContext().getScriptable().getParameterValue( "Year" ); &#160;&#160;&#160;&#160;var [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">It is possible to set the title of a chart dynamically, for example based on parameter values, using a little bit of scripting. The example below assumes that two parameters are defined (&#8220;Year&#8221; and &#8220;Month&#8221; with values such as &#8220;2010&#8243; and &#8220;Jan&#8221;).</p>
<p style="text-align: left;"><code><br />
function beforeGeneration( chart, icsc )<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;var sYear 	= icsc.getExternalContext().getScriptable().getParameterValue( "Year" );<br />
&nbsp;&nbsp;&nbsp;&nbsp;var sMonth 	= icsc.getExternalContext().getScriptable().getParameterValue( "Month" );<br />
&nbsp;&nbsp;&nbsp;&nbsp;var sTitle	= "Chart for " + sMonth + " " + sYear;<br />
&nbsp;&nbsp;&nbsp;&nbsp;chart.getTitle().getLabel().getCaption().setValue( sTitle );<br />
}</code></p>
<p style="text-align: left;">The title of the chart will be set dynamically based on report parameter values.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/01/setting-birt-chart-title-dynamically/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fill missing values in BIRT charts</title>
		<link>http://www.martinhammer.com/blog/index.php/2009/11/fill-missing-values-in-birt-charts/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2009/11/fill-missing-values-in-birt-charts/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 18:26:24 +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=376</guid>
		<description><![CDATA[The BIRT chart wizard provides an option to skip missing values in a series and connect them with the series line; however, there is no option to substitute a default value for the missing data. The screenshot below shows a chart where the series value is missing for category value 03-MAR and the &#8220;Connect Missing [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">The BIRT chart wizard provides an option to skip missing values in a series and connect them with the series line; however, there is no option to substitute a default value for the missing data. The screenshot below shows a chart where the series value is missing for category value 03-MAR and the &#8220;Connect Missing Values&#8221; option has been selected under the value series options:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-386" title="chart_fill_before" src="http://www.martinhammer.com/blog/wp-content/uploads/2009/11/chart_fill_before.png" alt="chart_fill_before" width="466" height="173" /></p>
<p style="text-align: left;">There is no option in the chart wizard to fill in the missing values, i.e. replace them with a default. However, it is possible to achieve this with a simple script. In this case we check for the series name and replace the missing values with 0. To use the script, highlight the chart in the UI and click the Script tab along the bottom of the main window. Then simply paste the script below and save the report.</p>
<p><code><br />
function afterDataSetFilled( series, dataSet, icsc )<br />
{<br />
&nbsp;&nbsp;if( series.getSeriesIdentifier() == "Series 1" )<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;var list = dataSet.getValues();<br />
&nbsp;&nbsp;&nbsp;&nbsp;for( var i = 0; i &lt; list.length; i = i + 1 )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if( list[i] == null )<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list[i] = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
}<br />
</code></p>
<p style="text-align: left;">The screenshot below shows the chart with the script included:</p>
<p><img class="aligncenter size-full wp-image-385" title="chart_fill_after" src="http://www.martinhammer.com/blog/wp-content/uploads/2009/11/chart_fill_after.png" alt="chart_fill_after" width="466" height="173" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2009/11/fill-missing-values-in-birt-charts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Formatting chart legend value entry</title>
		<link>http://www.martinhammer.com/blog/index.php/2009/07/formatting-chart-legend-value-entry/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2009/07/formatting-chart-legend-value-entry/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 17:11:57 +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=313</guid>
		<description><![CDATA[In the legend properties for BIRT meter charts (accessed via Format Chart &#62; Chart Area &#62; Legend) there is a Show Value checkbox which controls displaying the series value together with its name. For some reason, in the Entries the dialog the Format control appears to be disabled, and so there is no way to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">In the legend properties for BIRT meter charts (accessed via Format Chart &gt; Chart Area &gt; Legend) there is a Show Value checkbox which controls displaying the series value together with its name. For some reason, in the Entries the dialog the Format control appears to be disabled, and so there is no way to control the format of the value. This is especially a problem when the computed value contains a lot of decimal places, as shown below:</p>
<p style="text-align: left;"><img class="alignnone size-full wp-image-316" title="BIRT Meter Legend 01" src="http://www.martinhammer.com/blog/wp-content/uploads/2009/07/BIRT-Meter-Legend-01.png" alt="BIRT Meter Legend 01" width="354" height="278" /></p>
<p style="text-align: left;">My solution to get around this problem is to add a little bit of script to the chart. Simply paste the following code to the charts onRender event (select the chart, click the Script tab at the bottom of the main editor window, select onRender in the first dropdown and beforeDrawLegendItem in the second one):</p>
<p><code><br />
function beforeDrawLegendItem( lerh, bounds, icsc )<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;var nVal = lerh.getValueLabel().getCaption().getValue();<br />
&nbsp;&nbsp;&nbsp;&nbsp;nVal = Math.round( nVal ) + "%";<br />
&nbsp;&nbsp;&nbsp;&nbsp;lerh.getValueLabel().getCaption().setValue( nVal );<br />
}<br />
</code></p>
<p style="text-align: left;">The result is a nicely formatted percentage value:</p>
<p style="text-align: left;"><img class="alignnone size-full wp-image-317" title="BIRT Meter Legend 02" src="http://www.martinhammer.com/blog/wp-content/uploads/2009/07/BIRT-Meter-Legend-02.png" alt="BIRT Meter Legend 02" width="356" height="278" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2009/07/formatting-chart-legend-value-entry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reducing wasted whitespace in meter charts</title>
		<link>http://www.martinhammer.com/blog/index.php/2009/07/reducing-wasted-whitespace-in-meter-charts/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2009/07/reducing-wasted-whitespace-in-meter-charts/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 15:50:09 +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=305</guid>
		<description><![CDATA[BIRT has a wonderful meter chart type which is very useful for building KPI-based performance dashboards. However, it can be a little tricky to get the visual layout of the chart right. With default settings most of the chart is empty blank space with a relatively small dial in the middle. This is because the [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">BIRT has a wonderful meter chart type which is very useful for building KPI-based performance dashboards. However, it can be a little tricky to get the visual layout of the chart right. With default settings most of the chart is empty blank space with a relatively small dial in the middle. This is because the meter (dial) appears to be taking only a small portion of the overall area and also the distances between the chart title, legend and the dial are too big. This can look disjointed in a dashboard-style report. See the screenshot below, which shows a meter chart with a legend below and otherwise default settings. The background colour is set to blue to highlight the amount of empty space wasted:</p>
<p style="text-align: left;"><img class="alignnone size-full wp-image-307" title="BIRT Meter 01 - Before" src="http://www.martinhammer.com/blog/wp-content/uploads/2009/07/BIRT-Meter-01-Before.png" alt="BIRT Meter 01 - Before" width="431" height="288" /></p>
<p style="text-align: left;">The trick to make the dial take up a larger portion of the overall chart area is to set a couple of &#8220;inset&#8221; entries to negative values. The values below worked well for me for a chart with width of 4.5 in and height 3 in.</p>
<ul>
<li>To move the legend closer to the meter, go to Format Chart &gt; Chart Area &gt; Legend &gt; Layout and set Insets (points) &gt; Top to -20. This assumes that the legend Position is set to Below.</li>
<li>To move the dial closer to the title, go to Format Chart &gt; Chart Area &gt; Plot &gt; Area Format and set Insets (points) &gt; Top to -30.</li>
</ul>
<p>The screenshot below shows the same chart with the above two changes:</p>
<p><img class="alignnone size-full wp-image-308" title="BIRT Meter 02 - After" src="http://www.martinhammer.com/blog/wp-content/uploads/2009/07/BIRT-Meter-02-After.png" alt="BIRT Meter 02 - After" width="432" height="288" /></p>
<p>The exact values may need some trial and error playing around to get the layout exactly right, but the general principle is: don&#8217;t be afraid of setting negative inset values.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2009/07/reducing-wasted-whitespace-in-meter-charts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BIRT chart scrollbars in Firefox</title>
		<link>http://www.martinhammer.com/blog/index.php/2009/07/birt-chart-scrollbars-in-firefox/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2009/07/birt-chart-scrollbars-in-firefox/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 15:27:55 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[birt]]></category>
		<category><![CDATA[charts]]></category>
		<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=295</guid>
		<description><![CDATA[There&#8217;s a strange bug in BIRT charting with Firefox on Linux. Some charts are rendered with horizontal and vertical scrollbars, sort of like an embedded frame which is too big to fit in the allocated space. The fix for this annoyance is straightforward, simply change the output format from SVG to PNG on the first [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a strange bug in BIRT charting with Firefox on Linux. Some charts are rendered with horizontal and vertical scrollbars, sort of like an embedded frame which is too big to fit in the allocated space.</p>
<p>The fix for this annoyance is straightforward, simply change the output format from SVG to PNG on the first tab of the chart dialog. This also makes scrolling smoother and improves overall responsiveness of Firefox when a report with a lot of charts is displayed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2009/07/birt-chart-scrollbars-in-firefox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

