Can not link a Series to a chart SeriesDefinitions in BIRT
I am trying hard to implement a charting extension to an app that i am developing : so my problem is that I have written some code (the boiler plate one) for doing this in BIRT.
At some place in the code, I have to link the dataset to a series and link the series to a seriesdefinition object which finally will be attached to the charts seriesDefinitions like this
RadarSeries radarSeries = RadarSeriesImpl.create();
radarSeries.setDataSet(numberDataValues);
radarSeries.setSeriesIdentifier("Number data values");
radarSeries.getLabel().setVisible(true);
where numberDataValues is an array of doubles. Then I create my seriesDefinition :
SeriesDefinition seriesDefinition = SeriesDefinitionImpl.create();
seriesDefinition.getSeriesPalette().shift(0);
But then, here comes the time when I have to LINK my radarSeries to the seriesDefinition like this :
seriesDefinition.getSeriesDefinitions().add(radarSeries);
THE PROBLEM : I don't have the getSeriesDefinitions() method when trying to call it from code (doing a Ctrl+Space in Eclipse).
Needless to say that I can't call the getSeriesDefinitions() method on myChart object :
myChart.getSeriesDefinitions().add(seriesDefinition);
FOR YOUR INFORMATION : I have included my birt jars manually in my local maven repository and the details of these dependencies are :
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>engineapi</artifactId>
<version>${birtVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<a开发者_运维百科rtifactId>coreapi</artifactId>
<version>${birtVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>scriptapi</artifactId>
<version>${birtVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>chartengineapi</artifactId>
<version>${birtVersion}</version>
</dependency>
where ${birtVersion} = 2.6.2
here is a link to the official example of the 2.6.2 release of birt about RadarChart : Radar chart official release example
Can somebody help me ? I really can't believe I didn't found out how to do this in a 3days google search session : that not serious! ... given its popularity and its power, I think they should have invested more effort in the documentation ...
@Birt guyz (if any) > sorry to be so dramatic guys, but I really think that the doc side really sucks ... I hope to be able to help you on this (really, I do)
Here is the code :
public String drawChart() {
// Birt Vars
IDeviceRenderer iDeviceRenderer = null;
IDisplayServer iDisplayServer = null;
RunTimeContext context;
Chart chart = null;
// Birt Platform configuration
PlatformConfig platformConfig = new PlatformConfig();
platformConfig.setProperty("STANDALONE", true);
// Creating Chart Engine
ChartEngine chartEngine = ChartEngine.instance(platformConfig);
IGenerator iGenerator = chartEngine.getGenerator();
if(iGenerator == null)
System.out.println("IGenerator NULL");
else
System.out.println("IGenerator NOT NULL");
try {
// iDeviceRenderer = chartEngine.getRenderer("dv.PNG");
iDeviceRenderer = chartEngine.getRenderer("dv.GIF");
iDisplayServer = iDeviceRenderer.getDisplayServer();
} catch (Exception e) {
e.printStackTrace();
}
// Creating Chart
ChartWithoutAxes radarChart = ChartWithoutAxesImpl.create( );
radarChart.setDimension( ChartDimension.TWO_DIMENSIONAL_LITERAL );
radarChart.setType(Radar.TYPE_LITERAL); //$NON-NLS-1$
radarChart.setSubType( "Standard Radar Chart" ); //$NON-NLS-1$
// Plot
radarChart.setSeriesThickness( 10 );
// Legend
Legend lg = radarChart.getLegend( );
lg.getOutline( ).setVisible( true );
// Title
radarChart.getTitle( )
.getLabel( )
.getCaption( )
.setValue( "Radar Chart" );//$NON-NLS-1$
try {
if(radarChart != null)
System.out.println("RADAR CHART NOT NULL");
else
System.out.println("RADAR CHART NULL!!!");
// PREPARE PHASE
context = Generator.instance().prepare(radarChart, null, null, ULocale.getDefault());
if(context == null)
System.out.println("CONTEXT NULL ");
else
System.out.println("CONTEXT NOT NULL");
//BIND PHASE : fetch data from DB
NumberDataSet numberDataValues = NumberDataSetImpl.create( new double[]{
54, 21, 75, 91, 37
} );
// Radar series
RadarSeries radarSeries = RadarSeriesImpl.create();
radarSeries.setDataSet(numberDataValues);
radarSeries.setSeriesIdentifier("Number data values");
radarSeries.getLabel().setVisible(true);
SeriesDefinitionImpl seriesDefinition = (SeriesDefinitionImpl) SeriesDefinitionImpl.create();
seriesDefinition.getSeriesPalette().shift(0);
// ERROR HERE : can't call the method
seriesDefinition.getSeriesDefinitions()
// RENDERING PHASE
if(iDisplayServer == null)
System.out.println("DISPLAY SERVER NULL");
else
System.out.println("DISPLAY SERVER NOT NULL");
GeneratedChartState generatedChartState = iGenerator.build(iDisplayServer, radarChart, null, null, context);
iGenerator.render(iDeviceRenderer, generatedChartState);
} catch (Exception e) {
e.printStackTrace();
}
}
EDIT + SOLUTION
Sorry for the delay : I should have posted this answer earlier to mark this question as solved. Just use the RCP report designer to create your report document. Copy ReportEngine/lib/*jars to your /WEB-INF/lib; also create a platform/ directory under WEB-INF/ and copy BIRT ReportEngine configuration/ and plugins/ directories under the newly created WEB-INF/platform/ folder. Now with the *.rptdesign file that you have created in your BIRT RCP designer tool, you will have to use the BIRT API which will allow you to interact with your report...
Sorry for the delay : I should have posted this answer earlier to mark this question as solved.
Just use the RCP report designer to create your report document. Then copy ReportEngine/lib/*jars to your /WEB-INF/lib; also create a platform/ directory under WEB-INF/ and copy BIRT ReportEngine configuration/ and plugins/ directories under the newly created WEB-INF/platform/ folder.
Now with the *.rptdesign file that you have created in your BIRT RCP designer tool, you will have to use the BIRT API which will allow you to interact with your report...
精彩评论