Hi,
I am trying to add paddings to the both ends of the Xaxis, so the beginning and the end labels and data points could display. I see the paddings were added to the graph, but the labels on the XAxis are off, should start at Jan-06, and end at Sep-06, the grid also doesn't line up with the lable. Here is the code snippet, can you advise what I should do to get this right?
public void paddingXAxis(double offset, ChartControl myChart, ChartDateTimeIntervalType intervalType, int interval, string xaxisFormat)
{
DateTime dateMin=DateTime.Now,dateMax=DateTime.Now;
int dataCount = myChart.Series[0].SeriesModelImpl.Count;
if (dataCount > 0)
{
dateMin = DateTime.FromOADate(myChart.Series[0].SeriesModelImpl.GetX(0));
dateMax = DateTime.FromOADate(myChart.Series[0].SeriesModelImpl.GetX(dataCount-1));
}
int monthDiff = dateMax.Month - dateMin.Month;
int yrDiff = dateMax.Year - dateMin.Year;
if(yrDiff > 0)
monthDiff = monthDiff + 12*yrDiff;
switch(intervalType)
{
case ChartDateTimeIntervalType.Days: break;
case ChartDateTimeIntervalType.Months:
{
myChart.PrimaryXAxis.Offset = offset;
myChart.PrimaryXAxis.Range.Max += 2 * offset;
for(int i = 0; i <= monthDiff; i+=interval)
{
ChartAxisLabel lable = new ChartAxisLabel(i.ToString(), Color.Black, new Font("Arial",10,FontStyle.Bold), dateMin, xaxisFormat,xaxisFormat);
myChart.PrimaryXAxis.Labels.Add(lable);
dateMin.AddMonths(interval);
}
}
break;
}
}
thanks,
HB
lineChartIssue.zip