JFreeChart for JSP pages to draw the Line Chart

A free public discussion forum for the JFreeChart class library.

JFreeChart for JSP pages to draw the Line Chart

Postby newJavaUser » Fri Mar 24, 2006 9:23 am

Hello everyone,

How to use JFreeChart using JSP pages?
I want to generate the Line chart for the data retrieved from the database
in the JSP pages.
How this can be accomplish?

Thanks in advance.

Regards,
Varsha
newJavaUser
 
Posts: 1
Joined: Fri Mar 24, 2006 9:17 am

Postby ash_bhalgat2003 » Fri Mar 24, 2006 11:05 am

i too want to do the same , but like to draw pie chart using data frm database........
u can use applet to draw chart , write applet class n use this class in jsp page via jsp plugin........

jsp code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Using jsp:plugin</TITLE>
<LINK REL=STYLESHEET
HREF="JSP-Styles.css"
TYPE="text/css">
</HEAD>
<BODY>
<TABLE BORDER=5 ALIGN="CENTER">
<TR><TH CLASS="TITLE">
Using jsp:plugin</TABLE>
<P>
<CENTER>
<jsp:plugin type="applet"
code="trygod.jfr.class" codebase = "defaultroot\WEB-INF\classes"
width="475" height="350">

</jsp:plugin>
</CENTER>
</BODY>
</HTML>

applet class

import java.awt.*;
import java.applet.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.data.*;
import org.jfree.data.general.*;


public class JFreeChartApplet extends Applet {
JFreeChart piechart;
public void init()
{
setBackground(Color.cyan);
}

public void start() {
DefaultPieDataset pds = new DefaultPieDataset();
pds.setValue("Yes",new Double(30));
pds.setValue("No",new Double(50));
pds.setValue("Can't say!",new Double(20));


piechart = ChartFactory.createPieChart("Result.",pds,true,true,true);

}

public void paint(Graphics g) {
if ( piechart!=null ) {
piechart.draw( (Graphics2D)g,getBounds());
}
}

public void destroy(){
}

}
ash_bhalgat2003
 
Posts: 4
Joined: Wed Mar 22, 2006 9:41 am

i think servlet is better!

Postby Rainpoem » Sat Mar 25, 2006 6:39 am

you can write a servlet bean to generate a picture,and used by jsp page!
Rainpoem
 
Posts: 3
Joined: Sat Mar 25, 2006 6:31 am


Return to JFreeChart - General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot], Yahoo [Bot] and 4 guests