Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 218034

Summary: [Chart usability] Ability to warn when a chart is empty
Product: z_Archived Reporter: erlich <jerlich>
Component: BIRTAssignee: Yulin Wang <Lionel.wyl>
Status: VERIFIED DUPLICATE QA Contact: Tianli Zhang <tzhang>
Severity: enhancement    
Priority: P3 Keywords: plan
Version: 2.2.0   
Target Milestone: 2.5.0   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description erlich CLA 2008-02-06 12:57:30 EST
When a report has a chart, but that chart has no data it's not shown..
There should be a way to tell why it's not being shown, like a configurable text under the chart title
Comment 1 erlich CLA 2008-09-05 12:37:57 EDT
Is there any update to this??
Comment 2 erlich CLA 2008-12-29 14:05:11 EST
Any update or workaround?
Comment 3 Yulin Wang CLA 2008-12-29 23:34:41 EST
Usually, if chart has no data, it won't display in report.
Do you have any use case that chart should display error message?
Comment 4 erlich CLA 2008-12-30 08:45:49 EST
I have a chart with a title outside..
The problem is that, if the chart is empty, it's not shown but the title is.
I needed to use an external title because the chart title doesn't support dynamic titles.
Also it's good to show a message saying: "Chart is not shown because... "
maybe just accesing the chart in script and asking something like chart.isRendered() or something like that..
Comment 5 Yulin Wang CLA 2008-12-31 01:00:17 EST
(In reply to comment #4)
> I have a chart with a title outside..
> The problem is that, if the chart is empty, it's not shown but the title is.
> I needed to use an external title because the chart title doesn't support
> dynamic titles.
> Also it's good to show a message saying: "Chart is not shown because... "
> maybe just accesing the chart in script and asking something like
> chart.isRendered() or something like that..
> 
What do you mean by "the chart title doesn't support dynamic titles"?
Chart title supports i18n by properties, or scripting to change model value in runtime.
Comment 6 erlich CLA 2009-01-05 08:34:03 EST
(In reply to comment #5)
> (In reply to comment #4)
> > I have a chart with a title outside..
> > The problem is that, if the chart is empty, it's not shown but the title is.
> > I needed to use an external title because the chart title doesn't support
> > dynamic titles.
> > Also it's good to show a message saying: "Chart is not shown because... "
> > maybe just accesing the chart in script and asking something like
> > chart.isRendered() or something like that..
> > 
> What do you mean by "the chart title doesn't support dynamic titles"?
> Chart title supports i18n by properties, or scripting to change model value in
> runtime.
> 

But the chart my have some parameter and the title may change according to it..
I didn't find a way to script for the title..
For instance:
A chart that shows sales per regions for a product defined by a parameter i could show: "Sales for param["product"]" but on the chart it doesn't let me script.. So I've to use a dynamic text above the chart

But the issue is not that.. 
What i need is to have a way to explain that the chart is not shown for some reason.. 
The parameters entered are not enough
Comment 7 Yulin Wang CLA 2009-01-06 01:14:53 EST
(In reply to comment #6)
> 
> But the chart my have some parameter and the title may change according to it..
> I didn't find a way to script for the title..
> For instance:
> A chart that shows sales per regions for a product defined by a parameter i
> could show: "Sales for param["product"]" but on the chart it doesn't let me
> script.. So I've to use a dynamic text above the chart
> 
> But the issue is not that.. 
> What i need is to have a way to explain that the chart is not shown for some
> reason.. 
> The parameters entered are not enough
> 

The first question: how to set title according to parameter
Please write script like this:
function beforeGeneration( chart, icsc )
{
var title = chart.getTitle().getLabel().getCaption();
var parameter = icsc.getExternalContext().getScriptable().getParameterValue("parameterName");
title.setValue(parameter);
}

The second question: how to write text if no data.
You could set alt text to chart, so that if chart doesn't display, alt text will replace. But it seems if data set is empty, no item display. If chart doesn't bind data, alt text will work.
Comment 8 erlich CLA 2009-01-06 12:44:00 EST
This is with empty data..
the Alt text is not being shown..
But the dynamic title didnt work :(
Comment 9 erlich CLA 2009-01-09 13:26:29 EST
Any idea of a workaround?
Comment 10 Yulin Wang CLA 2009-01-12 01:18:35 EST
(In reply to comment #8)
> This is with empty data..
> the Alt text is not being shown..
> But the dynamic title didnt work :(
> 

The script I wrote is a sample, and it should work. Please try it again.
Regarding the empty data, if its behavior is the same with the chart without binding, i.e. to show alt text, is it ok?
Comment 11 Yulin Wang CLA 2009-01-18 21:47:51 EST
Will add two properties in chart model and UI.
The first property is to enable error message when data count is zero.
The second property is to customize error message.

*** This bug has been marked as a duplicate of bug 204922 ***
Comment 12 Tianli Zhang CLA 2009-01-20 01:30:28 EST
Verified.