An Oracle blog about BI Publisher

  • RTF
    January 31, 2008

Chartin' Colors 'n' Styles

As a follow up to yesterday's mis behavin bar charts Mayur had a follow up question. The resulting chart would have looked like this:


There was a followup request to have each bar take on a different color like this:


The simplest method is to add the following attribute to the Graph element e.g.

<Graph colorMode="COLOR_BY_GROUP">

This will change the colors for each bar - there is no further control over these colors without a little effort. But there is a way to define a set of colors to be used - this could be useful if you have a set of corporate colors that you want to use on all your charts. The BIBeans engine supports what they call 'styles' this is an XML definition of the look and feel for the charts from colors to fonts. The engine ships with a series of styles that you can apply to your charts - the latest Template Builder chart dialog allows you to pick one of these.


There are 13 predefined styles but you can create your own. Its a pretty simple XML file - I found it easier to take one of the delivered files and modified it - to get at the files you need to dig into the jar files that make up the chart engine. Its  going to depend on what flavor you're running to know where the jar is - check the classpath in most cases - if you get stuck drop me a comment.

Inside the bipres.jar file you'll find a set of XML files - just open the jar file with WinZip or similar and you'll find them. You can then extract one of them and get busy ...

There is a mass of things you can change in there - I was interested in the colors, just find the following section:

<SeriesItems defaultBorderColor="#0" defaultBorderTransparent="false" borderUsingDefaults="false" 
defaultColor="" defaultMarkerShape="MS_AUTOMATIC" defaultLineWidth="3" defaultFitlineType="FT_NONE">
<Series id="0" color="#a20346"/>
<Series id="1" color="#88575"/>
<Series id="2" color="#1008a"/>
<Series id="3" color="#cc9900"/>
<Series id="4" color="#d0146b"/>
<Series id="5" color="#694eaf"/>
<Series id="6" color="#dc5c15"/>
<Series id="7" color="#758b27"/>
<Series id="8" color="#a20346"/>
<Series id="9" color="#88575"/>
<Series id="10" color="#1008a"/>
<Series id="11" color="#cc9900"/>

Those hex values map to the color palette thats available to the charting engine. This is where things get a little tedious you are going to have to get a HEX color map, maybe here and then the really hard part getting everyone to agree on the color scheme to use. This is the toughest thing in the world - been there done that, had the arguments but did not get the T shirt - we couldnt agree on the color.

Once you have the file updated you need to merge it back into the jar file - WinZip can help here again - just remember when you extract the XML to be modified you get it out using the full path info and save it with a different name - then when you merge it back in use the 'full path info' flag to get it back into the jar under oracledssgraphstyles.

Now to test it, in your XML chart definition you just need to add a new attribute to the Graph element:


So now you'll have something like:

<Graph stylePath="/oracle/dss/graph/styles/greeeen.xml" colorMode="COLOR_BY_GROUP">

You can get the template here and you'll get something like this


yes, the color differences are very subtle - but Im just that kind of guy and I like green so dont argue!

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.