Home > Sample Charts > GanttChart

GanttChart

Gantt charts were originally devised as a graphical way to show the relationship between activites in a project plan, and have been made very popular by tools such as MS Project. The chart shows time progressing from left to right, with each activity drawn as a colored bar, and generally labelled with its name. The Y-axis shows some higher-level grouping of related tasks.

This style of chart also works very well as a way to show a production schedule (machines are shown on the Y-axis) or to record the output from any kind of logging system.


SharpPlot sp = new SharpPlot;
sp.SetMargins(6,12,36,4);
sp.SetColors(new Color[]{Color.OrangeRed,Color.ForestGreen});
sp.SetYLabels(new string[]{"Cut","Polish","Pack"});
sp.SetXTickMarks(5);
sp.SetYTickMarks(new double[] {0.5,1.5,2.5,3.5});
process = new int[] {1,1,2,2,2,3,3};
start = new int[] {24,28,25,29,35,29,42};
end = new int[] {28,32,29,33,40,30,44};
done = new bool[]{true,false,true,false,false,true,false};
sp.YAxisStyle = YAxisStyles.ForceZero|YAxisStyles.MiddleLabels|YAxisStyles.GridLines;
sp.KeyStyle = KeyStyles.NoKey;
sp.SplitBy(done);
sp.DrawGanttChart(process,start,end);

Worked Examples

ganttchart1 ganttchart2 ganttchart3 ganttchart4

Send comments on this topic
© Dyalog Ltd 2013