1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{
//response.setContentType("text/html");
//PrintWriter out=response.getWriter();
//out.println("<p>hello</p>");
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(120000.0, "Produit 1", "2000");
dataset.addValue(550000.0, "Produit 1", "2001");
dataset.addValue(180000.0, "Produit 1", "2002");
dataset.addValue(270000.0, "Produit 2", "2000");
dataset.addValue(600000.0, "Produit 2", "2001");
dataset.addValue(230000.0, "Produit 2", "2002");
dataset.addValue(90000.0, "Produit 3", "2000");
dataset.addValue(450000.0, "Produit 3", "2001");
dataset.addValue(170000.0, "Produit 3", "2002");
JFreeChart barChart = ChartFactory.createBarChart("Evolution des ventes", "","Unité vendue", dataset, PlotOrientation.VERTICAL, true, true, false);
ServletOutputStream out = response.getOutputStream();
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(out, barChart, 400, 300);
} |
Partager