Help for BIRT charts / data sets [message #147082] |
Wed, 22 March 2006 11:43  |
Eclipse User |
|
|
|
Originally posted by: jaymzs.hotmail.com
I need to generate a line graph ( or scatter ) that uses values for x
and y from a dataset. Using the scatter graph I seem to have gotten half
the way, however, Birt automatically connects one datapoint to another, I
need a way to insert datapoints with 0 in it between the dataset data
points so that for time intervals with no value ( its a time vs bytes
transfered graph ) the line will go down to 0.
Previously I did this by making a perl script that inserted 0 value rows
for those time intervals into the table before taking it to excel. The
database only contains entries for time intervals where there is activity
and can't be changed. I essentially need to fill the gaps with 0 for
(bytes transfered) value for the 1-second intervals between entries. Where
would be the best place in Birt to do this ? I can't see a way it can be
done through any query or computed column... Ideally I'd like to do it in
the Chart scripting methods from an existing dataset ,or is there somehow
a property I can set for the chart that makes it return to 0 if there are
no datapoints between two existing data points on a scatter graph.
I've tried doing it through the onfetch method for a dataset, but I'm
not sure how I'd insert rows that weren't already there , I can only
figure out how to modify the ones already there which doesn't really help.
Long winded I know, any help I can get would appreciated.
|
|
|
Re: Help for BIRT charts / data sets [message #147261 is a reply to message #147082] |
Thu, 23 March 2006 02:16   |
Eclipse User |
|
|
|
Hi,
There is no easy way to add points to a dataset, although you might try to
modify the dataset in the afterDataSetFilled(series, dataset, context)
method. The DataSet object has two method: Object getValues(), void
setValues(Object). So you'll have to manually recreate an array with the
missing values and set it through setValues(). I advise using Java scripting
(vs JavaScript scripting) to make debugging easier (extend
ChartEventHandlerAdapter and register your class name in the Property Editor
View under Properties/Event Handler, then you have a BIRT report entry under
the debug menu).
Thanks,
David
"Js" <jaymzs@hotmail.com> wrote in message
news:6a02a8567027c0520171fde33dab32c8$1@www.eclipse.org...
>
> I need to generate a line graph ( or scatter ) that uses values for x and
> y from a dataset. Using the scatter graph I seem to have gotten half the
> way, however, Birt automatically connects one datapoint to another, I
> need a way to insert datapoints with 0 in it between the dataset data
> points so that for time intervals with no value ( its a time vs bytes
> transfered graph ) the line will go down to 0.
> Previously I did this by making a perl script that inserted 0 value rows
> for those time intervals into the table before taking it to excel. The
> database only contains entries for time intervals where there is activity
> and can't be changed. I essentially need to fill the gaps with 0 for
> (bytes transfered) value for the 1-second intervals between entries. Where
> would be the best place in Birt to do this ? I can't see a way it can be
> done through any query or computed column... Ideally I'd like to do it in
> the Chart scripting methods from an existing dataset ,or is there somehow
> a property I can set for the chart that makes it return to 0 if there are
> no datapoints between two existing data points on a scatter graph.
> I've tried doing it through the onfetch method for a dataset, but I'm
> not sure how I'd insert rows that weren't already there , I can only
> figure out how to modify the ones already there which doesn't really help.
>
> Long winded I know, any help I can get would appreciated.
>
|
|
|
|
|
|
|
Re: Help for BIRT charts / data sets [message #545957 is a reply to message #147082] |
Fri, 09 July 2010 13:21   |
Eclipse User |
|
|
|
The problem is on the tooltip. I use JDBC datasource. You may create a table having two columns:
StartTime: DateTime
Value: int
Let's say it is supposed to have one record every minute, but sometimes no data.
In the report, create a dataset query from this table, then a line chart using this dataset. Now it works by using the following code. However, if I add Mouse Over event with action of Show Tooltip with text row["Value"], it throws an Out of bounds exception. I think the tooltip is reading data from the original dataset, which has less rows than the modified series' dataset.
var insertingPoint=new Array();
/**
* Called after populating the series dataset.
*
* @param series
* Series
* @param dataSet
* DataSet
* @param icsc
* IChartScriptContext
*/
function afterDataSetFilled( series, dataSet, icsc )
{
importPackage(Packages.org.eclipse.birt.chart.util);
importPackage(Packages.com.ibm.icu.util);
//importPackage(Packages.java.util);
var getTickTime = 1;
var list = dataSet.getValues();
var newList=new Packages.java.util.ArrayList();
var logger=icsc.getLogger();
logger.log(1,list.getClass()+" len="+list.length);
if ( series.getClass().getSimpleName() == "SeriesImpl" ) {
// time series
var tickTime=1;
var preTime,curTime;
if(list.length>0){
preTime=list[0];
newList.add(list[0]);
}
for (i=1; i<list.length; i++){
curTime=list[i];
if( CDateTime.computeDifference(curTime,preTime,Calendar.MINUTE)>tickTime ){
insertingPoint.push(i);
newList.add(preTime.forward(Calendar.MINUTE,tickTime));
logger.log(1,"insert "+newList.get(newList.size()-1)+" at "+i);
}
newList.add(list[i]);
preTime=curTime;
}
logger.log(1,"time series("+newList.size()+"): "+newList);
dataSet.setValues(newList);
} else if(insertingPoint.length>0){
var idx=0;
var point;
for (i=0; i<list.length; i++){
if(idx<insertingPoint.length){
point=insertingPoint[idx];
if(i==point){
newList.add(null);
logger.log(1,"insert null at "+point);
idx++;
}
}
newList.add(list[i]);
}
logger.log(1,"value series("+newList.size()+"): "+newList);
dataSet.setValues(newList);
}
}
|
|
|
|
|
|
|
Re: Help for BIRT charts / data sets [message #545986 is a reply to message #545982] |
Fri, 09 July 2010 15:27  |
Eclipse User |
|
|
|
I just replied to your latest email, but it appears that it might not
have sent properly. You are specifying a tool tip that is not based on
the chart data but on the binding data for the chart. When you add to
the chart there is no correlation to the row in the binding.
The only other way around this would to be add the data items to the
data set (Either in the db or using a scripted dataset and joint dataset
with your current dataset).
Jason
On 7/9/2010 3:14 PM, Richard Gong wrote:
> You didn't set anything in the tooltip text. I added it and sent back to
> your mailbox. Now you can see the error.
|
|
|
Powered by
FUDForum. Page generated in 0.03797 seconds