Search code examples
c#zedgraph

ZedGraph - How to hardcode axis value?


I am using zed graph for my new project, but sadly now i encounter one problem which is, on my graph, my starting x suppose to be 6 pm which is 18 on the x axis, my logic is , when it achieve 24, i want it the x axis value to back to 0 and continue to 1,2,3. Is it possible? i wish that i can put a algorithm in the x axis value so it can % with 24. Or if possible i wish i can hard code the x axis value too but it seem not possible. Anyone can help?


Solution

  • If you wanted to hard code the x-axis, you can specify labels for the x axis,

    string[] labels = new string[48];
    for(int i=0; i<24; i++)labels[i] = ""+i;
    for(int i=0; i<24; i++)labels[i] = ""+(i+24);
    ZedGraph.ZedGraphControl.GraphPane.XAxis.Type = AxisType.Text
    ZedGraph.ZedGraphControl.GraphPane.XAxis.Scale.TextLabels = labels;
    

    you can even add the am or pm label for each value.