Blame | Letzte Änderung | Log anzeigen | RSS feed
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1"><LINK REL="Start" HREF="index.html"><LINK REL="Contents" HREF="toc.html"><LINK REL="Prev" HREF="10126Adjustingthemarginswithautosizing.html"><LINK REL="Next" HREF="1014AddingCSIMClientsideImageMapstoGanttcharts.html"><STYLE TYPE="text/css"><!--BODY { font-family: serif }H1 { font-family: sans-serif }H2 { font-family: sans-serif }H3 { font-family: sans-serif }H4 { font-family: sans-serif }H5 { font-family: sans-serif }H6 { font-family: sans-serif }SUB { font-size: smaller }SUP { font-size: smaller }PRE { font-family: monospace }A { text-decoration: none }--></STYLE></HEAD><BODY><A HREF="toc.html">Contents</A><A HREF="10126Adjustingthemarginswithautosizing.html">Previous</A><A HREF="1014AddingCSIMClientsideImageMapstoGanttcharts.html">Next</A><HR NOSHADE><H2><A NAME="10_13">10.13 Simplifying the drawing of Gantt graphs</A></H2><P> As we have shown in the previous examples constructing a Gantt chartconsists of a number of repetitive tasks; Create the individualactivity bars and add them to the graph.</P><P> Now when you have a basic understanding of how this works you areready to appreciate a small helper method. <A href="">GanttGraph::CreateSimple()</A>. This method takes a few arrays of datawhich specifies you Gantt chart and then constructs this chart. Byusing this method you sacrifices a few adjustment possibilities forsimplicity. This method is nothing magical it just takes the data forthe activities,(start and end date, titles, progress, any constrainsand so on) and constructs the activities and adds them to the graph.</P><P> The activities are specified in data array which for each activityhave the following fields</P><UL><LI> What row the activity should be on</LI><LI> Activity type, controls the appearance. Can be one of<OL><LI> ACTYPE_NORMAL, A standard activty bar</LI><LI> ACTYPE_GROUP, A Grouping bar</LI><LI> ACTYPE_MILESTONE, A milestone</LI><LI></LI></OL><P></P></LI><LI> Title text</LI><LI> Start date</LI><LI> End date (NOT FOR Milestones!)</LI><LI> Caption</LI></UL><P></P><P> So for example to create a Gantt chart consisting of two activitieswhich are grouped and a milestone one would have to use somethingsimilar to the following code</P><P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB"> $data </FONT><FONT color="#007700">= array(<BR> array(</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONTcolor="#0000BB">ACTYPE_GROUP</FONT><FONT color="#007700">, </FONT><FONTcolor="#DD0000">"Phase 1"</FONT><FONT color="#007700">, </FONT><FONTcolor="#DD0000">"2001-10-26"</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">"2001-11-23"</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">""</FONT><FONT color="#007700">),<BR> array(</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONTcolor="#0000BB">ACTYPE_NORMAL</FONT><FONT color="#007700">, </FONT><FONTcolor="#DD0000">" Label 2"</FONT><FONT color="#007700">, </FONT><FONTcolor="#DD0000">"2001-10-26"</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">"2001-11-13"</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">"[KJ]"</FONT><FONT color="#007700">),<BR> array(</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">,</FONT><FONTcolor="#0000BB">ACTYPE_NORMAL</FONT><FONT color="#007700">, </FONT><FONTcolor="#DD0000">" Label 3"</FONT><FONT color="#007700">, </FONT><FONTcolor="#DD0000">"2001-11-20"</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">"2001-11-22"</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">"[EP]"</FONT><FONT color="#007700">),<BR> array(</FONT><FONT color="#0000BB">3</FONT><FONT color="#007700">,</FONT><FONTcolor="#0000BB">ACTYPE_MILESTONE</FONT><FONT color="#007700">,</FONT><FONTcolor="#DD0000">" Phase 1 Done"</FONT><FONT color="#007700">, </FONT><FONTcolor="#DD0000">"2001-11-23"</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">"M2"</FONT><FONT color="#007700">) );<BR><BR></FONT><FONT color="#FF8000">// Create the basic graph<BR></FONT><FONT color="#0000BB">$graph </FONT><FONT color="#007700">= new </FONT><FONT color="#0000BB">GanttGraph</FONT><FONT color="#007700">();<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-></FONT><FONTcolor="#0000BB">title</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">"Gantt Graph using CreateSimple()"</FONT><FONT color="#007700">);<BR><BR></FONT><FONT color="#FF8000">// Setup scale<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-></FONT><FONTcolor="#0000BB">ShowHeaders</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">GANTT_HYEAR </FONT><FONT color="#007700">| </FONT><FONT color="#0000BB">GANTT_HMONTH </FONT><FONT color="#007700">| </FONT><FONT color="#0000BB">GANTT_HDAY </FONT><FONT color="#007700">| </FONT><FONT color="#0000BB">GANTT_HWEEK</FONT><FONT color="#007700">);<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-></FONT><FONTcolor="#0000BB">scale</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">week</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">SetStyle</FONT><FONTcolor="#007700">(</FONT><FONT color="#0000BB">WEEKSTYLE_FIRSTDAY</FONT><FONTcolor="#007700">);<BR><BR></FONT><FONT color="#FF8000">// Add the specified activities<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-></FONT><FONTcolor="#0000BB">CreateSimple</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">$data</FONT><FONT color="#007700">);<BR><BR></FONT><FONT color="#FF8000">// .. and stroke the graph<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-></FONT><FONTcolor="#0000BB">Stroke</FONT><FONT color="#007700">();<BR></FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P><P> This will then show up as<DIV class="example"><BR> <A href="exframes/frame_ganttsimpleex1.html" target="blank"><IMG border="0"HEIGHT="231" src="img/ganttsimpleex1.png" WIDTH="523"></A><BR><B>Figure 166:</B> Using the simplified way via CreateSimple()method <A href="exframes/frame_ganttsimpleex1.html" target="blank">[src]</A> <P></P></DIV></P><P> You may (slightly) modify the appearance of the simple Gantt chartsby means of the methods <A href="">GanttGraph::SetSimpleFont()</A> and <Ahref="">GanttGraph::SetSimpleStyle()</A> But not anything else, rememberthat the purpose with this way of constructing graphs is to be simple.If you need full advanced control you have to construct all theactivities in the "normal" way.</P><P> You can also specify constrains and progress for each bar bysupplying additional data arrays to GanttGraph::CreateSimple().</P><HR NOSHADE><A HREF="toc.html">Contents</A><A HREF="10126Adjustingthemarginswithautosizing.html">Previous</A><A HREF="1014AddingCSIMClientsideImageMapstoGanttcharts.html">Next</A></BODY></HTML>