Page taking longer time after adding charts

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
goliraja
Posts: 5
Joined: Mon Jun 21, 2004 7:44 pm

Page taking longer time after adding charts

Post by goliraja » Mon Jun 28, 2004 6:30 pm

Hi,
When the users clicks on a certain link...i am creating a chart, saving it to a particular directory and then displaying them.
But after I have done this my page(jsp) is taking a long time to display.
Actually I do not want to create a file...can I have the chart displayed directly..

Thanks

richard_atkinson
Posts: 115
Joined: Fri Mar 14, 2003 3:13 pm
Location: London, England
Contact:

Not writing image to disk

Post by richard_atkinson » Mon Jun 28, 2004 7:15 pm

There are methods in the ChartUtilities class for writing directly to an OutputStream - like response.getOutputStream(). However I would consider add some logging messages to benchmark your code to confirm where the bottleneck is before doing too much work. You may find the cost of writing the chart to disk and re-retrieving it is small compared to, for example, database access.

Regards,
Richard...

angel
Posts: 899
Joined: Thu Jan 15, 2004 12:07 am
Location: Germany - Palatinate

Post by angel » Tue Jun 29, 2004 7:52 am

Do you reuse the saved images multiple times?

If you doing so, then you won't get any benefit from creating them directly.
If you create, store, retrieve and delete then every time then you might actually benefit from writing directly to outpustream.

goliraja
Posts: 5
Joined: Mon Jun 21, 2004 7:44 pm

any exam

Post by goliraja » Tue Jun 29, 2004 7:35 pm

Yes I am creating, storing, retrieving and deleting it...do you have any example which use a output stream...
I am creating my chart in the jsp...so how would i display the chart?

Thanks

angel
Posts: 899
Joined: Thu Jan 15, 2004 12:07 am
Location: Germany - Palatinate

Post by angel » Wed Jun 30, 2004 8:32 am

All you have to do is to fill the response of the servelt with the chart

Code: Select all

ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, 200, a);

Locked