1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
resultSet = statement.executeQuery(Requete);
while (resultSet.next())
{
rte_name = resultSet.getString(1);
int qty = Integer.decode(resultSet.getString(2));
dataset.addValue(qty, rte_name, "J1");
dataset.addValue(qty, rte_name, "J2");
}
// Create the chart object
CategoryAxis categoryAxis = new CategoryAxis("");
ValueAxis valueAxis = new NumberAxis("");
StackedBarRenderer renderer = new StackedBarRenderer();
renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator("LotList.jsp","techno","jalon"));
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
Plot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
chart.setBackgroundPaint(java.awt.Color.white);
//Write the chart image to the temporary directory
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
String filename = null;
filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, req.getSession());
System.out.println("Filename: "+filename);
//OutputStream myout = resp.getOutputStream();
//ChartUtilities.writeChartAsPNG(myout, chart, 600, 400);
// Write the image map to the PrintWriter
//ChartUtilities.writeChartAsPNG(out, chart, 600, 400);
//out.println(resp.getWriter());
ChartUtilities.writeImageMap(out, filename, info, true);
out.println("<img src="+filename+" width=500 height=300 border=0 usemap=#"+filename+">");
System.out.println("Fin");
out.flush();
out.close(); |
Partager