Page 1 of 1

X Axis Showing dd-MM only

Posted: Mon Jul 30, 2007 6:24 am
by 9640436
Hi,

I've got a chart which currently compares line series from different years, therefore the x-axis goes from 0 to 365. I would like it to have dd-MM format instead. How could I do this?

Thanks.

Posted: Mon Jul 30, 2007 9:17 am
by 9348258
Hi Dave

You can do it as below line:

Code: Select all

tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd-MM";

Posted: Mon Jul 30, 2007 11:38 pm
by 9640436
Hi Edu,

This will not work because, like I said earlier, my current x-axis values are integer from 0 to 365.

My series is filled by the following code:

Code: Select all

DateTime startYear = new DateTime(2007, 01, 01);
for (int i = 0; i<dRow.Length; i++)
{
DateTime currentDate = Convert.ToDateTime(dRow[i]["date"].ToString())
TimeSpan ts = currentDate.Subtract(startYear)
int daysDifference = ts.Days;

lineSeries.Add(daysDifference, Single.Parse(dRow[i]["values"].ToString()))
}
Instead of showing daysDifference on the x-axis, I would like to show a DateTime x-axis with a format of "dd-MM". How could I do it?

Posted: Tue Jul 31, 2007 4:56 am
by 9640436
Hi Edu,

Pls ignore my question. I've managed to plot what I wanted by substituting the years with a common year (for example, 2000), then setting the x-axis format to "dd-MM".

Thanks.