how do I add a chart to a report Programmatically(I am getting errors) [message #200775] |
Tue, 14 November 2006 11:33  |
Eclipse User |
|
|
|
Originally posted by: geromeferreira.hotmail.com
So far I am able to create a report programmatically but when I try to add
a chart to the report I am getting this error
Exception in thread "main" java.lang.NullPointerException
at
org.eclipse.birt.chart.internal.datafeed.DataProcessor.getRo wExpressions(DataProcessor.java:277)2
at
org.eclipse.birt.chart.internal.datafeed.DataProcessor.getRo wExpressions(DataProcessor.java:85)
at
org.eclipse.birt.chart.factory.Generator.getRowExpressions(G enerator.java:487)
at
org.eclipse.birt.chart.reportitem.ChartReportItemImpl.getRow Expressions(ChartReportItemImpl.java:563)
at
org.eclipse.birt.report.model.util.BoundColumnsMgr.dealExten dedItem(BoundColumnsMgr.java:197)
at
org.eclipse.birt.report.model.writer.BoundColumnsWriterMgr.d ealExtendedItem(BoundColumnsWriterMgr.java:411)
at
org.eclipse.birt.report.model.writer.ModuleWriter.visitExten dedItem(ModuleWriter.java:1417)
at
org.eclipse.birt.report.model.elements.ExtendedItem.apply(Ex tendedItem.java:113)
at
org.eclipse.birt.report.model.writer.ModuleWriter.writeConte nts(ModuleWriter.java:2229)
at
org.eclipse.birt.report.model.writer.DesignWriter.visitRepor tDesign(DesignWriter.java:122)
at
org.eclipse.birt.report.model.elements.ReportDesign.apply(Re portDesign.java:80)
at
org.eclipse.birt.report.model.writer.ModuleWriter.writeFile( ModuleWriter.java:198)
at
org.eclipse.birt.report.model.writer.ModuleWriter.write(Modu leWriter.java:169)
at
org.eclipse.birt.report.model.api.ModuleHandle.save(ModuleHa ndle.java:1438)
at
org.eclipse.birt.report.model.api.ModuleHandle.saveAs(Module Handle.java:1458)
at ibm.report.com.Report.createReport(Report.java:155)
at ibm.report.com.Report.main(Report.java:110)
//////////////////////////////////////////////////////////// //////////////////
this is how I am adding to the report
reportDesignHandle.getBody().add( ei);
//////////////////////////////////////////////////////////// //////////////////
this is the code to create the chart
public static ExtendedItemHandle createSimpleLineChart()
{
ExtendedItemHandle eItemHandle =null;
eItemHandle = elementFactory.newExtendedItem( null, "Chart"
);//$NON-NLS-1$
try
{
eItemHandle.setHeight( "288pt" );//$NON-NLS-1$
eItemHandle.setWidth( "252pt" );//$NON-NLS-1$
eItemHandle.setProperty( ExtendedItemHandle.DATA_SET_PROP, "Data
Set" );//$NON
PropertyHandle computedSet = eItemHandle.getColumnBindings( );
cs1.setExpression( "dataSetRow["ID"]" );//$NON-NLS-1$
computedSet.addItem( cs1 );
cs2.setExpression( "dataSetRow["Type"]" );//$NON-NLS-1$
computedSet.addItem( cs2 );
cs3.setExpression( "dataSetRow["Date"]" );//$NON-NLS-1$
computedSet.addItem( cs3 );
cs4.setExpression( "dataSetRow["Data"]" );//$NON-NLS-1$
computedSet.addItem( cs4 );
}
catch ( SemanticException e )
{
e.printStackTrace( );
}
ChartWithAxes cwaBar = ChartWithAxesImpl.create();
cwaBar.getBlock().setBackground(ColorDefinitionImpl.WHITE()) ;
Plot p = cwaBar.getPlot();
p.getClientArea().setBackground(ColorDefinitionImpl.create(2 55,
255,
225));
cwaBar.getTitle().getLabel().getCaption()
.setValue("Sample Line Chart");
Legend lg = cwaBar.getLegend();
LineAttributes lia = lg.getOutline();
lg.getText().getFont().setSize(16);
lia.setStyle(LineStyle.SOLID_LITERAL);
lg.getInsets().set(10, 5, 0, 0);
lg.getOutline().setVisible(false);
lg.setAnchor(Anchor.NORTH_LITERAL);
AxisImpl xAxisPrimary =
(AxisImpl) cwaBar.getPrimaryBaseAxes()[0];
xAxisPrimary.setType(AxisType.TEXT_LITERAL);
xAxisPrimary.getMajorGrid()
.setTickStyle(TickStyle.BELOW_LITERAL);
xAxisPrimary.getOrigin()
.setType(IntersectionType.VALUE_LITERAL);
xAxisPrimary.getTitle().setVisible(false);
AxisImpl yAxisPrimary = (AxisImpl) cwaBar
.getPrimaryOrthogonalAxis(xAxisPrimary);
yAxisPrimary.getMajorGrid()
.setTickStyle(TickStyle.LEFT_LITERAL);
yAxisPrimary.setPercent(true);
Vector vs = new Vector();
vs.add("one");
vs.add("two");
vs.add("three");
ArrayList vn1 = new ArrayList();
vn1.add(new Double(25));
vn1.add(new Double(35));
vn1.add(new Double(-45));
TextDataSet categoryValues = TextDataSetImpl.create(vs);
NumberDataSet orthoValues1 = NumberDataSetImpl.create(vn1);
// CREATE THE CATEGORY SERIES
Series seCategory = SeriesImpl.create();
seCategory.setDataSet(categoryValues);
// CREATE THE PRIMARY DATASET
LineSeries ls = (LineSeries) LineSeriesImpl.create();
ls.setSeriesIdentifier("My Line Series");
ls.setDataSet(orthoValues1);
ls.getLineAttributes().setColor(ColorDefinitionImpl.CREAM()) ;
ls.getMarker().setType(MarkerType.TRIANGLE_LITERAL);
ls.getLabel().setVisible(true);
SeriesDefinition sdX = SeriesDefinitionImpl.create();
sdX.getSeriesPalette().update(0);
xAxisPrimary.getSeriesDefinitions().add(sdX);
SeriesDefinition sdY = SeriesDefinitionImpl.create();
sdY.getSeriesPalette().update(1);
yAxisPrimary.getSeriesDefinitions().add(sdY);
sdX.getSeries().add(seCategory);
sdY.getSeries().add(ls);
try
{
//Add chart instance to IReportItem
eItemHandle.getReportItem( ).setProperty( "chart.instance",
cwaBar );//$NON-NLS-1$
System.out.println("2");
}
catch ( ExtendedElementException e )
{
e.printStackTrace( );
}
return eItemHandle;
}
//////////////////////////////////////////////////////////// //////////////////
If anyone could point me to the right direction or advice on me how to
tackle this I will highly appreciated. Thank you in advance. I been at
this for weeks and can't see the problem.
|
|
|
Re: how do I add a chart to a report Programmatically(I am getting errors) [message #200864 is a reply to message #200775] |
Tue, 14 November 2006 19:35  |
Eclipse User |
|
|
|
I believe this is because you are using data binding for the report item but
not using the query. You are defining vectors with values.
Take a look at this example.
Jason
import java.io.File;
import java.io.IOException;
import org.eclipse.birt.chart.model.Chart;
import org.eclipse.birt.chart.model.ChartWithAxes;
import org.eclipse.birt.chart.model.attribute.Anchor;
import org.eclipse.birt.chart.model.attribute.AxisType;
import org.eclipse.birt.chart.model.attribute.IntersectionType;
import org.eclipse.birt.chart.model.attribute.LineAttributes;
import org.eclipse.birt.chart.model.attribute.LineStyle;
import org.eclipse.birt.chart.model.attribute.Marker;
import org.eclipse.birt.chart.model.attribute.MarkerType;
import org.eclipse.birt.chart.model.attribute.TickStyle;
import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionI mpl;
import org.eclipse.birt.chart.model.component.Axis;
import org.eclipse.birt.chart.model.component.Series;
import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
import org.eclipse.birt.chart.model.data.Query;
import org.eclipse.birt.chart.model.data.SeriesDefinition;
import org.eclipse.birt.chart.model.data.impl.QueryImpl;
import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl;
import org.eclipse.birt.chart.model.layout.Legend;
import org.eclipse.birt.chart.model.layout.Plot;
import org.eclipse.birt.chart.model.type.LineSeries;
import org.eclipse.birt.chart.model.type.impl.LineSeriesImpl;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.DesignElementHandle;
import org.eclipse.birt.report.model.api.DesignEngine;
import org.eclipse.birt.report.model.api.ElementFactory;
import org.eclipse.birt.report.model.api.ExtendedItemHandle;
import org.eclipse.birt.report.model.api.IDesignEngine;
import org.eclipse.birt.report.model.api.IDesignEngineFactory;
import org.eclipse.birt.report.model.api.PropertyHandle;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.ScriptDataSetHandle;
import org.eclipse.birt.report.model.api.ScriptDataSourceHandle;
import org.eclipse.birt.report.model.api.SessionHandle;
import org.eclipse.birt.report.model.api.StructureFactory;
import org.eclipse.birt.report.model.api.activity.SemanticException ;
import org.eclipse.birt.report.model.api.command.ContentException;
import org.eclipse.birt.report.model.api.command.NameException;
import org.eclipse.birt.report.model.api.elements.structures.Comput edColumn;
import org.eclipse.birt.report.model.api.extension.ExtendedElementE xception;
import org.eclipse.birt.report.model.api.metadata.IMetaDataDictiona ry;
import com.ibm.icu.util.ULocale;
public class CreateChart {
ReportDesignHandle reportDesignHandle = null;
ElementFactory elementFactory = null;
IMetaDataDictionary dict = null;
ComputedColumn cs1, cs2, cs3 = null;
public static void main( String[] args ) throws SemanticException,
IOException
{
new CreateChart( ).createReport( );
System.out.println("Finished");
}
void createReport( ) throws SemanticException, IOException
{
//Configure the Engine and start the Platform
DesignConfig config = new DesignConfig( );
config.setProperty("BIRT_HOME",
"C:/birt-runtime-2_1_1/birt-runtime-2_1_1/ReportEngine");
IDesignEngine engine = null;
try{
Platform.startup( config );
IDesignEngineFactory factory = (IDesignEngineFactory) Platform
.createFactoryObject(
IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
engine = factory.createDesignEngine( config );
}catch( Exception ex){
ex.printStackTrace();
}
SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;
// Create a new report
reportDesignHandle = session.createDesign( );
// Element factory is used to create instances of BIRT elements.
elementFactory = reportDesignHandle.getElementFactory( );
dict = new DesignEngine( null ).getMetaData( );
createMasterPages( );
createDataSources( );
createDataSets( );
createBody( );
String outputPath = "output";//$NON-NLS-1$
File outputFolder = new File( outputPath );
if ( !outputFolder.exists( ) && !outputFolder.mkdir( ) )
{
throw new IOException( "Can not create the output folder" );//$NON-NLS-1$
}
reportDesignHandle.saveAs( outputPath
+ "/" + "CreateLineChartExample.rptdesign" );//$NON-NLS-1$//$NON-NLS-2$
}
private void createBody( ) throws SemanticException
{
ExtendedItemHandle eih = elementFactory.newExtendedItem( null,
"Chart" );//$NON-NLS-1$
try
{
eih.setHeight( "488pt" );//$NON-NLS-1$
eih.setWidth( "452pt" );//$NON-NLS-1$
eih.setProperty( ExtendedItemHandle.DATA_SET_PROP, "Data
Set" );//$NON-NLS-1$
}
catch ( SemanticException e )
{
e.printStackTrace( );
}
PropertyHandle computedSet = eih.getColumnBindings( );
cs1.setExpression( "dataSetRow[\"Month\"]" );//$NON-NLS-1$
computedSet.addItem( cs1 );
cs2.setExpression( "dataSetRow[\"Product\"]" );//$NON-NLS-1$
computedSet.addItem( cs2 );
cs3.setExpression( "dataSetRow[\"Amount\"]" );//$NON-NLS-1$
computedSet.addItem( cs3 );
reportDesignHandle.getBody( ).add( eih );
try
{
// Add chart instance to IReportItem
eih.getReportItem( ).setProperty( "chart.instance",
createSimpleLineChart( ) );//$NON-NLS-1$
}
catch ( ExtendedElementException e )
{
e.printStackTrace( );
}
}
private void createDataSources( ) throws SemanticException
{
ScriptDataSourceHandle dataSourceHandle =
elementFactory.newScriptDataSource( "Data Source" );//$NON-NLS-1$
reportDesignHandle.getDataSources( ).add( dataSourceHandle );
}
private void createDataSets( ) throws SemanticException
{
// Data Set
ScriptDataSetHandle dataSetHandle = elementFactory.newScriptDataSet( "Data
Set" );//$NON-NLS-1$
dataSetHandle.setDataSource( "Data Source" );//$NON-NLS-1$
// Set open( ) in code
dataSetHandle.setOpen( "i=0;"//$NON-NLS-1$
+ "sourcedata = new Array( new Array(3), new Array(3), new Array(3),
new Array(3));"//$NON-NLS-1$
+ "sourcedata[0][0] = 10; "//$NON-NLS-1$
+ "sourcedata[0][1] = \"Ice Bella\";"//$NON-NLS-1$
+ "sourcedata[0][2] = 304;"//$NON-NLS-1$
+ "sourcedata[1][0] = 10; "//$NON-NLS-1$
+ "sourcedata[1][1] = \"Nola Dicci\";"//$NON-NLS-1$
+ "sourcedata[1][2] = 258;"//$NON-NLS-1$
+ "sourcedata[2][0] = 11; "//$NON-NLS-1$
+ "sourcedata[2][1] = \"Ice Bella\";"//$NON-NLS-1$
+ "sourcedata[2][2] = 202;"//$NON-NLS-1$
+ "sourcedata[3][0] = 11; "//$NON-NLS-1$
+ "sourcedata[3][1] = \"Nola Dicci\";"//$NON-NLS-1$
+ "sourcedata[3][2] = 181;" );//$NON-NLS-1$
// Set fetch( ) in code
dataSetHandle.setFetch( "if ( i < 4 ){"//$NON-NLS-1$
+ "row[\"Month\"] = sourcedata[i][0];"//$NON-NLS-1$
+ "row[\"Product\"] = sourcedata[i][1];"//$NON-NLS-1$
+ "row[\"Amount\"] = sourcedata[i][2];"//$NON-NLS-1$
+ "i++;"//$NON-NLS-1$
+ "return true;}" + "else return false;" );//$NON-NLS-1$//$NON-NLS-2$
// Set computed columns
cs1 = StructureFactory.createComputedColumn( );
cs1.setName( "Month" );//$NON-NLS-1$
cs1.setExpression( "row[\"Month\"]" );//$NON-NLS-1$
cs1.setDataType( "integer" );//$NON-NLS-1$
cs2 = StructureFactory.createComputedColumn( );
cs2.setName( "Product" );//$NON-NLS-1$
cs2.setExpression( "row[\"Product\"]" );//$NON-NLS-1$
cs2.setDataType( "string" );//$NON-NLS-1$
cs3 = StructureFactory.createComputedColumn( );
cs3.setName( "Amount" );//$NON-NLS-1$
cs3.setExpression( "row[\"Amount\"]" );//$NON-NLS-1$
cs3.setDataType( "integer" );//$NON-NLS-1$
PropertyHandle computedSet = dataSetHandle.getPropertyHandle(
ScriptDataSetHandle.COMPUTED_COLUMNS_PROP );
computedSet.addItem( cs1 );
computedSet.addItem( cs2 );
computedSet.addItem( cs3 );
reportDesignHandle.getDataSets( ).add( dataSetHandle );
}
private void createMasterPages( ) throws ContentException, NameException
{
DesignElementHandle simpleMasterPage =
elementFactory.newSimpleMasterPage( "Master Page" );//$NON-NLS-1$
reportDesignHandle.getMasterPages( ).add( simpleMasterPage );
}
public Chart createSimpleLineChart()
{
ChartWithAxes cwaLine = ChartWithAxesImpl.create();
cwaLine.setType("Line Chart");
cwaLine.setSubType("Overlay");
cwaLine.getBlock().setBackground(ColorDefinitionImpl.WHITE() );
Plot p = cwaLine.getPlot();
p.getClientArea().setBackground(ColorDefinitionImpl.create(2 55,
255,
225));
cwaLine.getTitle().getLabel().getCaption().setValue("Sample Line Chart");
Legend lg = cwaLine.getLegend();
LineAttributes lia = lg.getOutline();
lg.getText().getFont().setSize(16);
lia.setStyle(LineStyle.SOLID_LITERAL);
lg.getInsets().set(10, 5, 0, 0);
lg.getOutline().setVisible(false);
lg.setAnchor(Anchor.NORTH_LITERAL);
Axis xAxisPrimary = (Axis) cwaLine.getPrimaryBaseAxes()[0];
xAxisPrimary.setType(AxisType.TEXT_LITERAL);
xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LIT ERAL);
xAxisPrimary.getOrigin().setType(IntersectionType.VALUE_LITE RAL);
xAxisPrimary.getTitle().setVisible(false);
Axis yAxisPrimary = (Axis) cwaLine.getPrimaryOrthogonalAxis(xAxisPrimary);
yAxisPrimary.getMajorGrid() .setTickStyle(TickStyle.LEFT_LITERAL);
yAxisPrimary.setPercent(false);
/*
Vector vs = new Vector();
vs.add("one");
vs.add("two");
vs.add("three");
ArrayList vn1 = new ArrayList();
vn1.add(new Double(25));
vn1.add(new Double(35));
vn1.add(new Double(-45));
TextDataSet categoryValues = TextDataSetImpl.create(vs);
NumberDataSet orthoValues1 = NumberDataSetImpl.create(vn1);
*/
Series seCategory = SeriesImpl.create( );
Query query = QueryImpl.create( "row[\"Month\"]" );//$NON-NLS-1$
seCategory.getDataDefinition( ).add( query );
// CREATE THE CATEGORY SERIES
// Series seCategory = SeriesImpl.create();
//seCategory.setDataSet(categoryValues);
// CREATE THE PRIMARY DATASET
LineSeries ls = (LineSeries) LineSeriesImpl.create();
ls.setSeriesIdentifier("My Line Series");
//ls.setDataSet(orthoValues1);
Query queryls = QueryImpl.create( "row[\"Amount\"]" );//$NON-NLS-1$
ls.getDataDefinition().add( queryls );
ls.getLineAttributes().setColor(ColorDefinitionImpl.CREAM()) ;
for ( int i = 0; i < ls.getMarkers( ).size( ); i++ )
{
( (Marker) ls.getMarkers( ).get( i ) ).setType(
MarkerType.TRIANGLE_LITERAL );
( (Marker) ls.getMarkers( ).get( i ) ).setSize( 5 );
}
ls.getLabel().setVisible(true);
SeriesDefinition sdX = SeriesDefinitionImpl.create();
sdX.getSeriesPalette().update(0);
xAxisPrimary.getSeriesDefinitions().add(sdX);
SeriesDefinition sdY = SeriesDefinitionImpl.create();
sdY.getSeriesPalette().update(1);
yAxisPrimary.getSeriesDefinitions().add(sdY);
sdX.getSeries().add(seCategory);
sdY.getSeries().add(ls);
return cwaLine;
}
}
"Gerome Ferreira" <geromeferreira@hotmail.com> wrote in message
news:5d0c444c899f3a3a6b706c40bf0acd2b$1@www.eclipse.org...
> So far I am able to create a report programmatically but when I try to add
> a chart to the report I am getting this error
> Exception in thread "main" java.lang.NullPointerException
> at
> org.eclipse.birt.chart.internal.datafeed.DataProcessor.getRo wExpressions(DataProcessor.java:277)2
>
> at
> org.eclipse.birt.chart.internal.datafeed.DataProcessor.getRo wExpressions(DataProcessor.java:85)
> at
> org.eclipse.birt.chart.factory.Generator.getRowExpressions(G enerator.java:487)
> at
> org.eclipse.birt.chart.reportitem.ChartReportItemImpl.getRow Expressions(ChartReportItemImpl.java:563)
> at
> org.eclipse.birt.report.model.util.BoundColumnsMgr.dealExten dedItem(BoundColumnsMgr.java:197)
> at
> org.eclipse.birt.report.model.writer.BoundColumnsWriterMgr.d ealExtendedItem(BoundColumnsWriterMgr.java:411)
> at
> org.eclipse.birt.report.model.writer.ModuleWriter.visitExten dedItem(ModuleWriter.java:1417)
> at
> org.eclipse.birt.report.model.elements.ExtendedItem.apply(Ex tendedItem.java:113)
> at
> org.eclipse.birt.report.model.writer.ModuleWriter.writeConte nts(ModuleWriter.java:2229)
> at
> org.eclipse.birt.report.model.writer.DesignWriter.visitRepor tDesign(DesignWriter.java:122)
> at
> org.eclipse.birt.report.model.elements.ReportDesign.apply(Re portDesign.java:80)
> at
> org.eclipse.birt.report.model.writer.ModuleWriter.writeFile( ModuleWriter.java:198)
> at
> org.eclipse.birt.report.model.writer.ModuleWriter.write(Modu leWriter.java:169)
> at
> org.eclipse.birt.report.model.api.ModuleHandle.save(ModuleHa ndle.java:1438)
> at
> org.eclipse.birt.report.model.api.ModuleHandle.saveAs(Module Handle.java:1458)
> at ibm.report.com.Report.createReport(Report.java:155)
> at ibm.report.com.Report.main(Report.java:110)
>
> //////////////////////////////////////////////////////////// //////////////////
>
> this is how I am adding to the report reportDesignHandle.getBody().add(
> ei);
>
> //////////////////////////////////////////////////////////// //////////////////
> this is the code to create the chart public static ExtendedItemHandle
> createSimpleLineChart()
> {
> ExtendedItemHandle eItemHandle =null;
> eItemHandle = elementFactory.newExtendedItem( null,
> "Chart" );//$NON-NLS-1$
> try
> {
> eItemHandle.setHeight( "288pt" );//$NON-NLS-1$
> eItemHandle.setWidth( "252pt" );//$NON-NLS-1$
> eItemHandle.setProperty( ExtendedItemHandle.DATA_SET_PROP, "Data
> Set" );//$NON
>
> PropertyHandle computedSet = eItemHandle.getColumnBindings( );
>
> cs1.setExpression( "dataSetRow["ID"]" );//$NON-NLS-1$
> computedSet.addItem( cs1 );
> cs2.setExpression( "dataSetRow["Type"]" );//$NON-NLS-1$
> computedSet.addItem( cs2 );
> cs3.setExpression( "dataSetRow["Date"]" );//$NON-NLS-1$
> computedSet.addItem( cs3 );
> cs4.setExpression( "dataSetRow["Data"]" );//$NON-NLS-1$
> computedSet.addItem( cs4 );
>
> }
> catch ( SemanticException e )
> {
> e.printStackTrace( );
> }
> ChartWithAxes cwaBar = ChartWithAxesImpl.create();
> cwaBar.getBlock().setBackground(ColorDefinitionImpl.WHITE()) ;
> Plot p = cwaBar.getPlot();
> p.getClientArea().setBackground(ColorDefinitionImpl.create(2 55,
> 255,
> 225));
> cwaBar.getTitle().getLabel().getCaption()
> .setValue("Sample Line Chart");
>
>
> Legend lg = cwaBar.getLegend();
> LineAttributes lia = lg.getOutline();
> lg.getText().getFont().setSize(16);
> lia.setStyle(LineStyle.SOLID_LITERAL);
> lg.getInsets().set(10, 5, 0, 0);
> lg.getOutline().setVisible(false);
> lg.setAnchor(Anchor.NORTH_LITERAL);
>
>
> AxisImpl xAxisPrimary =
> (AxisImpl) cwaBar.getPrimaryBaseAxes()[0];
> xAxisPrimary.setType(AxisType.TEXT_LITERAL);
> xAxisPrimary.getMajorGrid()
> .setTickStyle(TickStyle.BELOW_LITERAL);
> xAxisPrimary.getOrigin()
> .setType(IntersectionType.VALUE_LITERAL);
> xAxisPrimary.getTitle().setVisible(false);
>
>
> AxisImpl yAxisPrimary = (AxisImpl) cwaBar
> .getPrimaryOrthogonalAxis(xAxisPrimary);
> yAxisPrimary.getMajorGrid()
> .setTickStyle(TickStyle.LEFT_LITERAL);
> yAxisPrimary.setPercent(true);
>
>
> Vector vs = new Vector();
> vs.add("one");
> vs.add("two");
> vs.add("three");
>
>
> ArrayList vn1 = new ArrayList();
> vn1.add(new Double(25));
> vn1.add(new Double(35));
> vn1.add(new Double(-45));
>
>
> TextDataSet categoryValues = TextDataSetImpl.create(vs);
> NumberDataSet orthoValues1 = NumberDataSetImpl.create(vn1);
>
>
> // CREATE THE CATEGORY SERIES
> Series seCategory = SeriesImpl.create();
> seCategory.setDataSet(categoryValues);
>
>
> // CREATE THE PRIMARY DATASET
> LineSeries ls = (LineSeries) LineSeriesImpl.create();
> ls.setSeriesIdentifier("My Line Series");
> ls.setDataSet(orthoValues1);
> ls.getLineAttributes().setColor(ColorDefinitionImpl.CREAM()) ;
> ls.getMarker().setType(MarkerType.TRIANGLE_LITERAL);
> ls.getLabel().setVisible(true);
>
>
> SeriesDefinition sdX = SeriesDefinitionImpl.create();
> sdX.getSeriesPalette().update(0);
> xAxisPrimary.getSeriesDefinitions().add(sdX);
>
>
> SeriesDefinition sdY = SeriesDefinitionImpl.create();
> sdY.getSeriesPalette().update(1);
> yAxisPrimary.getSeriesDefinitions().add(sdY);
>
>
> sdX.getSeries().add(seCategory);
> sdY.getSeries().add(ls);
>
>
> try
> {
> //Add chart instance to IReportItem
> eItemHandle.getReportItem( ).setProperty( "chart.instance",
> cwaBar );//$NON-NLS-1$
> System.out.println("2");
> }
> catch ( ExtendedElementException e )
> {
> e.printStackTrace( );
> }
>
> return eItemHandle;
> }
> //////////////////////////////////////////////////////////// //////////////////
> If anyone could point me to the right direction or advice on me how to
> tackle this I will highly appreciated. Thank you in advance. I been at
> this for weeks and can't see the problem.
>
|
|
|
Powered by
FUDForum. Page generated in 0.42844 seconds