Bonjour,

Je viens ici pour trouver de l'aide car je me suis intéressé à JFreeCharts afin de pouvoir généré un graphique à barre horizontal mais scindé en plusieurs morceaux.

Déjà trouver le bon modèle n'est pas évident mais cela n'est pas le but de ma discussion.

J'ai téléchargé l'api et importer les jar : jcommon-1.0.15.jar et jfreecharts-1.0.12.jar.

Lorsque je tape une application toute faite sur le net comme celle-ci :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
 
package vue;
 
import java.awt.Color;
import java.awt.Font;
import java.text.DecimalFormat;
 
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.NumberTickUnit;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.IntervalBarRenderer;
import org.jfree.data.category.DefaultIntervalCategoryDataset;
import org.jfree.ui.TextAnchor;
 
/**
 * An interval bar chart.
 *
 * @author Jeremy Bowman
 */
public class IntervalBarChartsDemo1 {
 
    /** The categories. */
    private static final String[] CATEGORIES = {"1", "3", "5", "10", "20"};
 
    /** The label font. */
    private static Font labelFont = null;
 
    /** The title font. */
    private static Font titleFont = null;
 
    /** The chart. */
    private JFreeChart chart = null;
 
    static {
        labelFont = new Font("Helvetica", Font.PLAIN, 10);
        titleFont = new Font("Helvetica", Font.BOLD, 14);
    }
 
    /**
     * Creates a new demo.
     */
    public IntervalBarChartsDemo1() {
 
        DefaultIntervalCategoryDataset data = null;
        final double[][] lows = {{-.0315, .0159, .0306, .0453, .0557}};
        final double[][] highs = {{.1931, .1457, .1310, .1163, .1059}};
        data = new DefaultIntervalCategoryDataset(lows, highs);
        data.setCategoryKeys(CATEGORIES);
 
        final String title = "Strategie Sicherheit";
        final String xTitle = "Zeitraum (in Jahren)";
        final String yTitle = "Performance";
        final CategoryAxis xAxis = new CategoryAxis(xTitle);
        xAxis.setLabelFont(titleFont);
        xAxis.setTickLabelFont(labelFont);
        xAxis.setTickMarksVisible(false);
        final NumberAxis yAxis = new NumberAxis(yTitle);
        yAxis.setLabelFont(titleFont);
        yAxis.setTickLabelFont(labelFont);
        yAxis.setRange(-0.2, 0.40);
        final DecimalFormat formatter = new DecimalFormat("0.##%");
        yAxis.setTickUnit(new NumberTickUnit(0.05, formatter));
 
        final IntervalBarRenderer renderer = new IntervalBarRenderer();
        renderer.setSeriesPaint(0, new Color(51, 102, 153));
//        renderer.setLabelGenerator(new IntervalCategoryLabelGenerator());
        renderer.setItemLabelsVisible(true);
        renderer.setItemLabelPaint(Color.white);
        final ItemLabelPosition p = new ItemLabelPosition(
            ItemLabelAnchor.CENTER, TextAnchor.CENTER
        );
        renderer.setPositiveItemLabelPosition(p);
 
        final CategoryPlot plot = new CategoryPlot(data, xAxis, yAxis, renderer);
        plot.setBackgroundPaint(Color.lightGray);
        plot.setOutlinePaint(Color.white);
        plot.setOrientation(PlotOrientation.VERTICAL);
 
        this.chart = new JFreeChart(title, titleFont, plot, false);
        this.chart.setBackgroundPaint(Color.white);
    }
 
    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // * http://www.object-refinery.com/jfreechart/guide.html                     *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    * 
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************
 
    /**
     * Returns the chart.
     *
     * @return the chart.
     */
    public JFreeChart getChart() {
        return this.chart;
    }
 
    /**
     * Starting point for the demo.
     *
     * @param args  ignored.
     */
    public static void main(final String[] args) {
        final IntervalBarChartsDemo1 sample = new IntervalBarChartsDemo1();
        final JFreeChart chart = sample.getChart();
        final ChartFrame frame = new ChartFrame("Interval Bar Chart Demo", chart);
        frame.pack();
        frame.setVisible(true);
    }
}
Lorsque je fais RunAS Java Application, rien ne se passe aucune fenêtre ne s'ouvre ni même de console.

Ai-je oublier quelque chose ?

Merci d'avance pour votre aide