deploy BIRT chart on web application
Options
Hi,
I m using BIRT chart Engine from a last week
I m able to show the chart as a PNG image using BIRT chart Api by using java
Now i want to show the chart on a webpage in the form of image only
I dont want to use applet or any webviewer(Provided by BIRT Chart Engine).
I search through google what i got is two options:
1: use of servlet to show chart on webpage
from the examples provided at
org.eclipse.birt.chart.examples_2.1.1.v20070705-1847 plugine in chart Engine
2:jsp chart tag library to show the chart image on webpage
It take the input as XML file or java instance which create the chart
I got the example for this from chart-viewer-sampple.war file from chart engine download.
So which option i should use?
and also
i want to show tooltip ,Hyperlink,Drilldown effect on that chart Image on webpage
the chart image is in the form of jag or png formatte.
so is there any way to do that?
because i search through google but i m not getting anything. very much confused.
Is any functionality provided by BIRT chart Engine to do that?
plesae help me.
give some guideline.
thanks
mani
I m using BIRT chart Engine from a last week
I m able to show the chart as a PNG image using BIRT chart Api by using java
Now i want to show the chart on a webpage in the form of image only
I dont want to use applet or any webviewer(Provided by BIRT Chart Engine).
I search through google what i got is two options:
1: use of servlet to show chart on webpage
from the examples provided at
org.eclipse.birt.chart.examples_2.1.1.v20070705-1847 plugine in chart Engine
2:jsp chart tag library to show the chart image on webpage
It take the input as XML file or java instance which create the chart
I got the example for this from chart-viewer-sampple.war file from chart engine download.
So which option i should use?
and also
i want to show tooltip ,Hyperlink,Drilldown effect on that chart Image on webpage
the chart image is in the form of jag or png formatte.
so is there any way to do that?
because i search through google but i m not getting anything. very much confused.
Is any functionality provided by BIRT chart Engine to do that?
plesae help me.
give some guideline.
thanks
mani
0
Comments
-
Mani,<br />
<br />
There is an example here:<br />
<a class='bbc_url' href='http://www.birt-exchange.com/modules/wfdownloads/singlefile.php?cid=2&lid=340'>http://www.birt-exchange.com/modules/wfdownloads/singlefile.php?cid=2&lid=340</a><br />
that uses both the Chart Engine api in a servlet and the chart tag library.<br />
<br />
The chart engine also supports interactivity. Some of the api examples in that same package illustrate this.<br />
<br />
Jason0 -
Once you have created the chart model using the api you can store it in an xml file by calling the serializer methods
ChartEngine ce = ChartEngine.instance( pf);
ce.getSerializer().write(yourchartmodel, new FileOutputStream( "chartmodels/mycolorchart.chart" ));
Jason0 -
Hi jason,
Thanks for your reply.
i tried the code that u hav given .but i m not able to see that chart on web page.
I m using JSP chart taglib ,in which i am passing .chart file as a parameter.
I m not able to see the chart generated from mycolorchart.chart file.
please help..........
mani0 -
Hi jason,
I m able to run the example of ChartWebWiz.
but i m trying to create XML file from the chart genetrated by
chart api in java from your given code .
and try to show it on web page by using index.jsp file
but i m not able to see chart on web.
Am i doing something wrong?
that is
1.generating chart from chart api in java
2.converting it to XML by using serialize fuction(i.e in .chart file)
3.passing .chart file to jsptaglib
please help.............
thanks
mani0 -
This is a little tricky, because the serializer does not save the data for the series created in ta chart model. So you can either use the sample data or add the data attribute to the chart tag. Take a look at this example
I am creating a pie chart and serializing it. You will see that I set the sample data for the chart and also creat a query on each of the two series. More notes after the code:
cm = SerializerExample.createPie();
ce.getSerializer().write(cm, new FileOutputStream( "chartmodels/testpie.chart" ));
public static Chart createPie( )
{
ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create( );
cwoaPie.setDimension( ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL );
cwoaPie.setType( "Pie Chart" ); //$NON-NLS-1$
cwoaPie.setSubType( "Standard Pie Chart" ); //$NON-NLS-1$
// Plot
cwoaPie.setSeriesThickness( 10 );
// Legend
Legend lg = cwoaPie.getLegend( );
lg.getOutline( ).setVisible( true );
// Title
cwoaPie.getTitle( ).getLabel( ).getCaption( ).setValue( "Pie Chart" );//$NON-NLS-1$
SampleData sdata = DataFactory.eINSTANCE.createSampleData( );
BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData( );
sdBase.setDataSetRepresentation( "" );//$NON-NLS-1$
sdata.getBaseSampleData( ).add( sdBase );
OrthogonalSampleData sdOrthogonal = DataFactory.eINSTANCE.createOrthogonalSampleData( );
sdOrthogonal.setDataSetRepresentation( "" );//$NON-NLS-1$
sdOrthogonal.setSeriesDefinitionIndex( 0 );
sdata.getOrthogonalSampleData( ).add( sdOrthogonal );
cwoaPie.setSampleData( sdata );
// Base Series
Query xQ = QueryImpl.create( "cat-1" );
Series seCategory = SeriesImpl.create( );
seCategory.getDataDefinition().add(xQ);
SeriesDefinition sd = SeriesDefinitionImpl.create( );
cwoaPie.getSeriesDefinitions( ).add( sd );
sd.getSeriesPalette( ).shift( 0 );
sd.getSeries( ).add( seCategory );
// Orthogonal Series
Query yQ = QueryImpl.create( "val-1" );
PieSeries sePie = (PieSeries) PieSeriesImpl.create( );
sePie.getDataDefinition().add(yQ);
sePie.setSeriesIdentifier( "Cities" );//$NON-NLS-1$
sePie.setExplosion( 5 );
SeriesDefinition sdCity = SeriesDefinitionImpl.create( );
sd.getSeriesDefinitions( ).add( sdCity );
sdCity.getSeries( ).add( sePie );
return cwoaPie;
}
To display this chart using the tag lib I must use the data attribute in my jsp page
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/chart.tld" prefix="chart"%>
<%@page import="org.eclipse.birt.chart.viewer.sample.SampleHelper"%>
<%@page import="com.ibm.icu.util.ULocale"%>
<%@page import="my.chart.data.DataForChartTag"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Sample web page of BIRT chart</title>
</head>
<body>
Bar chart with tooltips, URL hyperlink, data evaluator (PNG):
<chart:renderChart width="600" height="400"
data="<%=DataForChartTag.getChartData() %>"
model="<%=session.getServletContext().getRealPath("testpie.chart")%>">
</chart:renderChart>
</body>
</html>
You will notice my data attribute is using DataForChartTag.getChartData(). I added this to my jsp project and it looks like the following:
package my.chart.data;
import org.eclipse.birt.chart.factory.IDataRowExpressionEvaluator;
import org.eclipse.birt.chart.integrate.SimpleDataRowExpressionEvaluator;
public class DataForChartTag {
public static IDataRowExpressionEvaluator getChartData(){
String[] set = { "cat-1", "val-1" };
Object[][] data = {
{
"New York",
"Boston",
"Chicago",
"San Francisco",
"Dallas"
},
{
new Double(54.65),
new Double(21.2),
new Double(75.95),
new Double(91.28),
new Double(37.43)
}
};
return new SimpleDataRowExpressionEvaluator( set, data);
}
}
Hope this helps.
Jason0 -
Hi jason,
Thanks alot for help.
everything is working fine.....
Hope, u will help in same manner for futher my Queries........
Because I got the project in which we hav to use BIRT chart
And this is my First project.
So your help is realy helpful to me
mani0
Categories
- All Categories
- 111 Developer Announcements
- 49 Articles
- 102 General Questions
- 123 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 898 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 124 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 1 XM Fax