Tchart, series et affichage...

Résolu
sfkuhvdlkufgs Messages postés 31 Date d'inscription jeudi 16 décembre 2004 Statut Membre Dernière intervention 4 mai 2007 - 6 juin 2006 à 11:27
sfkuhvdlkufgs Messages postés 31 Date d'inscription jeudi 16 décembre 2004 Statut Membre Dernière intervention 4 mai 2007 - 7 juin 2006 à 19:58
bonjour,
donc voila je fais une appli qui doit afficher un graphe qd l'utilisateur clique sur un bouton mais rien ne s'affiche... ou en tout cas pas les courbes.
 a l'appui du bouton je rentre bien dans ma procédure tform1.button1click(sender: tobject); dans laquelle je procede pour mes series de la maniere suivante : 
      series1:=TlineSeries.Create(self);
      series1.parentchart:=chart1;
      series1.clear:
      for i:=1 to n do
        series1.addxy(i,un_extended)
voila

ma procedure est déclare de la maniere suivante dans la classe tform1 : tform1.button1click(sender: tobject);
  puis je l'instancie avec la même en tete dans la partie implementation.

3 réponses

sfkuhvdlkufgs Messages postés 31 Date d'inscription jeudi 16 décembre 2004 Statut Membre Dernière intervention 4 mai 2007
7 juin 2006 à 19:58
Bon ben alors en fait, c'est juste que j'avais selectionné l'echelonage automatique des axes, pensant que ceux la s'ajusteraient automatiquement à mes courbes, mais en fait, cela ne se passait jamais et les courbes n'étaient pas dans la zone d'affichage...
  J'ai donc eu la bonne surprise tout à l'heure en décochant cette case (plus par désespoir qu'en croyant obtenir un résultat) d'apercevoir deux traits sur mon graphe.
  En tout cas merci de ton aide.
 
3
sfkuhvdlkufgs Messages postés 31 Date d'inscription jeudi 16 décembre 2004 Statut Membre Dernière intervention 4 mai 2007
6 juin 2006 à 11:55
Avec le code se sera peut etre mieux, je pense que cela rappelera des choses à certains mais j'ai pas réussi à trouver le message original
ce qui est en rouge correspond à des interrogations (risques d'erreuers) et ce qui ce rapporte à ma question.
Merci
unit mol;<?xml:namespace prefix o ns "urn:schemas-microsoft-com:office:office" /?>





 





interface





 





uses






  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,






  Dialogs, StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart, Buttons,






  DbChart, Menus;





 





type






  TNBB = array of extended;






  TForm1 = class(TForm)






 
   Chart1: TChart;






    Series1: TLineSeries;






    StaticText1: TStaticText;





 






    StaticText2: TStaticText;






    Edit1: TEdit;






    StaticText3: TStaticText;






    Edit2: TEdit;






    StaticText4: TStaticText;






    Edit3: TEdit;






    StaticText5: TStaticText;






    Edit4: TEdit;






    StaticText6: TStaticText;






    Edit5: TEdit;






    Splitter2: TSplitter;






    StaticText7: TStaticText;






    StaticText8: TStaticText;






    StaticText9: TStaticText;






    Edit6: TEdit;






    Edit7: TEdit;






    StaticText10: TStaticText;






    Splitter3: TSplitter;






    Button1: TButton;






    Label1: TLabel;






    Edit8: TEdit;






    Label2: TLabel;






    Label3: TLabel;






    Edit9: TEdit;






    Label4: TLabel;






    Label5: TLabel;






    Edit10: TEdit;






    Edit11: TEdit;






    Label6: TLabel;






    Label7: TLabel;






    Edit12: TEdit;






    Edit13: TEdit;






    Edit14: TEdit;






    Label8: TLabel;






    Edit15: TEdit;






    Label9: TLabel;






    Edit16: TEdit;






    Label10: TLabel;






    Label11: TLabel;






    Edit17: TEdit;






    Label12: TLabel;






    Edit18: TEdit;






    Label13: TLabel;






    Edit19: TEdit;






    Series2: TLineSeries;






    Label14: TLabel;






   
procedure Button1Click(Sender: TObject);







 

private






    { Déclarations privées }






  public






    { Déclarations publiques }






  end;





 





var        {par conv, A et B représentent les especes, 1 et 2 les milieux}






 

Form1: TForm1;





 






  dens_pop_a , dens_nour_a, tx_abs_nour_a, dens_pop_b,






  dens_nour_b , tx_abs_nour_b, supply_pool, temps, precision : string;





 






  dpa,dn1,tana,dpb,dn2,tanb,s, coefr1,






  coefr2,coefn1,coefn2, prec, pt_suiv_r1,pt_suiv_r2,






  coefnA,coefnB,conv1A,conv1B,conv2A,conv2B,perteA,perteB : extended ;





 






  i,n,c1,c2,pa1,pa2,pb1,pb2 : integer;





 






  TNA,TNB : tnbb;






  implementation





 





 





 





 






procedure TForm1.Button1Click(Sender: TObject);







  begin





 






 
with form1 do







 








 

dpa:=strtofloat(Edit1.text); {dens pop A}    {recupération des valeurs}






 

dn1:=strtofloat( Edit3.text);  {dens nour 1}






  dpb:= strtofloat(  edit2.text);






  dn2:=strtofloat( Edit4.text);






  S:=strtofloat(Edit8.text);  {supply pool}






  n:=strtoint(Edit9.Text);     {temps}






  prec:=strtofloat(Edit5.text);






 

pa1:=strtoint(Edit10.Text);  {approvisionement de A sur 1}






 

pa2:=strtoint(Edit11.Text);






  pb1:=strtoint(Edit12.Text);






  pb2:=strtoint(Edit13.Text);






 

conv1A:=strtofloat(Edit17.text);  {convertion nour de A sur 1}






 

conv1B:=strtofloat(Edit18.text);






  conv2A:=strtofloat(Edit16.text);






  conv2B:=strtofloat(Edit15.text);






  perteA:=strtofloat(Edit19.text);






  perteB:=strtofloat(Edit14.text);






  n:=10;






  c1:=1;






  c2:=1;






   //dpa:=1.0 ;






  SetLength(TNA, n);       {init des tableaux}






  SetLength(TNB, n);





 






  tNA[0]:=dpa;






  tNB[0]:=dpb;





 





 






 
series1:=TLineSeries.Create(self);








  series2:=TLineSeries.Create(Self);







 








  series1.parentChart:=chart1;








  series2.parentChart:=chart1;







 








  series1.clear;








  series2.clear;







 








  series1.addxy(1,dpa);








  series2.addxy(1,dpb);






 





 






 
 coefR1:=c1*(S-dn1)-(pa1*dpa*dn1+pb1*dpb*dn1);






  coefR2:=c2*(S-dn2)-(pa2*dpa*dn2+pb2*dpb*dn2);





 






  coefnA:= dpa*(pa1*conv1A*dn1+pa2*conv1B*dn2-perteA);






  coefnB:= dpa*(pb1*conv2a*dn1+pb2*conv2B*dn2-perteB);





 





 






 

pt_suiv_r1:=prec*coefR1+dn1;  {point 1}






  pt_suiv_r2:=prec*coefR2+dn2;





 





 





 





 






 

for i:=1 to n-1  do






  begin





 






  tna[i]:=coefna*prec+tna[i-1];






  tnb[i]:=coefnb*prec+tnb[i-1];





 






 
{ series1.add(tna[i]);








  series2.add(tnb[i]); }







 








  series1.addxy(i+1,tna[i]);








  series2.addxy(i+1,tnb[i]);






 






  coefr1:=c1*(S-pt_suiv_R1)-(pa1*dpa*pt_suiv_R1+pb1*dpb*pt_suiv_r1);






  coefR2:=c2*(S-pt_suiv_r2)-(pa2*dpa*pt_suiv_r2+pb2*dpb*pt_suiv_r2);





 






  coefna:=tna[i]*(pa1*conv1A*pt_suiv_r1+pa2*conv1B*pt_suiv_R2-perteA);






  coefnb:=tnb[i]*(pb1*conv2a*pt_suiv_r1+pb2*conv2B*pt_suiv_R2-perteA);





 





 






 

pt_suiv_r1:=prec*coefR1+pt_suiv_r1;






  pt_suiv_r2:=prec*coefR2+pt_suiv_r2;





 






  if (pt_suiv_r1<0) then pt_suiv_r1:=0;  {pas de ressources négatives}






  if (pt_suiv_r2<0) then pt_suiv_r2:=0;  {ca ou zngi???? ou zngi est a l'equilibre}





 





 





 






 

end;





 





 






  end;





 






   begin





{$R *.dfm}






  

// c1:=1;





 





 





end.




 
0
cs_Delphiprog Messages postés 4297 Date d'inscription samedi 19 janvier 2002 Statut Membre Dernière intervention 9 janvier 2013 32
7 juin 2006 à 14:09
Sauf si n est inférieur à 1, ton premier code doit fonctionner.

May Delphi be with you !
<hr color="#008000" />
Pensez à cliquer sur Réponse acceptée lorsque la réponse vous convient.
0
Rejoignez-nous