IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

AWT/Swing Java Discussion :

>Problème de courbes


Sujet :

AWT/Swing Java

  1. #1
    Débutant  
    Inscrit en
    Mars 2008
    Messages
    1 123
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 1 123
    Points : 170
    Points
    170
    Par défaut >Problème de courbes
    bonsoir à tous
    je veux réaliser comme les courbes qui figurent dans le lien suivant

    http://www.java2s.com/Code/Java/Char...ontheright.htm

    mais le problème est le code dans ce lien ne correspond pas aux courbes affichées

    Merci

  2. #2
    Débutant  
    Inscrit en
    Mars 2008
    Messages
    1 123
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 1 123
    Points : 170
    Points
    170
    Par défaut
    voici le code:

    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
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
     
    import java.awt.Font;   
     
    import javax.swing.JPanel;   
     
    import org.jfree.chart.ChartPanel;   
    import org.jfree.chart.JFreeChart;   
    import org.jfree.chart.axis.CategoryAxis;   
    import org.jfree.chart.axis.CategoryLabelPositions;   
    import org.jfree.chart.axis.NumberAxis;   
    import org.jfree.chart.axis.ValueAxis;   
    import org.jfree.chart.labels.StandardCategoryToolTipGenerator;   
    import org.jfree.chart.plot.CategoryPlot;   
    import org.jfree.chart.plot.CombinedRangeCategoryPlot;   
    import org.jfree.chart.plot.PlotOrientation;   
    import org.jfree.chart.renderer.category.BarRenderer;   
    import org.jfree.chart.renderer.category.LineAndShapeRenderer;   
    import org.jfree.data.category.CategoryDataset;   
    import org.jfree.data.category.DefaultCategoryDataset;   
    import org.jfree.ui.ApplicationFrame;   
    import org.jfree.ui.RefineryUtilities;   
     
    /**  
     * A demo for the {@link CombinedRangeCategoryPlot} class.  
     */   
    public class CombinedCategoryPlotDemo2 extends ApplicationFrame {   
     
        /**  
         * Creates a new demo instance.  
         *  
         * @param title  the frame title.  
         */   
        public CombinedCategoryPlotDemo2(String title) {   
     
            super(title);   
            ChartPanel chartPanel = new ChartPanel(createChart());   
            chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));   
            setContentPane(chartPanel);   
     
        }   
     
        /**  
         * Creates a dataset.  
         *  
         * @return A dataset.  
         */   
        public static CategoryDataset createDataset1() {   
     
            DefaultCategoryDataset result = new DefaultCategoryDataset();   
     
            // row keys...   
            String series1 = "First";   
            String series2 = "Second";   
     
            // column keys...   
            String type1 = "Type 1";   
            String type2 = "Type 2";   
            String type3 = "Type 3";   
            String type4 = "Type 4";   
            String type5 = "Type 5";   
            String type6 = "Type 6";   
            String type7 = "Type 7";   
            String type8 = "Type 8";   
     
            result.addValue(1.0, series1, type1);   
            result.addValue(4.0, series1, type2);   
            result.addValue(3.0, series1, type3);   
            result.addValue(5.0, series1, type4);   
            result.addValue(5.0, series1, type5);   
            result.addValue(7.0, series1, type6);   
            result.addValue(7.0, series1, type7);   
            result.addValue(8.0, series1, type8);   
     
            result.addValue(5.0, series2, type1);   
            result.addValue(7.0, series2, type2);   
            result.addValue(6.0, series2, type3);   
            result.addValue(8.0, series2, type4);   
            result.addValue(4.0, series2, type5);   
            result.addValue(4.0, series2, type6);   
            result.addValue(2.0, series2, type7);   
            result.addValue(1.0, series2, type8);   
     
            return result;   
     
        }   
     
        /**  
         * Creates a dataset.  
         *  
         * @return A dataset.  
         */   
        public static CategoryDataset createDataset2() {   
     
            DefaultCategoryDataset result = new DefaultCategoryDataset();   
     
            // row keys...   
            String series1 = "Third";   
            String series2 = "Fourth";   
     
            // column keys...   
            String sector1 = "Sector 1";   
            String sector2 = "Sector 2";   
            String sector3 = "Sector 3";   
            String sector4 = "Sector 4";   
     
            result.addValue(11.0, series1, sector1);   
            result.addValue(14.0, series1, sector2);   
            result.addValue(13.0, series1, sector3);   
            result.addValue(15.0, series1, sector4);   
     
            result.addValue(15.0, series2, sector1);   
            result.addValue(17.0, series2, sector2);   
            result.addValue(16.0, series2, sector3);   
            result.addValue(18.0, series2, sector4);   
     
            return result;   
     
        }   
     
        /**  
         * Creates a chart.  
         *  
         * @return A chart.  
         */   
        private static JFreeChart createChart() {   
     
            CategoryDataset dataset1 = createDataset1();   
            CategoryAxis domainAxis1 = new CategoryAxis("Class 1");   
            domainAxis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45);   
            domainAxis1.setMaximumCategoryLabelWidthRatio(5.0f);   
            LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();   
            renderer1.setBaseToolTipGenerator(   
                new StandardCategoryToolTipGenerator()   
            );   
            CategoryPlot subplot1 = new CategoryPlot(   
                dataset1, domainAxis1, null, renderer1   
            );   
            subplot1.setDomainGridlinesVisible(true);   
     
            CategoryDataset dataset2 = createDataset2();   
            CategoryAxis domainAxis2 = new CategoryAxis("Class 2");   
            domainAxis2.setCategoryLabelPositions(CategoryLabelPositions.UP_45);   
            domainAxis2.setMaximumCategoryLabelWidthRatio(5.0f);   
            BarRenderer renderer2 = new BarRenderer();   
            renderer2.setBaseToolTipGenerator(   
                new StandardCategoryToolTipGenerator()   
            );   
            CategoryPlot subplot2 = new CategoryPlot(   
                dataset2, domainAxis2, null, renderer2   
            );   
            subplot2.setDomainGridlinesVisible(true);   
     
            ValueAxis rangeAxis = new NumberAxis("Value");   
            CombinedRangeCategoryPlot plot    
                = new CombinedRangeCategoryPlot(rangeAxis);   
            plot.add(subplot1, 3);   
            plot.add(subplot2, 2);   
            plot.setOrientation(PlotOrientation.HORIZONTAL);   
     
            JFreeChart result = new JFreeChart(   
                "Combined Range Category Plot Demo",   
                new Font("SansSerif", Font.BOLD, 12),   
                plot,   
                true   
            );   
            return result;   
     
        }   
     
        /**  
         * Creates a panel for the demo (used by SuperDemo.java).  
         *   
         * @return A panel.  
         */   
        public static JPanel createDemoPanel() {   
            JFreeChart chart = createChart();   
            return new ChartPanel(chart);   
        }   
     
        /**  
         * Starting point for the demonstration application.  
         *  
         * @param args  ignored.  
         */   
        public static void main(String[] args) {   
     
            String title = "Combined Category Plot Demo 2";   
            CombinedCategoryPlotDemo2 demo = new CombinedCategoryPlotDemo2(title);   
            demo.pack();   
            RefineryUtilities.centerFrameOnScreen(demo);   
            demo.setVisible(true);   
     
        }   
     
    }

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème graphique courbe X = Y
    Par Linono dans le forum VB.NET
    Réponses: 2
    Dernier message: 23/03/2009, 16h50
  2. Problème de courbe
    Par Roxy841 dans le forum Excel
    Réponses: 2
    Dernier message: 12/12/2008, 16h47
  3. Réponses: 1
    Dernier message: 15/10/2008, 11h07
  4. probléme de+courbe MSchart
    Par nones dans le forum VB 6 et antérieur
    Réponses: 0
    Dernier message: 27/12/2007, 10h46
  5. Problème graphique courbe histo
    Par CélineM dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 05/06/2007, 19h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo