Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » modify chart color by dataset value
modify chart color by dataset value [message #177166] Thu, 13 July 2006 07:48 Go to next message
Eclipse UserFriend
Originally posted by: thomas.buffagni.otconsulting.com

Hi All!
I'm trying to modify at runtime the bar's color of chart conditionally.

I've tryed this code:

function beforeDrawDataPoint( dataPointHints, fill, context ){
val = dataPointHints.getOrthogonalValue();
chart = context.getChartInstance();
marker = 0;
if (val > marker) //crosses marker?
fill.set(0, 255, 0); //yes - display in red
else
fill.set(0, 0, 255); //no - display in blue*/
}

and it works but now i want change the color by the value of row field
that it isn't the value of the serie

I would like make somethings like this: marker = row["myMarker"], have you
some ideas?
Re: modify chart color by dataset value [message #177213 is a reply to message #177166] Thu, 13 July 2006 12:23 Go to previous messageGo to next message
David Michonneau is currently offline David MichonneauFriend
Messages: 1145
Registered: July 2009
Senior Member
This is currently not supported. You can try to create an invisible series
linked to "myMarker", then access the value of that series by getting the
chart instance from the context:

context.getChartInstance().getAxes().get(0).getAssociatedAxe s().get(0).getRuntimeSeries().get(1).getDataSet().getValues( );

This will return an array of the values for the second series on the first Y
Axis (assuming this is the invisible one), then you can look up the value
for the index you're at in the beforeDrawDataPoint function. (the
dataPointHints should have the current index).

Thanks,

David

"Thomas" <thomas.buffagni@otconsulting.com> wrote in message
news:e7e2d5e1d1cad416277649e9980de5da$1@www.eclipse.org...
> Hi All!
> I'm trying to modify at runtime the bar's color of chart conditionally.
> I've tryed this code:
> function beforeDrawDataPoint( dataPointHints, fill, context ){
> val = dataPointHints.getOrthogonalValue();
> chart = context.getChartInstance();
> marker = 0;
> if (val > marker) //crosses marker?
> fill.set(0, 255, 0); //yes - display in red
> else
> fill.set(0, 0, 255); //no - display in blue*/
> }
>
> and it works but now i want change the color by the value of row field
> that it isn't the value of the serie
>
> I would like make somethings like this: marker = row["myMarker"], have you
> some ideas?
>
Re: modify chart color by dataset value [message #177229 is a reply to message #177213] Thu, 13 July 2006 13:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: thomas.buffagni.otconsulting.com

Hi David!

I've tryed your code but doesn't work, i've this error:


Java class "[Lorg.eclipse.birt.chart.model.component.Series;" has no
public instance field or method named "get". at line 273 of chart
script:''


My Code:

function beforeDrawDataPoint( dataPointHints, fill, context ){

val = dataPointHints.getOrthogonalValue();
index = dataPointHints.getIndex();

seriesArray =
context.getChartInstance().getAxes().get(0).getAssociatedAxe s().get(0).getRuntimeSeries().get(0).getDataSet().getValues( );

marker = seriesArray[index];

if (val > marker) //crosses marker?
fill.set(255, 0, 0); //yes - display in red
else
fill.set(0, 0, 255); //no - display in blue
}
Re: modify chart color by dataset value [message #177259 is a reply to message #177229] Thu, 13 July 2006 13:32 Go to previous message
Eclipse UserFriend
Originally posted by: thomas.buffagni.otconsulting.com

This is the right code, now it works

function beforeDrawDataPoint( dataPointHints, fill, context ){

val = dataPointHints.getOrthogonalValue();
index = dataPointHints.getIndex();

seriesArray =
context.getChartInstance().getAxes().get(0).getAssociatedAxe s().get(0).getRuntimeSeries();
markerValue = seriesArray[0].getDataSet().getValues()[index];

if (markerValue < val) //crosses marker?
fill.set(255, 0, 0); //yes - display in red
else
fill.set(0, 0, 255); //no - display in blue
}
Previous Topic:BIRT 2.0 Performance issues
Next Topic:Matrix Report
Goto Forum:
  


Current Time: Thu Apr 25 05:19:16 GMT 2024

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

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

Back to the top