Smart bar chart coloring [message #123245] |
Thu, 02 February 2006 13:46  |
Eclipse User |
|
|
|
I need to specify that bar(s) on a chart will change color whenever they
cross a marker value. How is this done (2.0)?
|
|
|
Re: Smart bar chart coloring [message #123455 is a reply to message #123245] |
Thu, 02 February 2006 16:07   |
Eclipse User |
|
|
|
Here is an example of script to change the color of a bar depending on its
value (in your case the value is the value of the marker). Select your
chart, go to the Script tab in the designer, then input this script. Change
the value 10 to the marker value, and the color to the one you want. If the
value of the marker can change, then you can access it through the chart
model, which is available from scriptContext (look at IChartScriptContext
Javadoc). Chart chart = scriptContext.getChartInstance();
function beforeDrawDataPointLabel(dataPoints, label, scriptContext)
{
val = dataPoints.getOrthogonalValue( );
clr = label.getCaption( ).getColor( );
if ( val < -10 ) clr.set( 32, 168, 255 );
else if ( ( val >= -10 ) & ( val <=10 ) ) clr.set( 168, 0, 208 );
else if ( val > 10 ) clr.set( 0, 208, 32 );
}
Thanks,
David
"Mark Lorenz" <lorenzm@labcorp.com> wrote in message
news:eed946222d15a1d310675f8418ea2fb7$1@www.eclipse.org...
>I need to specify that bar(s) on a chart will change color whenever they
>cross a marker value. How is this done (2.0)?
>
>
|
|
|
|
|
|
|
Re: Smart bar chart coloring [message #124832 is a reply to message #124820] |
Mon, 06 February 2006 10:39  |
Eclipse User |
|
|
|
It works! Thanks. For those that might benefit from this, here's how I
conditionally colored my bar chart based on a marker value:
function beforeDrawDataPoint( dataPointHints, fill, scriptContext ){
val = dataPointHints.getOrthogonalValue();
chart = scriptContext.getChartInstance();
marker =
chart.getAxes().get(0).getAssociatedAxes().get(0).getMarkerL ines().get(0).getValue().getValue();
if (val > marker) //crosses marker?
fill.set(255, 0, 0); //yes - display in red
else
fill.set(0, 0, 255); //no - display in blue
}
|
|
|
Powered by
FUDForum. Page generated in 0.07107 seconds