Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » PieChart: All zero/null values
PieChart: All zero/null values [message #717364] Sat, 20 August 2011 06:51 Go to next message
Madhav Suram is currently offline Madhav SuramFriend
Messages: 10
Registered: August 2011
Junior Member
Hi,

We require the following conditions to be met on a pie chart:
(i) Category legend entries should be shown even if the value retrieved from DB is NULL or a zero.
(ii) All zero values should be suppressed from being shown in the chart.
(iii)When all values are zero, then "No data available" message should be shown.

The table being referenced for the pie-chart looks like
ID|| VALUE
====||==========
CATA|| 0.000000
CATB|| 123.456789
CATC|| 10.123456

The following has been tried:
a) We "suppress" the "zero" values from being displayed but putting a condition for the values. Eg: if (row["VALUE"]==0) null else row["VALUE"] .
Using this the legend entries are visible for the category and the value label is suppressed.
b) Set "Chart Visibility" to show "No data available" message. But this gets displayed only when do data is retrieved from the DB.
c) If we use a "data filter" to show only non-zero/null values, then the is "No data available" message appears, but the legend entries do not show.

So is there a way to show the legend entries(even if values are zeroes) and still show "no data available" message when all the values are zeroes/null? Customer wants to know at all times what all categories(legend) are displayed in the chart even when there are no values and when there are no values then a message should be shown.

We are using BIRT 2.6.2.

Thanks & regards,
Madhav

[Updated on: Sat, 20 August 2011 15:02]

Report message to a moderator

