0% found this document useful (0 votes)
212 views4 pages

First Invisible Then Visible

This document contains JavaScript functions used for customizing different parts of a chart generated in BIRT. The functions allow setting fill colors for datapoints based on their values, filtering out series from the y-axis that are not in a list of valid types, setting the scale of the y-axis based on a grade variable, and performing other customizations. The functions are called at different stages of chart generation to modify attributes before elements are rendered.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
212 views4 pages

First Invisible Then Visible

This document contains JavaScript functions used for customizing different parts of a chart generated in BIRT. The functions allow setting fill colors for datapoints based on their values, filtering out series from the y-axis that are not in a list of valid types, setting the scale of the y-axis based on a grade variable, and performing other customizations. The functions are called at different stages of chart generation to modify attributes before elements are rendered.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

importPackage(Packages.org.eclipse.birt.chart.model.data.

impl);
//importPackage(Packages.org.eclipse.birt.chart.model.data.impl.NumberDataElemen
tImpl);
org.eclipse.birt.chart.datafeed;
org.eclipse.birt.chart.model.attribute.impl;
org.eclipse.birt.chart.model.attribute;
org.eclipse.birt.chart.model;
org.eclipse.birt.chart.script.api.scale;
org.eclipse.birt.chart.model.component;
org.eclipse.birt.chart.model.component.impl.ScaleImpl
/**
* Called before drawing each datapoint graphical representation or marker.
*
* @param dph
*
DataPointHints
* @param fill
*
Fill
* @param icsc
*
IChartScriptContext
*/
function beforeDrawDataPoint( dph, fill, icsc )
{
val = dph.getOrthogonalValue();
index = dph.getIndex();
if ((val <= 120 && val >100) || (val <= 220 && val >200) || (val <= 320
&& val >300) || (val <= 420 && val >400) || (val <= 520 && val >500)){ //Limited
fill.set(255, 153, 0);
}
else if ((val <= 140 && val >120) || (val <= 240 && val >220) || (val <=
340 && val >320) || (val <= 440 && val >420) || (val <= 540 && val >520) ){ //B
asic
fill.set(255, 204, 0);
}
else if ((val <= 160 && val >140) || (val <= 260 && val >240) || (val <=
360 && val >340) || (val <= 460 && val >440) || (val <= 560 && val >540) ){ //I
ntermediate
fill.set(102, 255, 153);
}
else if ((val <= 180 && val >160) || (val <= 280 && val >260) || (val <=
380 && val >360) || (val <= 480 && val >460) || (val <= 580 && val >560) ){ //H
igh
fill.set(153, 204, 255);
}
else if ((val <= 200 && val >180) || (val <= 300 && val >280) || (val <=
400 && val >380) || (val <= 500 && val >480) || (val <= 600 && val >580) ){ //A
dvance
fill.set(204, 204, 255);
}
else {
fill.set(255, 255, 255); //no - display in blue
}
}
/**
* Called before rendering each label on a given Axis.
*
* @param axis
*
Axis

* @param label
*
Label
* @param icsc
*
IChartScriptContext
*/
function beforeDrawAxisLabel( axis, label, icsc )
{
//java.lang.System.out.println(label.getCaption().getValue());
//axis.set
}
/**
* Called before generation of chart model to GeneratedChartState.
*
* @param chart
*
Chart
* @param icsc
*
IChartScriptContext
*/
function beforeGeneration( chart, icsc )
{
var chart =
var
var
var
var

icsc.getChartInstance();
xAxis = chart.getAxes().get(0);
yAxis = xAxis.getAssociatedAxes().get(0);
xSeriesDef = xAxis.getSeriesDefinitions().get(0);
numberOfYSeries = yAxis.getSeriesDefinitions().size();

importPackage( Packages.org.eclipse.birt.chart.* );
importPackage( Packages.org.eclipse.birt.chart.model.impl );
importPackage(Packages.org.eclipse.birt.chart.model.type.impl );
xAxis = chart.getBaseAxes()[0];
yAxis = chart.getOrthogonalAxes( xAxis, true)[0]
yscale = yAxis.getScale();
yscale.setStep (20);
//yAxis.getSeriesDefinitions().get(l).getRunTimeSeries().get(0).getLegen
d();
//for(var l=0; l<yAxis.getSeriesDefinitions().size(); l++){
//
var s = yAxis.getSeriesDefinitions().get(l).getRunTimeSeries().g
et(0);
//
//}

s.setVisible(false);

var actualTypeOfTests = icsc.getExternalContext().getScriptable().getPer


sistentGlobalVariable("actualTypeOfTests");
var toRemove = new Array();
var k = 0;
for (var i=0; i<yAxis.getSeriesDefinitions().size(); i++ ){
java.lang.System.out.println(i + "Predefiend "+yAxis.getSeriesD
efinitions().get(i).getRunTimeSeries().get(0).getSeriesIdentifier());
for (var j=0; j<actualTypeOfTests.size(); j++) {
java.lang.System.out.println("actual
"+actualTypeOfTests[j]
);
if(!actualTypeOfTests.contains(yAxis.getSeriesDefinition

s().get(i).getRunTimeSeries().get(0).getSeriesIdentifier())) {
java.lang.System.out.println("HI");
toRemove[k] = yAxis.getSeriesDefinitions().get(i
).getRunTimeSeries().get(0).getSeriesIdentifier();
k++;
}
yAxis.getSeriesDefinitions().get(i).getRunTimeSeries().g
et(0).setVisible(true);
}
}
java.lang.System.out.println("toRemove"+toRemove);
for(var k=0; k< toRemove.length; k++) {
for (var i=0; i<yAxis.getSeriesDefinitions().size(); i++ ){
if(toRemove[k] == yAxis.getSeriesDefinitions().get(i).ge
tRunTimeSeries().get(0).getSeriesIdentifier()) {
yAxis.getSeriesDefinitions().remove(i);
}
}
}
var grade = icsc.getExternalContext().getScriptable().getPersistentGloba
lVariable("grade");
if (grade == "K") {
yscale.setMin(NumberDataElementImpl.create(100));
yscale.setMax(NumberDataElementImpl.create(200));
}
if (grade == "1") {
yscale.setMin(NumberDataElementImpl.create(200));
yscale.setMax(NumberDataElementImpl.create(300));
}
if (grade == "12" || grade == "9") {
yscale.setMin(NumberDataElementImpl.create(500));
yscale.setMax(NumberDataElementImpl.create(600));
}
if (grade == "3") {
yscale.setMin(NumberDataElementImpl.create(300));
yscale.setMax(NumberDataElementImpl.create(400));
}
yAxis.setScale(yscale);
}
/**
* Called
*
* @param
*
* @param
*
* @param
*
*/

before rendering Series.


series
Series
isr
ISeriesRenderer
icsc
IChartScriptContext

function beforeDrawSeries( series, isr, icsc )


{
java.lang.System.out.println(series);
//series.setVisible(t);
}
/**
* Called before drawing the legend item.

*
* @param
*
* @param
*
* @param
*
* @since
*/

lerh
LegendEntryRenderingHints
bounds
Bounds
icsc
IChartScriptContext
Version 2.2.0

function beforeDrawLegendItem( lerh, bounds, icsc )


{
}

You might also like