Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Fix color for series in bar chart
Fix color for series in bar chart [message #1027046] Tue, 26 March 2013 13:59 Go to next message
Daniel W is currently offline Daniel WFriend
Messages: 8
Registered: March 2013
Junior Member
Hi,

I have a bar chart that shows for each month data that is split into three categories:

  • within specification
  • within specification after adj.
  • out of specification


It can happen that one of these categories is not present for several months.

Therefore it could happen that for a status the bar color could change.
But I want to have a fixed color theme e.g.

  • within specification = blue
  • within specification after adj. = yellow
  • out of specification = red

Is this somehow possible?

Next is the order of the bars. I am only able to sort them after the name. I would like to also sort them like the first list...

Anyone an idea?

  • Attachment: Snap16.jpg
    (Size: 28.10KB, Downloaded 455 times)
Re: Fix color for series in bar chart [message #1027391 is a reply to message #1027046] Tue, 26 March 2013 23:16 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You can set the color using a script similar to:
function beforeDrawDataPoint(dph, fill, icsc)
{
val = dph.getBaseDisplayValue();
if (val == "within specification"){
fill.set(255, 0, 0);
}

}

You should be able to change the order by putting in a custom expression on the sort expression for the optional grouping category.

Re: Fix color for series in bar chart [message #1027951 is a reply to message #1027046] Wed, 27 March 2013 16:32 Go to previous messageGo to next message
Daniel W is currently offline Daniel WFriend
Messages: 8
Registered: March 2013
Junior Member
hmm this is not working for flash charts. I'll try it with a normal one..
Re: Fix color for series in bar chart [message #1028071 is a reply to message #1027951] Wed, 27 March 2013 20:02 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Daniel

For flash you will need to do something like:
if( fcdph.getDataPointHints().getBaseValue() == "S12_3148" ){
fill.setRed(255);
fill.setBlue(0);
fill.setGreen(0);
}
BTW have you seen this post?
http://birtworld.blogspot.com/2010/08/birt-flash-and-gadget-scripting.html
Re: Fix color for series in bar chart [message #1033557 is a reply to message #1028071] Thu, 04 April 2013 11:12 Go to previous messageGo to next message
Daniel W is currently offline Daniel WFriend
Messages: 8
Registered: March 2013
Junior Member
thanks! I will give it a try!
Re: Fix color for series in bar chart [message #1033572 is a reply to message #1027046] Thu, 04 April 2013 11:38 Go to previous messageGo to next message
Daniel W is currently offline Daniel WFriend
Messages: 8
Registered: March 2013
Junior Member
Ok,

just tried it with a normal chart.

I had to change things a little, because I want to change the color depending on the series:

That works for me:

function beforeDrawDataPoint( dph, fill, icsc )
{
	val = dph.getBaseDisplayValue();
	test = dph.getBaseValue();
	test2 = dph.getSeriesDisplayValue();
	
	if (test2 == 'within specification'){
		fill.set(255,255,0);
	}	
	else {
		fill.set(255,0,0);
	}
}



ps: I have one more issue. The legend of the series still shows the old color. Is there a possible way to change that one also?
  • Attachment: Snap30.jpg
    (Size: 17.18KB, Downloaded 490 times)

[Updated on: Thu, 04 April 2013 11:48]

Report message to a moderator

Re: Fix color for series in bar chart [message #1033661 is a reply to message #1033572] Thu, 04 April 2013 13:43 Go to previous message
Daniel W is currently offline Daniel WFriend
Messages: 8
Registered: March 2013
Junior Member
just solved it:

function beforeDrawLegendItem( lerh, bounds, icsc )	
{		
	var label = lerh.getLabel().getCaption().getValue();
	
	if( label == "within specification")         
		lerh.getFill().set(0,158,227);
	else if (label == 'within specification after adj.')
		lerh.getFill().set(247,234,72);	
	else if (label == 'out of specification')
		lerh.getFill().set(227,41,9);		
	else if (label == 'unknown')
		lerh.getFill().set(255,0,128);			
}
Previous Topic:Choose database and populate combo box
Next Topic:Drill Through-Do BIRT API provide any support to Extract Info about child report from Parent report?
Goto Forum:
  


Current Time: Fri Apr 19 23:30:27 GMT 2024

Powered by FUDForum. Page generated in 0.03266 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top