Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Parse dataset results in chart script.
moh
Hi all,
I wonder how can I parse dataset result within chart script,
so I can compute a new values and assign it to chart series.
In my test case I have a datasource with is an ssv file containing data like
12;16;56;45;...
So I added a chart with 3 Y series ( values are 1, 2 and 3 )
I will assign values to this series by script.
In the chart's script tab
I added the following code ( which doesn't work at the moment ),
first I just try to assign sample values :
function beforeGeneration( chart, icsc )
{
importPackage(Packages.java.util);
importPackage(Packages.org.eclipse.birt.chart.util);
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.type.impl);
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
var xAxis = chart.getAxes().get(0);
var yAxis = xAxis.getAssociatedAxes().get(0);
var ySerieMinPool = yAxis.getSeriesDefinitions().get(0);
var ySerieMaxUsed = yAxis.getSeriesDefinitions().get(1);
var ySerieMaxPool = yAxis.getSeriesDefinitions().get(2);
//Create ArrayLists for custom data from passed arrays
var yDataMinPool = new ArrayList();
var yDataMaxUsed = new ArrayList();
var yDataMaxPool = new ArrayList();
//Copy series vales. They suppose to have the same length
var yMinPool=0;
var yMaxPool=0;
var yMaxUsed=0;
yDataMinPool.add(10);
yDataMaxUsed.add(20);
yDataMaxPool.add(50);
//Create data sets for series
var minPoolValues = NumberDataSetImpl.create( yDataMinPool );
var maxUsedValues = NumberDataSetImpl.create( yDataMaxUsed );
var maxPoolValues = NumberDataSetImpl.create( yDataMaxPool );
//Get existing category series
var se01 = ySerieMinPool.getRunTimeSeries().get(0);
se01.setDataSet( minPoolValues );
var se02 = ySerieMaxUsed.getRunTimeSeries().get(0);
se02.setDataSet( maxUsedValues );
var se03 = ySerieMaxPool.getRunTimeSeries().get(0);
se03.setDataSet( maxPoolValues );
//Clear existing series
ySerieMinPool.getSeries().clear();
ySerieMaxUsed.getSeries().clear();
ySerieMaxPool.getSeries().clear();
//Bind new series to chart
ySerieMinPool.getSeries().add(se01);
ySerieMaxUsed.getSeries().add(se02);
ySerieMaxPool.getSeries().add(se03);
}
thank's for any help.
Find more posts tagged with
Comments
There are no comments yet