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
220
Custom Axis Labels on UltraChart
posted

I'm trying to create custom axis labels on a combination UltraChart.  I have the top X axis labels on an hour-by-hour time interval and I want the bottom X axis labels to follow the same interval, but display custom data.  The data I want to be displayed is going to be derived from the same data used to create the line chart, how could I go about manipulating the data and displaying the results in the bottom X axis labels?  

Any help would be greatly appreciated.

Thanks!

  • 26458
    Suggested Answer
    Offline posted

    Try implementing IRenderLabel, if you want to replace existing x axis labels with custom text. For example,

    Hashtable labelHash = new Hashtable();
    labelHash.Add("CUSTOM", new MyLabelRenderer());
    ultraChart1.LabelHash = labelHash;
    xAxis.Labels.ItemFormatString = "<CUSTOM>";

    public class MyLabelRenderer : IRenderLabel
    {
        public string ToString(Hashtable context)
        {
            string label = (string)context["ITEM_LABEL"];
            int row = (int)context["DATA_ROW"];
            int col = (int)context["DATA_COLUMN"];
            //use row, col, current label's text or other info inside the context to get the axis label.
            //the string returned here will replace the current label.
            return label;
        }
    }