Am using a ZedGraph in which data is plotted for a period of more than one year. When its initially displayed, its showing the data in a single shot but the X-axis is in DateTime format. How can I set the X axis values to Year at the time of loading? I need to change the format on different zooming levels ie, on further zooming the format should be MMM/yyyy followed by DD/MMM/yyyy and DD/MMM/yyyy HH:MM:ss
Asked
Active
Viewed 556 times
1 Answers
2
Before loading your data your should set something like:
zedgraphControl.GraphPane.XAxis.Scale.Format = "dd.MM.yyyy";
And in zedgraphControl_ZoomEvent
you can change scale format again like
private void zedgraphControl_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState)
{
GraphPane pane = sender.GraphPane;
pane.XAxis.Scale.Format = "dd.MM.yyyy HH:mm:ss";
}
In this event you can add some conditions depends on your current scale.

Varro
- 73
- 1
- 11
-
1To run a test on your current scale, check the value of `yourGraph.GraphPane.XAxis.Scale.MajorUnit` – RMGT Sep 08 '16 at 15:41