[JFreeChart] afficher plusieurs PieChart dans une seule page web
Bonjour,
J'ai un projet web qui utilise la bibliothèque JFreeChart.jarhttp://sourceforge.net/project/showf...group_id=15494
et qui fonctionne très bien qui permet d'afficher une PieChart dans une page web
voila le code
myDemoChart.java sous une package hello
Code:
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
|
import java.io.*;
import org.jfree.chart.*;
import org.jfree.data.*;
public class myDemoChart {
public myDemoChart() {}
private DefaultPieDataset getDataSet() throws IOException
{
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Utilisé", 60);
dataset.setValue("Libre ", 40);
return dataset;
}
public void getchart(OutputStream resp) throws IOException
{
DefaultPieDataset data = getDataSet();
JFreeChart chart = ChartFactory.createPieChart("PIE CHART",data, true, false, false);
try {
ChartUtilities.writeChartAsJPEG(resp, 100, chart, 700, 500, null);
}
catch (Exception e) {
e.printStackTrace();
}
}
} |
et index.jsp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
<%@ page import="hello.myDemoChart"%>
<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
</head>
<body>
<%
myDemoChart myDemoChart=new myDemoChart();
response.setContentType("image/jpeg");
myDemoChart.getchart(response.getOutputStream());
%>
</body>
</html> |
le programme fonctionne très bien mais le problème est que je peux rien ni afficher ni écrire ni ajouter une autre PieChart avec la première
Ma question est comment je peux ajouter d'autres insertions dans la page index.jsp avec l'image PieChart
merci