visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: Delphi :: delphi chart gantt


By: Bernard France  Date: 06/10/2005 10:01:11  English  Points: 20 Status: Answered
Quality : Excellent
how to draw a GANTT chart in Delphi ?
By: VGR Date: 06/10/2005 10:05:11 English  Type : Answer
this PAQ is related to this.

Roughly, a GANTT chart is nothing more than a drawing of boxes and lines.

This is my drawing procedure, I hope you find it enlightening.

Procedure TraceGANTT ( PTab : TypProj; NbT : Integer; DT : Integer ; TeC : String ); Var i, x1,x2,y1,y2 : Integer; PasGraphik : Integer; Color : Integer; msg : St10; Begin { couleur de d‚part } If MaxColors>5 Then ColReserved:=LightRed Else ColReserved:=MaxColors; Color:=-1; { toujours au moins d‚finie } Color:=NextColor(Color); { on calcule le 'pas' graphique du trac‚ } PasGraphik:=Xmax DIV DT; { on trace le GANTT au plus t“t } { trac‚ de l'axe des temps } Draw(0,2,Xmax,2,ColReserved); { l'axe } SetLineStyle(DashedLn,EmptyFill,NormWidth); For j:=0 to DT Do { les graduations } Begin PutPixel(j*PasGraphik,3,ColReserved); { pour mieux voir } PutPixel(j*PasGraphik,4,ColReserved); { pour mieux voir } { trac‚ d'axes verticaux tous les 5 unit‚s; … passer en 'options' !!! } If (j MOD 5 = 0) Then Draw(j*PasGraphik,5,j*PasGraphik,Ymax,ColReserved); End; { For graduations } { et GANTT proprement dit } SetLineStyle(SolidLn,EmptyFill,NormWidth); For i:=1 to NbT Do Begin x1:=PasGraphik*PTab^.RelTemps[1]; y1:=(Ymax DIV (NbT+1))*i; x2:=x1+PasGraphik*PTab^.Temps_Prevus[1]; y2:=y1; (* affiche num‚ro au lieu du libell‚ : Str(i,msg); *) msg:=PTab^.Libelle; If PTab^.RelTemps[1]=PTab^.RelTemps[2] Then Draw(x1,y1,x2,y2,ColReserved) { une tƒche critique } Else Begin Draw(x1,y1,x2,y2,Color); Color:= NextColor(Color); { normalement } End; { If } For j:=0 to PTab^.Temps_Prevus[1] Do PutPixel(x1+j*PasGraphik,y1-1,MaxColors); { pour mieux voir } OutTextXY((x1+x2+4) DIV 2,y1+1,msg); End; { on attend l'utilisateur } Repeat Until KeyPressed; Ch:=ReadKey; { impression si I ou i } TestPrint(ch,TeC); End; { TraceGANTT Procedure }



The structure I was using back in 1993 is explained in the referenced PAQ.

Regards

Do register to be able to answer

EContact
browser fav
page generated in 537.196870 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page