Languages :: Delphi :: delphi chart gantt |
|||
| By: Bernard |
Date: 06/10/2005 10:01:11 |
Points: 20 | Status: Answered Quality : Excellent |
| how to draw a GANTT chart in Delphi ? | |||
| By: VGR | Date: 06/10/2005 10:05:11 | 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 |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








