This post shows a first attempt to use my “HTML calculated column” method to display Gantt views.
Why would I do this, knowing that SharePoint already offers Gantt views? Well, this addresses a few issues of the built-in solution:
– adjust the timescale
– add color coding
– use grouping options on the chart itself
– add various behaviors like context information
On the other hand, my solution doesn’t display a scale. Also, like the built-in SharePoint Gantt, it won’t manage task dependencies (Finish to Start, etc.).
Well, as usual:
– a calculated column creates the HTML that will position the task on the Gantt
– the script renders the column as HTML instead of text
Here is the formula I used for the above example (did you expect a short one?):
="<DIV style='white-space:nowrap;'><SPAN style='display:inline-block; width:"&(MAX(DATE(2008,12,31),[Start Date])-DATE(2008,12,31))*0.5&"px;'> </SPAN><SPAN style='display:inline-block;background-color:"&Color&";width:"&(MAX(DATE(2008,12,31),[Due Date])-MAX(DATE(2008,12,31),[Start Date]))*0.5&"px;'> </SPAN><SPAN style='display:inline-block;'>"&" "&Title&": "&MONTH([Start Date])&"/"&DAY([Start Date])&" to "&MONTH([Due Date])&"/"&DAY([Due Date])&"</SPAN></DIV>"
How the formula works:
– the origin is represented by DATE(2008,12,31) – appears 4 times in the formula.
– 0.5 is the number of pixels for one day – appears twice in the formula.
– for tasks that start before the origin: the part before the origin won’t be displayed.
– the color is stored in a separate [Color] column (green, blue, etc.)
I’d love to hear from you on this first attempt. Does this offer a plus, compared to the built-in Gantt? Is it worth investigating it further? If so, what is still missing?