Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Dynamic colors for bar charts?
Dynamic colors for bar charts? [message #88589] Tue, 08 November 2005 00:59 Go to next message
Eclipse UserFriend
Originally posted by: jaredburns.no.spam.acm.org

Are there plans to add support for dynamic colors in bar charts for the
2.0 release?

For example, I might want bars to appear red for a value in the range
0-33, yellow for 34-66, or green if the value is 67-100.

I wasn't able to find a bug report for this request, but I could just be
missing it.
Re: Dynamic colors for bar charts? [message #88647 is a reply to message #88589] Tue, 08 November 2005 07:25 Go to previous messageGo to next message
mr. burns is currently offline mr. burnsFriend
Messages: 402
Registered: July 2009
Senior Member
About version 2.0 I cannot say, but you can use scripting, to achieve want
you want.

Go to the report builder into the scripts area and enter following function:

function beforeDrawElement(dataPointHints, fill)
{
val = dataPointHints.getOrthogonalValue(); // get orthogonal value of each
bar

if ((val >= 0) && (val <= 33))
fill.set(255, 0, 0); // red
else if ((val >= 34) && (val <= 66))
fill.set(255, 255, 0); // yellow
else if ((val >= 67) && (val <= 100))
fill.set(0, 255, 0); // green
}

The bar color will change for each bar depending on the orthogonal value.

hth,

Mr. Burns
Re: Dynamic colors for bar charts? [message #90337 is a reply to message #88647] Fri, 11 November 2005 22:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jaredburns.no.spam.acm.org

Thanks for the tip. That sounds good, but it's not working for me. Just
to make sure I'm putting this script code in the right place...

I'm double-clicking my chart on the Layout tab of the report editor.
This brings up a dialog with a "Scripts" page. Is this the area I should
place this script? If so, do I need to adjust the normal color setting
for the bars somehow so the script will take precedence?

Thanks,
- Jared

Mr. Burns wrote:
> About version 2.0 I cannot say, but you can use scripting, to achieve want
> you want.
>
> Go to the report builder into the scripts area and enter following function:
>
> function beforeDrawElement(dataPointHints, fill)
> {
> val = dataPointHints.getOrthogonalValue(); // get orthogonal value of each
> bar
>
> if ((val >= 0) && (val <= 33))
> fill.set(255, 0, 0); // red
> else if ((val >= 34) && (val <= 66))
> fill.set(255, 255, 0); // yellow
> else if ((val >= 67) && (val <= 100))
> fill.set(0, 255, 0); // green
> }
>
> The bar color will change for each bar depending on the orthogonal value.
>
> hth,
>
> Mr. Burns
>
>
Re: Dynamic colors for bar charts? [message #90454 is a reply to message #90337] Mon, 14 November 2005 08:16 Go to previous message
mr. burns is currently offline mr. burnsFriend
Messages: 402
Registered: July 2009
Senior Member
Hello,

yes, what you wrote is the place where you should add the script.
And yes, you must set the color of the label first, otherwise the script has
no effect.
The color you can change under chart builder Attributes-->Y-Series-->Labels
then click the [...] button on the right side of the font text box.

If you not set the color first, a XML attribute is missing in the
*.rptdesign (XML) file and the script has no effect!
For details see also my post:

Subject: After update to 2.0 still problems with color
Date: Wednesday, 9. November 2005 11:03

Hope that helps!
Previous Topic:ReferenceError trying to access row in OnRow of a Table
Next Topic:How to access a table by scrpting?
Goto Forum:
  


Current Time: Fri Aug 16 15:27:54 GMT 2024

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

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

Back to the top