views:

517

answers:

1

Hi All:
My requirement is need to display 2 barchart and 3 trendchart in single page. For that, i have used JFreeChart API and sending the image in bytearray format through response. Its working fine for single image. How do i merge all 5 charts and send that through response?. Please help me.

Sample Code:

            chartTypeCode="1";
            chartTypeDesc="Order Line Status Bar Chart";
            chart = createChart(defaultFromDate,defaultToDate,chartTypeCode);
            chartImage[0] = chart.createBufferedImage(600, 400);

   chartTypeCode="2";
   chartTypeDesc="Order Sent To OMS Trend Chart";
   chart = createTrendChart(defaultFromDate,defaultToDate,chartTypeCode);
   chartImage[1] = chart.createBufferedImage(600, 400);

   chartTypeCode="3";
   chartTypeDesc="Shipment Trend Chart";
   chart = createTrendChart(defaultFromDate,defaultToDate,chartTypeCode);
   chartImage[2] = chart.createBufferedImage(600, 400);

   chartTypeCode="4";
   chartTypeDesc="Return Trend Chart";
   chart = createTrendChart(defaultFromDate,defaultToDate,chartTypeCode);
   chartImage[3] = chart.createBufferedImage(600, 400);

   chartTypeCode="5";
   chartTypeDesc="PSP Email Bar Chart";
   chart = createChart(defaultFromDate,defaultToDate,chartTypeCode);
   chartImage[4] = chart.createBufferedImage(600, 400);
A: 

I don't know that you can send many charts as they are individual images. You should consider instead saving each chart to your server using servlet utilities and then using JFreeChart's servlet to query each image. This will allow you to use standard image tags which means you can use text html with maps (for tooltips) and css.

See my answer to a similar question for more info.

Adam