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 VCL Delphi Discussion :

Problème TChart (débutant)


Sujet :

Composants VCL Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Par défaut Problème TChart (débutant)
    Bonjour,

    Mon application utilise un Tchart pour présenter un graphique dont l'axe X exprime des distances en miles nautiques, et l'axe Y une quantité de carburant.
    des points géographiques sont disposés le long de l'axe X à intervalles irréguliers.

    Je tente de tracer une courbe dont la valeur Y est entrée par l'utilisateur dans un Tedit et qui correspond à l'un des points sélectionné dans un TCombobox.

    Je ne parviens pas à obtenir le résultat escompté.
    Ci joint l'écran du graphique nu avant la saisie de la première quantité de carburant.

    Ici Le code qui ne fonctionne pas comme souhaité:
    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
    unit Unit3;
     
    interface
     
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
      VCLTee.TeEngine, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.TeeSpline, VCLTee.TeeEdiGene,
      VCLTee.Series, Vcl.ComCtrls, Inifiles, Printers, VCLTee.TeeFunci;
     
    type
      TForm3 = class(TForm)
        Panel1: TPanel;
        CbxWaypoints: TComboBox;
        LblWaypoints: TLabel;
        LblFuelOnBoard: TLabel;
        EdFOB: TEdit;
        btnOK: TButton;
        btnPrint: TButton;
        LblRoute: TLabel;
        REdLog: TRichEdit;
        Chart1: TChart;
        Series2: TFastLineSeries;
        procedure FormActivate(Sender: TObject);
        procedure RichEdit_MoveTo(RichEdit: TRichEdit; LineNumber, CharNumber: Word);
        procedure btnPrintClick(Sender: TObject);
        procedure btnOKClick(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
     
    var
      Form3: TForm3;
      lstWPT                           : TStringList;
    implementation
     
    {$R *.dfm}
     
    procedure TForm3.btnOKClick(Sender: TObject);
    var WP: Integer;
        Qty  : Double;
    begin
      if edFOB.Text<> '' then
      begin
        Qty:= StrToFloat(EdFOB.Text);
        WP:= cbxWaypoints.ItemIndex;
        Series2.AddXY(StrToFloat(lstWPT[WP]),QTY,'',clRed);
      end;
     
    end;
     
    procedure TForm3.btnPrintClick(Sender: TObject);
    begin
     ChartPreview(Self,Chart1);
    end;
     
    procedure TForm3.FormActivate(Sender: TObject);
    var Ini                              : TInifile;
        CheminFs, stGd, Ligne            : String;
        SearchResult                     : TSearchRec;
        i, LoDistGrd, GloDistGrd, Value  : Integer;
        Ratio, rayon                     : Extended;
    begin
      LstWPT:= TStringList.Create;
      LstWPT.StrictDelimiter:= True;
      lstWPT.Delimiter:= ',';
      CbxWaypoints.Clear;
      Ini                       := TiniFile.Create(extractFilePath
                                                 (application.exename)+'CPS.cfg');
      CheminFs                  := Ini.ReadString('PATHS','FSX','');
      if FindFirst(CheminFS + '\Civa\ADEU\' +  '*.txt' , faAnyFile , searchResult)= 0 then
      begin
        REdLog.Lines.LoadFromFile(ExtractFilePath(CheminFS + '\Civa\ADEU\') + searchResult.Name);
        LblRoute.Caption:= Copy(searchResult.Name, 1, 12);
        Chart1.Axes.Bottom.Minimum    := 0;
        Chart1.Series[0].AddXY(LoDistGrd,0,copy(SearchResult.Name,1,4));
    //--------------------------Calcul de la distance et des cumuls----------------
        i:= 0;
        While i <  REdLog.Lines.Count+1 do
        Begin
          if TryStrToInt(Copy(REdLog.lines.Strings[i],44,4),Value) then
          begin
            LoDistGrd                 := LoDistGrd + Value;
            stGd                      := IntToStr(LoDistGrd);
            RichEdit_MoveTo(REdLog,i+1,(47 - Length(stGd)));
            Application.ProcessMessages;
            REdLog.SelLength:= 0;
            REdLog.SelText:= IntToStr(LoDistGrd)+ ' ' + #124;
            Chart1.Series[0].AddXY(LoDistGrd,0,Copy(REdLog.lines.Strings[i],17,6));
            LstWPT.Add(StGd);
            CbxWaypoints.Items.Add(Copy(REdLog.lines.Strings[i],17,6));
            Value:= 0;
            Inc(i);
          end;
          Inc(i);
        End;
        GloDistGrd:= LoDistGrd;
        //Ratio := 181.5/274; //Dimensions Air France (90 t. x 3200nm) Rayon = 1837.3 mm
        Ratio:= LoDistGrd / 3200;
        Chart1.Axes.Bottom.Maximum    := LoDistGrd;
        Chart1.Axes.Left.Maximum      := 90 * Ratio;
        Rayon := Rayon * Ratio;
        i:= 0;
        while i <= REdLog.Lines.Count+1 do
        Begin
          if TryStrToInt(Copy(REdLog.lines.Strings[i],44,4),Value) then
          begin
            LoDistGrd                 := LoDistGrd
                                       - Value;
            stGd                      := IntToStr(LoDistGrd);
            RichEdit_MoveTo(REdLog,i+1,(54 - Length(stGd)));
            Application.ProcessMessages;
            REdLog.SelLength:= 0;
            REdLog.SelText:= IntToStr(LoDistGrd) + ' ';
            Ligne:= REdLog.Lines[i+1];
            Ligne:= Copy(Ligne,1, Length(Ligne)-2);
            REdLog.Lines[i+1]:= Ligne;
            Inc(i,3)
          end
          else
            Inc(i);
        End;
      end;
      FindClose(SearchResult);
      cbxWaypoints.ItemIndex:= 0;
     
    end;
     
    procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      LstWPT.Free;
    end;
     
    procedure TForm3.RichEdit_MoveTo(RichEdit: TRichEdit; LineNumber, CharNumber: Word);
    begin
      RichEdit.SelStart := RichEdit.Perform(EM_LINEINDEX, LineNumber, 0) + CharNumber;
    end;
     
    end.
    Et enfin, le graphe tel que généré par mon mauvais code. les images ont été inversées.

    Étant donné ma méconnaissance du Tchart, une âme charitable pourrait-elle me mettre sur la voie.

    Merci

    Cordialement
    Pierre
    Images attachées Images attachées   

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

Discussions similaires

  1. requete, problème de débutant
    Par focus dans le forum Access
    Réponses: 4
    Dernier message: 16/02/2006, 05h51
  2. Problème de débutant dans une requête
    Par decour dans le forum Access
    Réponses: 7
    Dernier message: 14/10/2005, 14h17
  3. [C#][service windows] problème de débutant avec 1 timer
    Par Nycos62 dans le forum Windows Forms
    Réponses: 3
    Dernier message: 14/10/2005, 11h22
  4. Réponses: 3
    Dernier message: 24/09/2005, 09h34
  5. [DB2] problèmes de débutant
    Par rémi_tounul dans le forum DB2
    Réponses: 4
    Dernier message: 21/04/2005, 17h08

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