Saturday, June 11, 2011
BlockedTime-Extension a.k.a “NoWorkTime-Extension”
A plan may contain spans of time where no work can be done. When putting activities inside such spans, or near such spans so that they extend into the span, the activity should be paused and continue after the span.
Saturday, October 2, 2010
How to create alternate rows in Gantt for Silverlight and WPF
The Background is bound to “DataContext” that will be whatever the GanttRow represents – I add a Converter that can take my – in this case – DemoDataRow and turn it into a Brush:
Gantt for Silverlight and WPF
The GTP.NET.SL enables you to easily add time dependant stuff in the background or foreground of your TimeItemArea.
As our Gantt is flexible enough to integrate with any grid or treeview we need a generic way to help you do draw things in the area that belongs to the Grid or Tree but resides under the DateScaler:
We did this by exposing two events:
You can from the internal code above see that the exact same way that we implement the TodayLine and the VerticalDayStripes we also call the OnDrawBackground and OnDrawForeground events.
This is how we implement the today line:
Notice that the call to DateScaler.TimeToPixel easily helps anyone to convert between time and position – this call – that is very effective and the heart of our Gantt implementation – ensures that the TodayLine is positioned on the exact spot where the user perceives NOW to be.
Also notice that we check the ScheduleMode setting to decide in what direction to draw the todayline.
This is the sample implementation of the OnDrawForeground event:
The difference between Foreground and Background is achieved with Canvas.ZIndex settings and enables you to get effects like this:
Where the the blue ellipse goes above the TimeItem and the green ellipse goes below the TimeItem.
Size override and User draw of Gantt Time Items
One feature that may come in handy from time to time is the size override behavior that you can get by implement the event OnTimeItem_UserDrawBounds in the GTP.NET.
It is most commonly used with UserDraw – since most of the standard time items have a standard square form that does not get any real benefit from overriding the perceived size – since the standard square that is defined by Start and Stop in one axis and GanttRow Height (with consideration to Sub columns) in the other direction.
And the implementations:
This will render this way:
Now the cool thing is that when you click in the white area the TimeItem will be selected/moved/resized etc, but when you click in the corners, where the Time Item Square should have been drawn if this was a standard time item, this is just like clicking on the GanttRow alone.
I also added some code in the userdraw to center a text – you need to measure the text then consider the available space – then place the text.
Thursday, July 22, 2010
Collision detect of TimeItems in a Gantt chart
The GTP.NET will order the colliding time items in separate sub columns. The way this is done is fully automatic and the result will be something like this:
But what if you would rather to have the Top time item at the bottom?
One way is to re-order the SubColumn values after the collision detection is done. Go like this:
And then you have a result that looks like this:
Saturday, July 17, 2010
Getting an Ajax Gantt chart set up properly with VisualStudio 2010
You can use GTP.NET on the web and it supports Ajax to move around time items and scroll in time.
Create a new ASP.NET project:
The Gantt chart does not care from where your data comes, but since it needs data to display I need to go thru these steps in order to show anything at all. If you already have data you want to show, you might be better of just using that from the get-go.
First we need to get hold of some data, so I add a new SqlServer database to the App_Data folder and create some tables and fields to hold my Gantt data:
Start and Stop fields in the WorkItem table are of type DateTime.
I then create a new typed DataSet (Do not like typed dataset? Any data is fine really, do it your way ) and drag on the tables and set up some relations:
I added the Activity table twice, naming in SubActivity the second time, to hold a 2 level hierarchy in the gantt chart.
On the Default.aspx page where I want to show my Gantt chart I drag on a ScriptManager and UpdatePanel onto the form. These are the standard components that provide the Ajax effect of partial postbacks. I also add the Gantt_ASP inside the UpdatePanel, and I add some buttons about the UpdatePanel.
What also is important is to add the GTPImg.aspx page to the project – this page helps with Image rendering that the Gantt needs. You will find it under [program files]\plexityHide AB\GTP.NET 188.8.131.52\Assemblies\CLR35\asp.net. Make sure to add GTPImg.aspx and GTPImg.aspx.cs to the project.
If you run the project as it stands now you should be able to see the Gantt chart DateScaler and you should be able to panorate in time by grabbing and dragging it. You can also use the buttons to scale in or out to show less or more time:
Now we will need to add some code to set up the databind:
In this example I let the Gantt behave differently depending if this was a Postback or a new Page request. If it was a postback I get the data from the session cache to speed things up, and not from the database.
The methods involved are :
And also these two methods :
Minimum logic there really – just to show one way of many possible way to handle your data in an ASP.NET application.
Moving on with what this post is really about: a Live Ajax Gantt with Data.
To initialize the databind I have implemented this:
As you see on row 11 the root activities are handed to the Gantt_ASP1.Gantt.GridProperties.RootNodes_DataSource and that is the key row in that code. But equally important is the event handlers that are set up for “OnEachListItemWhenDataBound_”, there are two of these one for GridNodes and one for TimeItem.
Theses event handlers will allow us to set up further databind per item in the first databound collection (root activities).
In the code above you will see that I do different stuff depending on GridNode.SubLevel – this is a convenient way to know on what level I am getting this call. On Level zero – root level – I set up the databind of the Sub-activity-nodes. And on Level 1 the sub-activities – I set up databind for TimeItems in a TimeItemLayer.
I also want to mention a few words about CellLayouts and TimeItemLayouts – these are objects that control the rendering look and feel. In this sample I have chosen to define them in code like this:
Running the sample will give you this ; depending on your data of course:
The implementation behind the buttons are all about data and not Gantt specific at all:
The One bit of important Gantt related code left is this event implementation:
In the event above that is fired by the Gantt_ASP when it is done with applying the users change to the data, I save the data to the cache. This is the brilliant thing about databind – Load and save code need not be bothered with the components that aided in presenting or changing the data.
Ok Done. Comments are appreciated.
Sample can be downloaded from here http://www.plexityhide.com/pub/VS2010_Gantt_ASP_WebApplication1.zip
Subscribe to Posts [Atom]