Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
Gantt Chart Y2 Axis Labels
posted

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 GanttItem
2) Add Multiple GanttItemEntries into the GanttItem
3) Set GanttItem Label to day  
4) Add GanttItem to Series

The 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!

Parents
  • 26458
    Offline posted

    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;
       }
    }

Reply Children