We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Exporting a chart with DateTime on x axis

Hi,

I am exporting charts where the category axis is always of DateTime type. I would like to set the maximum/ minimum values on the category axis, but the properties

chart.PrimaryCategoryAxis.MinimumValue
chart.PrimaryCategoryAxis.MaximumValue

only allow double values to be set. How can I set these for a DateTime axis?

Also, rather than letting Syncfusion/Excel pick the category axis markings arbitrarily, is it possible to force a more sensible system
(e.g. if my x axis spans 20 years, it is sensible to show the first day of each year along the x axis). This won't always happen depending on e.g. my first plotted date. I don't want to insert all category labels manually though!

Thanks.


1 Reply

GM Geetha M Syncfusion Team May 24, 2010 09:24 AM UTC

Hi,

Thank you for your interest in Syncfusion products.

Currently it is not possible to set minimum value and maximum value. However, you can manipulate the labels and use them at IChartSerie.CategoryLabels property. You can manipulate the values for the CategoryAxis and place them inside the sheet (for example the first day of the year if the actual range spans 20 years).

// Create Categorylabels and assign it.
sheet["D1"].DateTime = new DateTime(1989, 1, 1);
sheet["A4:A23"].CopyTo(sheet["D2"], ExcelCopyRangeOptions.All);
sheet["D22"].DateTime = new DateTime(2010, 1, 1);

IChartSerie serie = chartShape.Series[0];
serie.CategoryLabels = sheet["D1:D22"];

// Set the date format
chartShape.PrimaryCategoryAxis.NumberFormat = "ddd, yy";

I have placed the sample in the link below.
http://help.syncfusion.com/samples/XlsIO.Windows/F94592/F94592.zip

Please try this and let me know if you have any questions.

Regards,
Geetha

Loader.
Live Chat Icon For mobile
Up arrow icon