problem in accesing dynamic data and no image is displaying on the browser
pradeep kumar <[email protected]> Fri, 22 Sep 2006 10:25:59 -0700 (PDT)
| Newsgroups | gmane.comp.krysalis.jcharts.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============1351362725==
Content-Type: multipart/alternative; boundary="0-518703348-1158945959=:40928"
Content-Transfer-Encoding: 7bit
--0-518703348-1158945959=:40928
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
i want to create bar chart fom a database table=20
i written the below code but it is not displaying any image plz help me=
very urgent
=20
=20
=20
=20
=20
/**********************************************************************=
*************************
* File Info: $Id: BarChartServlet.java,v 1.5 2003/04/19 01:41:27 nathani=
el_auvil Exp $
* Copyright (C) 2002
* Author: Nathaniel G. Auvil
* Contributor(s):
*
* Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved.
*
* Redistribution and use of this software and associated documentation (=
"Software"), with or
* without modification, are permitted provided that the following condit=
ions are met:
*
* 1. Redistributions of source code must retain copyright statements and=
notices.
* Redistributions must also contain a copy of this document.
*
* 2. Redistributions in binary form must reproduce the above copyright n=
otice, this list of
* conditions and the following disclaimer in the documentation and/or o=
ther materials
* provided with the distribution.
*
* 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endo=
rse or promote
* products derived from this Software without prior written permission =
of Nathaniel G.
* Auvil. For written permission, please contact nathaniel_auvil@users.=
sourceforge.net
*
* 4. Products derived from this Software may not be called "jCharts" nor=
may "jCharts" appear
* in their names without prior written permission of Nathaniel G. Auvil=
. jCharts is a
* registered trademark of Nathaniel G. Auvil.
*
* 5. Due credit should be given to the jCharts Project (http://jcharts.s=
ourceforge.net/).
*
* THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS =
IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IM=
PLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. =
IN NO EVENT SHALL
* jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDE=
NTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINE=
SS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STR=
ICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE =
OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
************************************************************************=
************************/
package com.objectplanet.chart.testing;
=20
import org.jCharts.axisChart.AxisChart;
import org.jCharts.axisChart.customRenderers.axisValue.renderers.ValueLab=
elPosition;
import org.jCharts.axisChart.customRenderers.axisValue.renderers.ValueLab=
elRenderer;
import org.jCharts.chartData.AxisChartDataSet;
import org.jCharts.chartData.DataSeries;
import org.jCharts.chartData.interfaces.IAxisDataSeries;
import org.jCharts.encoders.ServletEncoderHelper;
import org.jCharts.properties.*;
import org.jCharts.properties.util.ChartFont;
import org.jCharts.types.ChartType;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import java.awt.*;
import java.io.IOException;
import java.io.*;
import java.util.*;
public class barcheck extends HttpServlet {
//---all of my charts serviced by this Servlet will have the same pro=
perties.
private BarChartProperties barChartProperties;
=20
//---all of my charts serviced by this Servlet will have the same pro=
perties.
protected LegendProperties legendProperties;
protected AxisProperties axisProperties;
protected ChartProperties chartProperties;
=20
protected int width =3D 550;
protected int height =3D 360;
=20
=20
/********************************************************************=
**************************
*
********************************************************************=
**************************/
public void init() {
this.legendProperties =3D new LegendProperties();
this.chartProperties =3D new ChartProperties();
this.axisProperties =3D new AxisProperties( false );
ChartFont axisScaleFont =3D new ChartFont( new Font( "Georgia Neg=
reta cursiva", Font.PLAIN, 13 ), Color.black );
axisProperties.getXAxisProperties().setScaleChartFont( axisScaleF=
ont );
axisProperties.getYAxisProperties().setScaleChartFont( axisScaleF=
ont );
=20
ChartFont axisTitleFont =3D new ChartFont( new Font( "Arial Narro=
w", Font.PLAIN, 14 ), Color.black );
axisProperties.getXAxisProperties().setTitleChartFont( axisTitleF=
ont );
axisProperties.getYAxisProperties().setTitleChartFont( axisTitleF=
ont );
=20
DataAxisProperties dataAxisProperties =3D (DataAxisProperties) ax=
isProperties.getYAxisProperties();
=20
try {
dataAxisProperties.setUserDefinedScale( -3000, 3000 );
} catch( PropertyException propertyException ) {
propertyException.printStackTrace();
}
=20
dataAxisProperties.setRoundToNearest( 2 );
=20
ChartFont titleFont =3D new ChartFont( new Font( "Georgia Negreta=
cursiva", Font.PLAIN, 14 ), Color.black );
this.chartProperties.setTitleFont( titleFont );
=20
this.barChartProperties =3D new BarChartProperties();
=20
ValueLabelRenderer valueLabelRenderer =3D new ValueLabelRenderer(=
false, false, true, -1 );
valueLabelRenderer.setValueLabelPosition( ValueLabelPosition.ON_T=
OP );
valueLabelRenderer.useVerticalLabels( false );
barChartProperties.addPostRenderEventListener( valueLabelRenderer=
);
=20
}
=20
=20
/********************************************************************=
**************************
*
********************************************************************=
**************************/
public void service( HttpServletRequest req, HttpServletResponse http=
ServletResponse ) throws ServletException, IOException {
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDri=
ver());
Connection con;
con =3D DriverManager.getConnection("jdbc:oracle:thin:@127.0.=
0.1:1521:BSL","scott","tiger");
System.out.println(con);
Statement stmt =3D con.createStatement();
ResultSet rs =3D stmt.executeQuery("select * from account");
ResultSetMetaData rmd=3Drs.getMetaData();
String xAxisTitle =3D rmd.getColumnLabel(1);
String yAxisTitle =3D rmd.getColumnLabel(2);
=20
=20
String[] xAxisLabels=3Dnew String[20];
PrintWriter out=3DhttpServletResponse.getWriter();
int i=3D0;
double[][] data =3D new double[20][20];
int j=3D0;
while(rs.next())
{ =20
xAxisLabels[i]=3D rs.getString(2);=20
data[i][0]=3Drs.getDouble(1) ;
i++;
} =20
String title =3D "Micro$oft At Work";
IAxisDataSeries dataSeries =3D new DataSeries( xAxisLabels, x=
AxisTitle, yAxisTitle, title );
=20
=20
String[] legendLabels =3D {"Bugs"};
Paint[] paints =3D new Paint[]{Color.yellow};
dataSeries.addIAxisPlotDataSet( new AxisChartDataSet( data, l=
egendLabels, paints, ChartType.BAR, this.barChartProperties ) );
=20
AxisChart axisChart =3D new AxisChart( dataSeries, this.chart=
Properties, this.axisProperties, this.legendProperties, this.width, this.=
height );
ServletEncoderHelper.encodeJPEG13( axisChart, 1.0f, httpServl=
etResponse );
} catch( Throwable throwable ) {
//HACK do your error handling here...
throwable.printStackTrace();
}
}
}
=09
---------------------------------
All-new Yahoo! Mail - Fire up a more powerful email and get things done =
faster.
--0-518703348-1158945959=:40928
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
<div>i want to create bar chart fom a database table </div> <div>i writt=
en the below code but it is not displaying any image plz help me very urg=
ent</div> <div> </div> <div> </div> <div> </div> <div>=
</div> <div> </div> <div>/**********************************=
*************************************************************<BR> * =
File Info: $Id: BarChartServlet.java,v 1.5 2003/04/19 01:41:27 nathaniel_=
auvil Exp $<BR> * Copyright (C) 2002<BR> * Author: Nathaniel G.=
Auvil<BR> * Contributor(s):<BR> *<BR> * Copyright 2002 (C=
) Nathaniel G. Auvil. All Rights Reserved.<BR> *<BR> * Redistri=
bution and use of this software and associated documentation ("Software")=
, with or<BR> * without modification, are permitted provided that th=
e following conditions are met:<BR> *<BR> * 1. Redistributions =
of source code must retain copyright statements and notices.<BR> * &=
nbsp;Redistributions must also contain
a copy of this document.<BR> *<BR> * 2. Redistributions in bin=
ary form must reproduce the above copyright notice, this list of<BR> =
;* conditions and the following disclaimer in the documentation and=
/or other materials<BR> * provided with the distribution.<BR>&=
nbsp;*<BR> * 3. The name "jCharts" or "Nathaniel G. Auvil" must not =
be used to endorse or promote<BR> * products derived from this=
Software without prior written permission of Nathaniel G.<BR> * &nb=
sp;Auvil. For written permission, please contact <A href=3D"mailto:=
[email protected]">[email protected].=
net</A><BR> *<BR> * 4. Products derived from this Software may =
not be called "jCharts" nor may "jCharts" appear<BR> * in thei=
r names without prior written permission of Nathaniel G. Auvil. jCharts i=
s a<BR> * registered trademark of Nathaniel G. Auvil.<BR> =
;*<BR> * 5. Due credit should be
given to the jCharts Project (<A href=3D"http://jcharts.sourceforge.net/=
">http://jcharts.sourceforge.net/</A>).<BR> *<BR> * THIS SOFTWA=
RE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY<B=
R> * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,=
THE IMPLIED WARRANTIES OF<BR> * MERCHANTABILITY AND FITNESS FOR A P=
ARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL<BR> * jCha=
rts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, S=
PECIAL,<BR> * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NO=
T LIMITED TO, PROCUREMENT OF<BR> * SUBSTITUTE GOODS OR SERVICES; LOS=
S OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<BR> * HOWEVER =
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILI=
TY, OR TORT<BR> * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY=
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN<BR> * IF ADVISED OF THE P=
OSSIBILITY OF SUCH
DAMAGE<BR> ********************************************************=
****************************************/</div> <div>package com.objectp=
lanet.chart.testing;</div> <div><BR>import org.jCharts.axisChart.AxisCha=
rt;<BR>import org.jCharts.axisChart.customRenderers.axisValue.renderers.V=
alueLabelPosition;<BR>import org.jCharts.axisChart.customRenderers.axisVa=
lue.renderers.ValueLabelRenderer;<BR>import org.jCharts.chartData.AxisCha=
rtDataSet;<BR>import org.jCharts.chartData.DataSeries;<BR>import org.jCha=
rts.chartData.interfaces.IAxisDataSeries;<BR>import org.jCharts.encoders.=
ServletEncoderHelper;<BR>import org.jCharts.properties.*;<BR>import org.j=
Charts.properties.util.ChartFont;<BR>import org.jCharts.types.ChartType;<=
BR>import java.sql.*;<BR>import javax.servlet.ServletException;<BR>import=
javax.servlet.http.*;<BR>import java.awt.*;<BR>import java.io.IOExceptio=
n;<BR>import java.io.*;<BR>import java.util.*;</div> <div>public class b=
archeck extends HttpServlet
{<BR> //---all of my charts serviced by this Servlet w=
ill have the same properties.<BR> private BarChartPrope=
rties barChartProperties;<BR> <BR> //=
---all of my charts serviced by this Servlet will have the same propertie=
s.<BR> protected LegendProperties legendProperties;<BR>=
protected AxisProperties axisProperties;<BR> &nbs=
p; protected ChartProperties chartProperties;<BR> =
<BR> protected int width =3D 550;<BR>  =
; protected int height =3D 360;<BR> <BR> &nb=
sp; <BR> /*********************************************=
*************************************************<BR> &n=
bsp; *<BR> **************************************=
********************************************************/<BR> =
public void init()
{<BR> this.legendProperties =3D=
new LegendProperties();<BR> th=
is.chartProperties =3D new ChartProperties();<BR> =
this.axisProperties =3D new AxisProperties( false );<B=
R> ChartFont axisScaleFont =3D =
new ChartFont( new Font( "Georgia Negreta cursiva", Font.PLAIN, 13 ), Col=
or.black );<BR> axisProperties.=
getXAxisProperties().setScaleChartFont( axisScaleFont );<BR> &=
nbsp; axisProperties.getYAxisProperties().setScal=
eChartFont( axisScaleFont );<BR>  =
; <BR> ChartFont axisTitleFont =
=3D new ChartFont( new Font( "Arial Narrow", Font.PLAIN, 14 ), Color.blac=
k );<BR> axisProperties.getXAxi=
sProperties().setTitleChartFont( axisTitleFont
);<BR> axisProperties.getYAxis=
Properties().setTitleChartFont( axisTitleFont );<BR> &nb=
sp; <BR> Data=
AxisProperties dataAxisProperties =3D (DataAxisProperties) axisProperties=
.getYAxisProperties();<BR> <BR>=
try {<BR> &nb=
sp; dataAxisProperties.setUserD=
efinedScale( -3000, 3000 );<BR> =
} catch( PropertyException propertyException ) {<BR> &n=
bsp; propertyException.printSta=
ckTrace();<BR> }<BR>  =
; <BR> &=
nbsp; dataAxisProperties.setRoundToNearest( 2 );<BR> &nb=
sp;
<BR> ChartFont titleFont =3D n=
ew ChartFont( new Font( "Georgia Negreta cursiva", Font.PLAIN, 14 ), Colo=
r.black );<BR> this.chartProper=
ties.setTitleFont( titleFont );<BR> &n=
bsp; <BR> this.barChartProperti=
es =3D new BarChartProperties();<BR> &=
nbsp; <BR> ValueLabelRenderer v=
alueLabelRenderer =3D new ValueLabelRenderer( false, false, true, -1 );<B=
R> valueLabelRenderer.setValueL=
abelPosition( ValueLabelPosition.ON_TOP );<BR> &nb=
sp; valueLabelRenderer.useVerticalLabels( false );<BR> &=
nbsp; barChartProperties.addPostRenderEvent=
Listener( valueLabelRenderer );<BR> &n=
bsp; <BR>
}<BR> <BR> <BR> /*=
*************************************************************************=
********************<BR> *<BR> &=
nbsp; *******************************************************************=
***************************/<BR> public void service( H=
ttpServletRequest req, HttpServletResponse httpServletResponse ) throws S=
ervletException, IOException {<BR> &nb=
sp; try {<BR> =
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()=
);<BR> =
Connection con;<BR> =
con =3D DriverManager.getConnection("jdbc:oracle:thin:@127.0=
.0.1:1521:BSL","scott","tiger");<BR> &=
nbsp;
System.out.println(con);<BR> &n=
bsp; Statement stmt =3D con.createStatement();<BR> =
; ResultSet r=
s =3D stmt.executeQuery("select * from account");<BR> &n=
bsp; ResultSetMetaData rmd=3Drs=
.getMetaData();<BR> =
String xAxisTitle =3D rmd.getColumnLabel(1);<BR> =
String yAxisTitle =
=3D rmd.getColumnLabel(2);<BR> &=
nbsp; <BR> &nb=
sp; <BR>  =
; String[] xAxisLabels=3Dnew String[20];<BR>  =
; PrintWriter
out=3DhttpServletResponse.getWriter();<BR> =
int i=3D0;<BR> &nbs=
p; double[][] data =3D new double[20]=
[20];<BR> &nbs=
p; int j=3D0;<BR> &n=
bsp; while(rs.next())<BR> =
{ <BR> =
&=
nbsp; xAxisLabels[i]=3D rs.getString(2); <BR> &nbs=
p;  =
; data[i][0]=3Drs.getDouble(1) ;<BR> &=
nbsp; i++;<BR=
> }&nbs=
p;
<BR> S=
tring title =3D "Micro$oft At Work";<BR> &nb=
sp; IAxisDataSeries dataSeries =3D new Data=
Series( xAxisLabels, xAxisTitle, yAxisTitle, title );<BR> &nbs=
p; <BR> =
<BR> &n=
bsp; String[] legendLabels =3D =
{"Bugs"};<BR> =
Paint[] paints =3D new Paint[]{Color.yellow};<BR>  =
; dataSeries.addIAxisPlot=
DataSet( new AxisChartDataSet( data, legendLabels, paints, ChartType.BAR,=
this.barChartProperties ) );<BR> &nbs=
p; <BR> =
AxisChart axisChart =3D
new AxisChart( dataSeries, this.chartProperties, this.axisProperties, th=
is.legendProperties, this.width, this.height );<BR> &nbs=
p; ServletEncoderHelper.encodeJ=
PEG13( axisChart, 1.0f, httpServletResponse );<BR>  =
; } catch( Throwable throwable ) {<BR>  =
; //HACK do your error ha=
ndling here...<BR> &=
nbsp; throwable.printStackTrace();<BR>  =
; }<BR> }<BR>}<BR></div><BR><BR><DIV>
<DIV>
<DIV>
<DIV>
<DIV><A href=3D"http://www.flamingtext.com/ymail.html" target=3D_top></A>=
</DIV><A href=3D"http://www.flamingtext.com/ymail.html" target=3D_top></A=
><A href=3D"http://www.flamingtext.com/ymail.html" target=3D_top><IMG alt=
=3D"Image by FlamingText.com" src=3D"http://ymail.flamingtext.com/ymail/2=
005/01/27/flamingtext_com_1106818644_23535.jpg" border=3D0></A><A href=3D=
"http://www.flamingtext.com/ymail.html" target=3D_top></A></DIV></DIV></D=
IV></DIV><p> 
<hr size=3D1><a href=3D"http://us.rd.yahoo.com/evt=3D43256/*http://advi=
sion.webevents.yahoo.com/mailbeta"> All-new Yahoo! Mail </a>- Fire up a m=
ore powerful email and get things done faster.
--0-518703348-1158945959=:40928--
--===============1351362725==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
--===============1351362725==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
jCharts-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jcharts-developers
--===============1351362725==--