Using JFree Chart with JHTML

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Dhiraj Narula

Using JFree Chart with JHTML

Post by Dhiraj Narula » Tue Jul 02, 2002 10:36 pm

Hi ,
I am using JHTML and want to use the JFREE charts to display the charts on the Pages.
Can anybody let me know the way how to use JFREE charts with the JHTMLs.

David Gilbert

Re: Using JFree Chart with JHTML

Post by David Gilbert » Wed Jul 03, 2002 6:34 am

It's not something I can help with, since I know nothing about JHTML. Anyone else?

Regards,

DG.

jim moore

Re: Using JFree Chart with JHTML

Post by jim moore » Wed Jul 03, 2002 3:11 pm

anytime you want to show a chart on the web it will be the exact same procedure:

make a servlet that generates your chart as a jpeg, gif, or png (be sure to set the something along the lines of (only doGet method shown):

public void doGet(HttpServletRequest request, HttpServletResponse response) {

//change these as appropriate
int width = 500;
int height =500;

JFreeChart chart = generateChart(request); //need to fill in this method yourself

ByteArrayOutputStream baos = new ByteArrayOutputStream();
ChartUtilities.writeChartAsJPEG(baos, chart, width, height);
response.setContentType ("image/jpeg");
response.setContentLength(baos.size());
baos.writeTo(out);
}

then include an img tag in your jhtml page with the url of your servlet as the src attribute.

jim moore

Re: Using JFree Chart with JHTML

Post by jim moore » Wed Jul 03, 2002 3:14 pm

the second paragraph should be:

make a servlet that generates your chart as a jpeg, gif, or png (be sure to set the content type and content length headers). something along the lines of (only doGet method shown):

Dhiraj Narula

Re: Using JFree Chart with JHTML

Post by Dhiraj Narula » Wed Jul 03, 2002 7:19 pm

I am not using the servlets with the JHTMLs. Bean shells scripts are used with the ATG Dynamo Server. I am not able to instantiate the classes as we do in JSP and Servelts .
If somebody is having any idea about that then that would be really helpful. we are having DynamoHttpRequest and resonse object only .

Locked