Générer un graphique

Fermé
linguere5 Messages postés 6 Date d'inscription jeudi 24 avril 2014 Statut Membre Dernière intervention 8 mai 2014 - 8 mai 2014 à 16:05
KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 - 8 mai 2014 à 17:46
Bonjour je veux générer un graphique avec jfreechart. j'ai télechargé les jars, voici mon code :
package graphique;

package graphique;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.ChartFactory;
import org.jfree.data.general.DefaultPieDataset;
import java.io.File;

public class MaGraphique {
public static void main(String[] args) {
DefaultPieDataset pie = new DefaultPieDataset();
pie.setValue("Mamadou", new Integer(55));
pie.setValue("Fallou", new Integer(25));
pie.setValue("Issa", new Integer(10));
pie.setValue("Demba", new Integer(10));

JFreeChart chart = ChartFactory.createPieChart
("Pourcentage par personne", pie,true,true,false);

try {
ChartUtilities.saveChartAsJPEG(new File("C:/Graphique.jpg"), chart, 450, 400);
} catch (Exception e) {
System.out.println("Probleme");
}
}
}

Mais il me génére cettre erreur
Probleme.
A voir également:

1 réponse

KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 3 015
8 mai 2014 à 17:46
Bonjour,

Ne masques pas ton exception avec ton
System.out.println("Probleme");
sinon on ne peut pas savoir quel est le problème en question.

Fais plutôt un
e.printStackTrace();
et indiques nous l'erreur qu'il t'affiche.
0