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

Composants Java Discussion :

charts


Sujet :

Composants Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Inactif  
    Homme Profil pro
    Inscrit en
    Septembre 2003
    Messages
    570
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Septembre 2003
    Messages : 570
    Par défaut charts
    bonjour tout le monde
    j utilise la biblio chart pour generer des grphiques

    MAIS quand je l'affiche dans un Jpanel il apparait puis disparais sur le champ??!!!
    qu'elle est la cause de ce bug??

    [ Sujet déplacé depuis le forum java par Viena ]
    Les Règles du Forum

  2. #2
    Membre chevronné Avatar de Scorpyosis
    Homme Profil pro
    Inscrit en
    Janvier 2004
    Messages
    365
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2004
    Messages : 365
    Par défaut
    A priori ca peut être plein de chose, rafraichissement graphique....
    donne nous le bout de code problématique stp

  3. #3
    Membre éclairé Avatar de calogerogigante
    Homme Profil pro
    Technicien réseau
    Inscrit en
    Avril 2003
    Messages
    608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : Belgique

    Informations professionnelles :
    Activité : Technicien réseau
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2003
    Messages : 608
    Par défaut
    Si tu parles de jCharts, j'ai eu le même problème au début...

    Alors, même si c'est pas un code 100% parfait, voici une façon de tracer un graphique pour qu'il se repeigne quand il le faut :

    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
    // SwingDemo.java  
     
    import org.jCharts.axisChart.*;
    import org.jCharts.test.*;
    import org.jCharts.types.*;
    import org.jCharts.chartData.*;
    import org.jCharts.nonAxisChart.*;
    import org.jCharts.properties.*;
     
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
     
    public class SwingDemo extends JFrame
    {
    private MonPanel panel;
     
    //*******************************************************************************
    public SwingDemo() throws ChartDataException, PropertyException
      {
      initComponents();
      }
    //********************************************************************************/
    private void initComponents() throws ChartDataException, PropertyException
      {
      setTitle("Test Swing et JCharts");
      setSize( 600, 400 );
      MonPanel panel=new MonPanel();
      panel.setSize( 600, 400 );
      panel.construireUnAxisChart();
     
      getContentPane().add( panel, BorderLayout.CENTER );
      setVisible( true );
     
      addWindowListener( new WindowAdapter()
               {
               public void windowClosing( WindowEvent e )
                  {
                  System.exit( 0 );
                  }
               }
            );
      }
     
    //***********************************************************
      public static void main( String args[] ) throws ChartDataException, PropertyException
      {
      // En tout premier, on place le LookAndFeel
      try {
          UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
          }
      catch (Exception e)
          {
          System.out.println(e.toString());
          }
     
      new SwingDemo();
      }
    }
    et aussi

    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
    import org.jCharts.axisChart.*;
    import org.jCharts.test.*;
    import org.jCharts.types.*;
    import org.jCharts.chartData.*;
    import org.jCharts.nonAxisChart.*;
    import org.jCharts.properties.*;
     
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
     
    public class MonPanel extends JPanel
    {
    // CHAMPS
    AxisChart axisChart;
     
    // Constructeur :
    public MonPanel()
      {
      super(true);
      setBackground(Color.black);
      }
    //**********************************************************************
    public void construireUnAxisChart() throws ChartDataException, PropertyException
      {
      // -----------------------------------------------------------------------------
      String[] xAxisLabels= { "A", "B", "C", "D", "E", "F", "G", "H", "I" };
      String xAxisTitle= "Temps";
      String yAxisTitle= "Rendement";
      String title=      "Joli graphe";
      DataSeries dataSeries = new DataSeries( xAxisLabels, xAxisTitle, yAxisTitle, title );
     
     
      double[][] data= new double[][]{ { 250,  45, 136,  66, 145,  80, 55, 34, 98 }, 
                                       {  50, 145,   6, 166, 105, 105, 85, 78, 80 } };
      String[] legendLabels= { "Bugs", "FUD Towards Gnu/Linux" };
      Paint[] paints= new Paint[] { new Color( 255,  0, 18 ,100 ),  //new Color( 153, 0, 255 ,100 ), 
                                    new Color( 255,138,  0, 150 ) };//new Color( 204,0,255, 150 ) };
     
      AreaChartProperties areaChartProperties= new AreaChartProperties();
      AxisChartDataSet axisChartDataSet= new AxisChartDataSet( data, legendLabels, 
                                                             paints, ChartType.AREA, 
                                                             areaChartProperties );
     
      dataSeries.addIAxisPlotDataSet( axisChartDataSet );
     
      ChartProperties  chartProperties  = new ChartProperties();
      AxisProperties   axisProperties   = new AxisProperties();
      LegendProperties legendProperties = new LegendProperties();
     
      axisChart= new AxisChart( dataSeries, chartProperties, 
                                        axisProperties, legendProperties,
                                        500, 350 );
     
      Graphics   g  = this.getGraphics();
      Graphics2D g2 = (Graphics2D) g;
     
      axisChart.setGraphics2D( g2) ;
      }
    //**********************************************************************
    public void paintComponent(Graphics g)
      {
      super.paintComponent(g);
      Graphics2D g2 = (Graphics2D) g;
     
      axisChart.setGraphics2D( g2) ;
      try {
          axisChart.render();
          }
      catch (ChartDataException cde)
         {
         System.out.println( cde.toString() );
         }
      catch (PropertyException pe)
         {
         System.out.println( pe.toString() );
         }
      }
    //**********************************************************************
    }
    En espérant que cela te serve...
    ;-)

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

Discussions similaires

  1. Paramètres Chart
    Par J-P-B dans le forum XMLRAD
    Réponses: 2
    Dernier message: 15/08/2003, 17h17
  2. Example d'applications XMLGRAM Chart
    Par danuz dans le forum XMLRAD
    Réponses: 5
    Dernier message: 29/07/2003, 18h00
  3. [VB6] Modification des axes d'un composant Chart
    Par HPJ dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 21/05/2003, 08h33
  4. Exemples XMLGram Chart et Gestion Exception
    Par Sylvain James dans le forum XMLRAD
    Réponses: 5
    Dernier message: 05/05/2003, 18h50
  5. Créer une série dans un chart
    Par cyrose dans le forum C++Builder
    Réponses: 5
    Dernier message: 28/11/2002, 11h37

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