The Gantt chart can be used to easily represent schedules, making visualising this information far more straightfoward.
The example file is here.
<script>
window.onload = function ()
{
var gantt = new RGraph.Gantt('gantt');
gantt.Set('chart.xmax', 365);
gantt.Set('chart.gutter', 35);
gantt.Set('chart.labels', ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
gantt.Set('chart.title', 'Holiday schedule for Xyz Ltd');
gantt.Set('chart.defaultcolor', 'rgba(255,0,0,1)');
gantt.Set('chart.tooltips', ["<b>Richard</b><br />Richard is going on holiday to Malta.<br />He'll be away for 28 days.",
"<b>Fred</b><br />Fred is also going away for 28 days",
"<b>Barney</b><br />Barney is off work for two weeks",
"<b>Gloria</b><br />Gloria is off for 3 weeks",
"<b>Paul</b><br /> Away for 31 days",
"<b>Harry</b><br />Away for three weeks",
"<b>Shane</b><br />Away for one week",
"<b>Barry</b><br />Away for two weeks",
"<b>Cynthia</b><br />Away for two weeks",
"<b>Graham</b><br />Away for August and September",
"<b>Paul</b><br />Away for 31 days"]);
gantt.Set('chart.events'[
[31, 28, null, 'Richard'],
[31, 28, null, 'Fred'],
[59, 14, null, 'Barney'],
[59, 21, null, 'Gloria'],
[59, 31, null, 'Paul'],
[80, 21, null, 'Harry'],
[94, 7, null, 'Shane'],
[120, 14, null, 'Barry'],
[130, 14, null, 'Cynthia'],
[211, 61, null, 'Graham'],
[334, 31, null, 'Paul'],
]);
gantt.Set('chart.vbars', [
[0, 31, 'rgba(192,255,192,0.5)'],
[59, 31, 'rgba(192,255,192,0.5)'],
[120, 31, 'rgba(192,255,192,0.5)'],
[181, 31, 'rgba(192,255,192,0.5)'],
[243, 30, 'rgba(192,255,192,0.5)'],
[304, 30, 'rgba(192,255,192,0.5)'],
]);
gantt.Draw();
}
</script>
You can use these properties to control how the bar graph apears.
To add events, you specify them using the chart.events property. You could use the following to set some events on your gantt chart:
gantt.Set('chart.events', [
[31, 28, 75, 'Richard'],
[12, 28, 67, 'Fred'],
[59, 14, 0, 'Barney'],
[59, 21, 5, 'Gloria'],
[46, 31, 94, 'Paul'],
[80, 21, 46, 'Harry'],
[94, 17, 84, 'Shane'],
[34, 14, 32, 'Barry'],
[64, 14, 28, 'Cynthia', 'red', 'yellow'],
[13, 61, 74, 'Graham'],
[84, 31, 16, 'Paul']
]);
The first value is the (zero indexed) start number relative to your chart.xmax. So if you have set your chart.xmax to 62, (to represent two months), and this value is 31, the start will be the start of the second month. In this case you could give two labels - ['July', 'August'].
The second value is the duration. So using the previous example, if you set this to 7, you would have an event lasting a week.
The third value is the "percentage complete" indicator. This is shown to the right of the event, and is optional - you can specify null if you wish.
The fourth value is the label that is used on the left hand side.
The optional fifth value stipulates the background colour that the bar is. Default is white.
And the last optional 6th value is the foreground color of the bar. Defaulting to #0c0.
You can add decorative vertical bars like so:
gantt.Set('chart.vbars', [
[0, 31, 'rgba(192,255,192,0.5)'],
[59, 31, 'rgba(192,255,192,0.5)'],
[120, 31, 'rgba(192,255,192,0.5)'],
[181, 31, 'rgba(192,255,192,0.5)'],
[243, 30, 'rgba(192,255,192,0.5)'],
[304, 30, 'rgba(192,255,192,0.5)'],
]);
You can use these for decorative purposes, or to mark events/limits. The first value is the start index, as above. The second value is the unit length, again as above. The third value is the color of the vertical bar.