Assume you want to visualize a list of tasks in a Gantt chart. In addition you need to sort these tasks in descending order to get a better overview of what task you should work on next. Typically, VARCHART XGantt supports up to 3 criteria to sort tasks. With this blog post from our VARCHART XGantt tips & tricks series we show you an approach how to expand these number of criteria.
Let's say, we have 15 groups all filled with nodes. All of the nodes are already sorted like this:
Every node represents a task. Let us further assume that one of the groups contains the unassigned tasks and the other 14 groups represent machines with assigned tasks. Imagine, you want to see tasks with a certain status at the top of the "unassigned tasks" group.
So how could you achive this?
So what to do? Simply use a 4th sorting criteria.
You can combine the values that would be in the new first and second criteria, save this combination into a newly added field in the node and change the first node sorting criteria to this new field.
This way we effectively use 4 sorting criteria while only using all 3 available criteria in VARCHART XGantt.
To stick to our example we would sort the nodes like this:
Now you have to combine the 1st and 2nd criteria and save the combined value into a new Field.
The type of this new field will be String, because this is the only type that would let us combine an Integer with a DateTime.
Please keep in mind that by using a String field the values will be sorted alphanumerically. That means Integers in a String field will be sorted not by their value but by their leading characters.
For example the numbers 1 - 12 would look like this:
1
10
11
12
2
3
...
To let them be sorted by value we have to fill these number up with leading "0"s until the length of the longest number is reached:
01
02
03
04
…
With that in mind we use the sortable format for DateTimes, i.e. "yyyyMMddhhmmss", as well and we are good to go. Now we just have to combine those two values as a string and save it into the new field.
When this is finished for all nodes we just have to call SortNodes() on the XGantt instance and the rest will be handled by VARCHART XGantt.
Not yet developing .NET Gantt chart applications with XGantt? Give it a try!