deploy BIRT chart on web application

Options
mani
edited February 11, 2022 in Analytics #1
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

Comments

  • JasonW
    edited December 31, 1969 #2
    Options
    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 />
    Jason
  • mani
    edited December 31, 1969 #3
    Options
    Hi jason,
    I got the examples to show chart on webpage.
    but in that they r using .chart file to create the chart i.e SamplePie.chart file
    So how i create this file.
    Is BIRT chart Engine provides any XML schema for that

    thanks in advance,
    mani
  • JasonW
    edited December 31, 1969 #4
    Options
    You can use the chart builder or the api to create the xml chart file.

    Jason
  • mani
    edited December 31, 1969 #5
    Options
    Hi,jason
    Thanks for your reply.
    Will u tell me which Api i should i use to generate the chart in XML formate.
    because i didnt found any help for this on google.
    will u provide me any example with all import api
    please help me.......

    thanks
    mani
  • JasonW
    edited December 31, 1969 #6
    Options
    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" ));

    Jason
  • mani
    edited December 31, 1969 #7
    Options
    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..........

    mani
  • JasonW
    edited December 31, 1969 #8
    Options
    Mani,

    Where you able to get the example in the downloaded I pointed you to, to work?
    It is the ChartWebWiz project and the chart file is the SamplePie.chart which is displayed using the index.jsp page in that project.

    Jason
  • mann
    edited December 31, 1969 #9
    Options
    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
    mani
  • JasonW
    edited December 31, 1969 #10
    Options
    Mani,

    Which example are you using to create the chart? Can you post it?

    Jason
  • mani
    edited December 31, 1969 #11
    Options
    hi jason
    here is my code.
    In this I hav Category.java file which create the chart and give me chart file as Category.chart
    i m passing this chart file to index123.jsp file which uses BIRT chart tag library.

    waiting for your reply.............

    thanks
    mani
  • JasonW
    edited December 31, 1969 #12
    Options
    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"&gt;
    <%@ 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.

    Jason
  • mani
    edited December 31, 1969 #13
    Options
    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

    mani