Home » Archived » BIRT » bars highlight
bars highlight [message #161776] |
Wed, 17 May 2006 05:04  |
Eclipse User |
|
|
|
Hi again,
In my bar chart, I'd like to highlight some bars according to a field of
the represented datasets. The values row["RED_ALERT"] and row["WARNING"]
(Boolean) would set respectively a red and orange background if true.
To do so, I used the chart's property editor -> highlights tab to
configure two cases : "row["RED_ALERT"] Equal to true" and "row["WARNING"]
Equal to true" but it seems strange to that these highlights are not
configured in the Y series properties tab... Anyway this has apparently no
effect at all as the preview is not working.
Is this the good way to reach my goal ? Is it at least possible in BIRT 2
RC1 ?
Thanks,
|
|
|
Re: bars highlight [message #161835 is a reply to message #161776] |
Wed, 17 May 2006 08:47   |
Eclipse User |
|
|
|
Ok, after searching a lot, I wrote this :
previousFill = new Object();
function beforeDrawElement(dataPointHints, fill) {
previousFill.r = fill.getRed();
previousFill.g = fill.getGreen();
previousFill.b = fill.getBlue();
if (this.getRowData().getExpressionValue("row[RED_ALERT]") == "true") {
fill.set(255, 0, 0);
} else if (this.getRowData().getExpressionValue("row[WARNING]") ==
"true") {
fill.set(255, 165, 0);
}
}
function afterDrawDataElement(dataPointHints, fill) {
if (dataPointHints.getOrthogonalValue() == null) {
fill.set(previousFill.r, previousFill.g, previousFill.b);
}
}
The integration logic seems good, since without the tests my bars color is
changed. But nothing happens when the tests are on.
Since the objects in row["RED_ALERT"] and row["WARNING"] are Boolean, I
tried with .valueOf, nothing, etc. I even tried without getRowData (simply
rowData).
I tsounds like I NEVER get the row values within these methods : what is
the good way, please ??
Thanks, Thomas.
|
|
|
Re: bars highlight [message #161878 is a reply to message #161835] |
Wed, 17 May 2006 09:59   |
Eclipse User |
|
|
|
Hi Thomas,
You can't access row[""] directly from a script. there is actually an
enhancement filed for that already:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=137793
I understand that red_alert and warning are columns that are not shown in
your chart, so it's going to be tricky. What I would do is: create two
series for those red_alert and warning. Make those series invisible. Then in
the beforeDrawElement, get the index of the datapointhint, then access the
chart from the context, get the series for red_alert and warning. Check the
values using the index by looking in their dataset.
Theoritically it should work.
Thanks,
David
"Thomas Escolan" <thomas_escolan@yahoo.fr> wrote in message
news:216e493f49a2f4e892d03d447899d0bd$1@www.eclipse.org...
> Ok, after searching a lot, I wrote this :
>
> previousFill = new Object();
>
> function beforeDrawElement(dataPointHints, fill) {
> previousFill.r = fill.getRed();
> previousFill.g = fill.getGreen();
> previousFill.b = fill.getBlue();
>
> if (this.getRowData().getExpressionValue("row[RED_ALERT]") == "true") {
> fill.set(255, 0, 0);
> } else if (this.getRowData().getExpressionValue("row[WARNING]") == "true")
> {
> fill.set(255, 165, 0);
> }
> }
> function afterDrawDataElement(dataPointHints, fill) {
> if (dataPointHints.getOrthogonalValue() == null) {
> fill.set(previousFill.r, previousFill.g, previousFill.b);
> }
> }
>
> The integration logic seems good, since without the tests my bars color is
> changed. But nothing happens when the tests are on.
> Since the objects in row["RED_ALERT"] and row["WARNING"] are Boolean, I
> tried with .valueOf, nothing, etc. I even tried without getRowData (simply
> rowData).
>
> I tsounds like I NEVER get the row values within these methods : what is
> the good way, please ??
>
> Thanks, Thomas.
>
>
|
|
| | | | | | |
Re: bars highlight [message #162006 is a reply to message #161961] |
Wed, 17 May 2006 13:45  |
Eclipse User |
|
|
|
Originally posted by: thomas_esoclan.yahoo.fr
OK, thank you David !
As the index property was not signaled in the API doc online, it took me a
while to figure out what you meant. BUT, that is a working solution, after
indeed converting my Booleans to Integers :
previousFill = new Object();
function beforeDrawDataPoint(dataPointHints, fill, context) {
previousFill.r = fill.getRed();
previousFill.g = fill.getGreen();
previousFill.b = fill.getBlue();
var warning = false;
var alert = false;
var pos = dataPointHints.getIndex();
var series = context.getChartInstance().getSeries(0); // correct ?
for (var i = 0; i < series.length; i++) {
var id = series[i].getSeriesIdentifier();
var values = series[i].getDataSet().getValues();
if (id.equals("Red Alerte") && values[pos] == 1) alert = true;
if (id.equals("Warning") && values[pos] == 1) warning = true;
}
if (alert) fill.set(255, 0, 0);
else if (warning) fill.set(255, 165, 0);
}
function afterDrawDataPoint(dataPointHints, fill, context) {
fill.set(previousFill.r, previousFill.g, previousFill.b);
}
To anyone interested.
|
|
|
Goto Forum:
Current Time: Thu Jun 05 18:54:55 EDT 2025
Powered by FUDForum. Page generated in 0.09848 seconds
|