Search code examples
c#zedgraph

Zedgraph Hard code axis


tempTime = new DateTime(1989, 1, 1, Convert.ToInt32(tempTime.ToString("HH")) + 1, 0, 0);

string[] labels = new string[(totalMinutes / 60) + 3];
for (int a = 0; a < (totalMinutes / 60) + 3; a++)
{
    tempTime = tempTime.AddHours(1);
    labels[a] = tempTime.ToString("hh") + tempTime.ToString("tt");
}
//for (int i = 1; i < 20; i++)
//    labels[i] = "" + i * 2;
graph.XAxis.Type = AxisType.Text;
graph.XAxis.Scale.TextLabels = labels;

Above is the code I hard code the zed graph x axis, before I hard code it, this is the graph

https://i.sstatic.net/SNrm7.png

After apply the code to hard code, it become like this , please help


Solution

  •     string XAxis_ScaleFormatEvent(GraphPane pane, Axis axis, double val, int index)
        {
            if (index == 0)
            {
                return "this is 0 index";
            }
            else
            {
                return "else this is not 0 index";
            }
        }
    

    found answer, i need to add the event inside format event in the graph , hard code it by each label