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.

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">
<TITLE>Using jsp:plugin</TITLE>
Using jsp:plugin</TABLE>
<jsp:plugin type="applet"
code="trygod.jfr.class" codebase = "defaultroot\WEB-INF\classes"
width="475" height="350">


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()

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(){

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!
Posts: 3
Joined: Sat Mar 25, 2006 6:31 am

Return to JFreeChart - General

Who is online

Users browsing this forum: Bing [Bot] and 8 guests