Skip to main content



      Home
Home » Archived » BIRT » bars highlight
bars highlight [message #161776] Wed, 17 May 2006 05:04 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #161922 is a reply to message #161878] Wed, 17 May 2006 10:43 Go to previous messageGo to next message
Eclipse UserFriend
Hi again, David,

I understand how to create new series and make them invisible. But how do
you then access them within the script (contexte, etc.) ? Please, give me
an coding example !

Thomas.
Re: bars highlight [message #161930 is a reply to message #161878] Wed, 17 May 2006 11:04 Go to previous messageGo to next message
Eclipse UserFriend
Strange,

It is now said in the report preview that there is an error in the chart,
no matter if I comment out the script functions ; but I did preview it
once without any pb (to check if the X axis wasn't streched by the new
invisible series).
When the series are visible, the value given for each is the same as the
first serie's value ; not "true" and "false" as I would expect it. Is this
normal, David ?

Thomas.
Re: bars highlight [message #161961 is a reply to message #161930] Wed, 17 May 2006 11:56 Go to previous messageGo to next message
Eclipse UserFriend
OK, so I got the error description in the viewer's log file :
Caused by: org.eclipse.birt.chart.exception.ChartException: The dataset
used by the Chart is invalid

BUT I didn't touch the dataset, actually... Is it that the value series
datas has to be of a same type ? That would seem reasonnable, after all...
Re: bars highlight [message #161976 is a reply to message #161878] Wed, 17 May 2006 12:05 Go to previous messageGo to next message
Eclipse UserFriend
But, then, what is the chart's highlights tab made for ??
Re: bars highlight [message #161983 is a reply to message #161976] Wed, 17 May 2006 13:11 Go to previous messageGo to next message
Eclipse UserFriend
It's to set the style of the whole chart, not the chart series.


"Thomas Escolan" <thomas_escolan@yahoo.fr> wrote in message
news:5280c30cf9301f10be93613f73c991ba$1@www.eclipse.org...
> But, then, what is the chart's highlights tab made for ??
>
Re: bars highlight [message #161991 is a reply to message #161961] Wed, 17 May 2006 13:11 Go to previous messageGo to next message
Eclipse UserFriend
Hi Thomas,

I think you have to convert your boolean to an integer, we do not accept
boolean values in the Series I believe.

Thanks,

David

"Thomas Escolan" <thomas_escolan@yahoo.fr> wrote in message
news:bfc1e4ee12fba1855735730744306d30$1@www.eclipse.org...
> OK, so I got the error description in the viewer's log file :
> Caused by: org.eclipse.birt.chart.exception.ChartException: The dataset
> used by the Chart is invalid
>
> BUT I didn't touch the dataset, actually... Is it that the value series
> datas has to be of a same type ? That would seem reasonnable, after all...
>
Re: bars highlight [message #162006 is a reply to message #161961] Wed, 17 May 2006 13:45 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Hide a table ?
Next Topic:publishing Birt Reports
Goto Forum:
  


Current Time: Thu Jun 05 18:54:55 EDT 2025

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

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

Back to the top