Open a .chart file in the eclipse reporting platform? [message #757160] |
Wed, 16 November 2011 15:35  |
Eclipse User |
|
|
|
I have downloaded the birt reporting eclipse platform (not the standalone chart editor). I have the created a simple chart that I write to disk:
Chart myChart = ChartWithAxesImpl.create();
Serializer si = SerializerImpl.instance();
try {
si.write(myChart, new FileOutputStream(new File(CHART_FILE)));
} catch (IOException e) {
e.printStackTrace();
}
When I open the .chart file in eclipse (I have switched to the reporting perspective) I just get an xml file. Is it possible to import a .chart file as chart object somehow?
|
|
|
Re: Open a .chart file in the eclipse reporting platform? [message #757829 is a reply to message #757160] |
Wed, 16 November 2011 17:08  |
Eclipse User |
|
|
|
You can read it into a chart model like:
PlatformConfig pf = new PlatformConfig();
pf.setProperty("STANDALONE", true);
//Returns a singleton instance of the Chart Engine
ChartEngine ce = ChartEngine.instance( pf);
//Returns a singleton instance of the Generator
IGenerator gr = ce.getGenerator();
try
{
//device renderers for dv.SWT, dv.PNG, dv.JPG
//dv.PDF, dv.SVG, dv.SWING, dv.PNG24, div.BMP
dRenderer = ce.getRenderer("dv.PNG");
dServer =dRenderer.getDisplayServer( );
//Example of writting the xml file
//ce.getSerializer().write(cmf, new FileOutputStream(
"chartmodels/mycolorchart.chart" ));
Chart cmf = ce.getSerializer().read(new FileInputStream(
"chartmodels/testpie.chart" ));
Chart cm = (Chart) EcoreUtil.copy( (Chart) cmf );
Remember data is not stored in the .chart file so you will have to bind
it to data
//SerializerExample.bindChart((ChartWithAxes)cm);
Something like:
public static void bindChart(ChartWithAxes cmb){
// Data Set
TextDataSet categoryValues = TextDataSetImpl.create( new String[]{
"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"} ); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
NumberDataSet orthoValues1 = NumberDataSetImpl.create( new double[]{
25, 35, 15, 5, 20
} );
NumberDataSet orthoValues2 = NumberDataSetImpl.create( new double[]{
5, 10, 25, 10, 5
} );
Axis xaxis = cmb.getPrimaryBaseAxes()[0];
Axis yaxis = cmb.getPrimaryOrthogonalAxis(xaxis);
SeriesDefinition sdx =
(SeriesDefinition)xaxis.getSeriesDefinitions().get(0);
SeriesDefinition sdy =
(SeriesDefinition)yaxis.getSeriesDefinitions().get(0);
((Series)sdx.getSeries().get(0)).setDataSet(categoryValues);
((Series)sdy.getSeries().get(0)).setDataSet(orthoValues1);
((Series)sdy.getSeries().get(1)).setDataSet(orthoValues2);
}
Jason
On 11/16/2011 3:35 PM, js wrote:
> I have downloaded the birt reporting eclipse platform (not the
> standalone chart editor). I have the created a simple chart that I write
> to disk:
>
>
> Chart myChart = ChartWithAxesImpl.create();
> Serializer si = SerializerImpl.instance();
> try {
> si.write(myChart, new FileOutputStream(new File(CHART_FILE)));
> } catch (IOException e) {
> e.printStackTrace();
> }
>
>
> When I open the .chart file in eclipse (I have switched to the reporting
> perspective) I just get an xml file. Is it possible to import a .chart
> file as chart object somehow?
|
|
|
Powered by
FUDForum. Page generated in 0.06160 seconds