try
{
Chart1.ChartAreas[0].AxisX.Minimum = Front_Min.AddDays(-2).ToOADate();
Chart1.ChartAreas[0].AxisX.Maximum = Front_Max.AddDays(2).ToOADate();
double days = ( double )((TimeSpan)(Front_Max.AddDays(2) - Front_Min.AddDays(-2))).Days;
double labels = 2.0;
// check if the number of days is bigger than labels
if (days > labels)
{
// calculate the interval
double interval = days / labels;
Chart1.ChartAreas[0].AxisX.Interval = interval;
}
else
{
// set the interval of 1 day
Chart1.ChartAreas[0].AxisX.Interval = 1;
}
}
catch
{
//prevent null data
}
|