I am trying to add labels to my Y2 axis but the way I am using the Gantt chart I am running into a fork in the road....
My logic is as follows:1) Create GanttItem2) Add Multiple GanttItemEntries into the GanttItem 3) Set GanttItem Label to day 4) Add GanttItem to SeriesThe YAxis already refers to the GanttItem Label, which is the only property for GanttItem where I can see to store any referable values for axis (i.e. <ITEM_LABEL>). The only other values that populate when I refer to them are DATA_VALUE and SERIES_LABEL which are already in use.
What I would like to do is to be able to set a GantItem property to a certain string and have that display along the Y2 axis. I have been drilling into the class interfaces a bit to see how I could modify the GanttItem class to display a particular value but am moving at a crawl since I am trying to learn exactly how you guys put this framework together. I understand how to assign a custom value to GantItem but what would be the suggested method of getting that custom value to render along an axis OR are there any other suggestions of how to go about this?
In the mean time I have a work around where I redraw the chart again over top of the first layer and assign the GanttItem label to the string I need and only show the Y2 axis and nothing else. Kind of a round about way so I would like to tighten this up a bit.
Thanks!
Works like a charm and that is the exact way I wanted to go about this.
Thank you for the thorough support.
Oh, I see... You're trying to add another descriptive field to the gantt item. I suggest using a lookup table of some sort. Here's an example, where I'm using a dictionary to store an additional label for my gantt items.
item = new GanttItem(); item.Label = "task 2"; item.Times.Add(new GanttTimeEntry(DateTime.Parse("4/15/2008"), DateTime.Parse("5/3/2008"))); lookupTable.Add(item.Label, "myLabel2"); series.Items.Add(item);
class Labels : IRenderLabel{ private Dictionary<string,string> labelTable;
public string ToString(Hashtable context) { string itemLabel = (string)context["ITEM_LABEL"]; return labelTable[itemLabel]; }}
So all I should need to do is pass a Hashtable of my desired labels ( in order ) and the UltraChart will take care of the rest? I know I am oversimplifying but that is the general idea.
Try using a custom label renderer. It will allow you to substitute your axis labels with any string.
private void Form1_Load(object sender, EventArgs e){ UltraChart1.Data.DataSource = DemoTable.Table(4); Hashtable labelHash = new Hashtable(); labelHash.Add("CustomLabels", new Labels()); UltraChart1.LabelHash = labelHash; UltraChart1.Axis.Y2.Labels.ItemFormatString = "<CustomLabels>";}
class Labels : IRenderLabel{ public string ToString(Hashtable context) { string myLabel; // here you can look up any property value, as long as the chart or it's data is made accessible to this class. return myLabel; }}