Re: PieChart: All zero/null values [message #717898 is a reply to message #717364] Mon, 22 August 2011 16:23 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You could do this by adding a check in the chart script for all null
values. If they are all null you can hide the plot and use the chart
type to say all values are null. You can also resize the title block to
center the message. Take a look at the attached example.

Here is the script I used:

var allnull = true;
function afterDataSetFilled( series, dataSet, icsc )
{
if( series.getSeriesIdentifier() == "Series 1" ){
var list = dataSet.getValues();
for(ii=0;ii<list.length;ii++){
if( list[ii] != null ){
allnull = false;
}
}
}
}


function beforeRendering( gcs, icsc )
{
var chart = gcs.getChartModel();
if( allnull ){
chart.getPlot().setVisible(false);
var svheight = chart.getPlot().getBounds().getHeight();
var svwidth = chart.getPlot().getBounds().getWidth();
chart.getPlot().getBounds().setHeight(0);
chart.getPlot().getBounds().setWidth(0);
chart.getTitle().getBounds().setHeight(svheight);
//chart.getTitle().getBounds().setWidth(svwidth);

chart.getTitle().getLabel().getCaption().setValue("All Values Are Null");

}
}

Jason

On 8/20/2011 2:51 AM, Madhav wrote:
> CATA|| 0.000000
> CATB|| 123.456789
> CATC|| 10.123456
Re: PieChart: All zero/null values [message #718143 is a reply to message #717898] Tue, 23 August 2011 11:56 Go to previous messageGo to next message
Madhav Suram is currently offline Madhav SuramFriend
Messages: 10
Registered: August 2011
Junior Member
Thanks a lot Jason!!

Works perfect for our requirements. Just had to make a line change to make the message "internationalized". No other changes to your script.

Thank you!!!
Regards,
Madhav
Re: PieChart: All zero/null values [message #720393 is a reply to message #717898] Tue, 30 August 2011 13:52 Go to previous messageGo to next message
Madhav Suram is currently offline Madhav SuramFriend
Messages: 10
Registered: August 2011
Junior Member
Hello Jason,

For the same issue, instead of setting the Chart Title, is it possible to have the "Chart Visibility" label set instead? I tried the following but wasn't seeing the label.

chart.getEmptyMessage().getCaption().setValue("No data available");
chart.getEmptyMessage().setVisible(true);

The above I have tried in beforeRendering, beforeGeneration and afterGeneration methods.

Thanks & regards,
Madhav
Re: PieChart: All zero/null values [message #720445 is a reply to message #720393] Tue, 30 August 2011 15:29 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Look at 2nd pie chart in revised example.

Jason

On 8/30/2011 9:52 AM, Madhav wrote:
> Hello Jason,
>
> For the same issue, instead of setting the Chart Title, is it possible
> to have the "Chart Visibility" label set instead? I tried the following
> but wasn't seeing the label.
>
> chart.getEmptyMessage().getCaption().setValue("No data available");
> chart.getEmptyMessage().setVisible(true);
>
> The above I have tried in beforeRendering, beforeGeneration and
> afterGeneration methods.
>
> Thanks & regards,
> Madhav
Re: PieChart: All zero/null values [message #720641 is a reply to message #720445] Wed, 31 August 2011 01:33 Go to previous messageGo to next message
Madhav Suram is currently offline Madhav SuramFriend
Messages: 10
Registered: August 2011
Junior Member
Hello Jason,

Thank you for the update. But I'm still confused as to how it is working. I have tried to add a new Pie Chart in the file you sent and setup the script as has been mentioned and it isn't working. Please find attached the updated file with a new Pie Chart added with the exact things we are doing. The Empty Message doesn't appear. What am I missing or doing wrong?

Thanks & regards,
Madhav
Re: PieChart: All zero/null values [message #720931 is a reply to message #720641] Wed, 31 August 2011 13:52 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

If you tie your chart in that example to dataset1 it should work. The
reason is that data set 1 returns no rows where data set returns three
rows. If you do not want the data set to return any rows just filter
out zero values on the data set.

Jason

On 8/30/2011 9:33 PM, Madhav wrote:
> Hello Jason,
>
> Thank you for the update. But I'm still confused as to how it is working. I have tried to add a new Pie Chart in the file you sent and setup the script as has been mentioned and it isn't working. Please find attached the updated file with a new Pie Chart added with the exact things we are doing. The Empty Message doesn't appear. What am I missing or doing wrong?
>
> Thanks& regards,
> Madhav
Re: PieChart: All zero/null values [message #720940 is a reply to message #720931] Wed, 31 August 2011 14:08 Go to previous messageGo to next message
Madhav Suram is currently offline Madhav SuramFriend
Messages: 10
Registered: August 2011
Junior Member
Hi Jason,
If I filter out the zeroes/null values, then the corresponding legend entry also wouldn't show up right? Customer wants to know what are the different categories that get displayed on the chart but at the same time not see zero values displayed on the chart labels. And when all are zero or null values, a mention should be made to indicate all are zeroes/null while continuing to show the label entries.

So the first example sent works very well for our case, except that now the title text is replaced. So wanted if there was any other thing that could be done to display a text apart from changing the title of the chart.

For now, we are putting the title out of the chart as a separate text so overcome the problem as in the attached image. But wanted to know if there was a way to do the other thing.

Thanks & regards,
Madhav
Re: PieChart: All zero/null values [message #721104 is a reply to message #720940] Wed, 31 August 2011 21:35 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You could use the series label instead. Take a look at the third chart
in the revised example.

Jason

On 8/31/2011 10:08 AM, Madhav wrote:
> Hi Jason,
> If I filter out the zeroes/null values, then the corresponding legend entry also wouldn't show up right? Customer wants to know what are the different categories that get displayed on the chart but at the same time not see zero values displayed on the chart labels. And when all are zero or null values, a mention should be made to indicate all are zeroes/null while continuing to show the label entries.
>
> So the first example sent works very well for our case, except that now the title text is replaced. So wanted if there was any other thing that could be done to display a text apart from changing the title of the chart.
>
> For now, we are putting the title out of the chart as a separate text so overcome the problem as in the attached image. But wanted to know if there was a way to do the other thing.
>
> Thanks& regards,
> Madhav
Re: PieChart: All zero/null values [message #722247 is a reply to message #721104] Mon, 05 September 2011 07:00 Go to previous message
Madhav Suram is currently offline Madhav SuramFriend
Messages: 10
Registered: August 2011
Junior Member
Thank you Jason! This would work just right!!

Regards,
Madhav
Previous Topic:how to delete temprory file when report is finished created (Is It Possible to do this?)
Next Topic:event handle class problem
Goto Forum:
  


Current Time: Thu Mar 28 10:08:45 GMT 2024

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

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

Back to the top