My Program want to show the dynamic Data. y axis show the double data . x axis show the datetime data (for example:12:23:31 12:23:51 12:24:11 12:24:31 12:23:51). but the x axis of my Program show nothing . I think that the Form1_Load function has the problem .
The problem is because of the relationship between Scale.BaseTic and the MajorUnit/MinorUnit. If your scale is in "auto" mode, then ZedGraph makes all these settings for you. If you manually set your scale, then you must manually set the MajorUnit and MinorUnit.
Scale.MajorUnit determines the units of the major tics. So setting Scale.MajorUnit = DateUnit.Second means that your Scale.MajorStep value is in units of seconds. Also, the Scale.BaseTic value is automatically determined by ZedGraph unless you set it manually. The BaseTic calculation depends on the MajorUnit setting. So if the MajorUnit is not "consistent" with the scale range (e.g., don't use a majorunit of "days" if the scale range is in seconds), then the BaseTic might be set unreasonably. For example, if your scale range is 30 seconds and your MajorUnit is "days", and your MajorStep is 5/86400 (5 seconds equivalent in units of days), then the basetic will be selected at an even "day" unit, which will probably be way outside your scale range. That is, the range of the scale might cover 08:37 AM, while the nearest even "day" basetic is 00:00.
In your case, you have used MajorUnit = Seconds, but you specified your MajorStep in days. So, you can either specify your MajorStep in seconds, OR, you can specify your MajorStep in days and manually set the Scale.BaseTic property.
My Program want to show the dynamic Data. y axis show the double data . x axis show the datetime data (for example:12:23:31 12:23:51 12:24:11 12:24:31 12:23:51). but the x axis of my Program show nothing . I think that the Form1_Load function has the problem .
thinks for you
my code as follows:
public partial class Form1 : Form
{
private void Form1_Load(object sender, EventArgs e)
}
The problem is because of the relationship between Scale.BaseTic and the MajorUnit/MinorUnit. If your scale is in "auto" mode, then ZedGraph makes all these settings for you. If you manually set your scale, then you must manually set the MajorUnit and MinorUnit.
Scale.MajorUnit determines the units of the major tics. So setting Scale.MajorUnit = DateUnit.Second means that your Scale.MajorStep value is in units of seconds. Also, the Scale.BaseTic value is automatically determined by ZedGraph unless you set it manually. The BaseTic calculation depends on the MajorUnit setting. So if the MajorUnit is not "consistent" with the scale range (e.g., don't use a majorunit of "days" if the scale range is in seconds), then the BaseTic might be set unreasonably. For example, if your scale range is 30 seconds and your MajorUnit is "days", and your MajorStep is 5/86400 (5 seconds equivalent in units of days), then the basetic will be selected at an even "day" unit, which will probably be way outside your scale range. That is, the range of the scale might cover 08:37 AM, while the nearest even "day" basetic is 00:00.
In your case, you have used MajorUnit = Seconds, but you specified your MajorStep in days. So, you can either specify your MajorStep in seconds, OR, you can specify your MajorStep in days and manually set the Scale.BaseTic property.
Try this:
DateTime mynow = DateTime.Now;
myPane.XAxis.Type = AxisType.Date;
myPane.XAxis.Scale.Format = "T";
myPane.XAxis.Scale.MajorUnit = DateUnit.Second;
myPane.XAxis.Scale.MinorUnit = DateUnit.Second;
myPane.XAxis.Scale.Min = mynow.ToOADate();
myPane.XAxis.Scale.Max = mynow.AddSeconds(30).ToOADate();
myPane.XAxis.Scale.MinorStep = 1; // 1 second
myPane.XAxis.Scale.MajorStep = 5; // 5 seconds
This should work for you.
PS: Please don't double post.
John