Reference > Properties > XDateFormat Property

SharpPlot.XDateFormat Property

Set Date picture (X axis). When the X-axis is set to style ‘Date’, ‘Annual’ or ‘Monthly’, the date labels may be formatted with a standard picture format.

public string XDateFormat {get; set;}

Example

sp.XDateFormat = "MMM-yy";

Dates are formatted according to the current locale. Note that newlines are accepted in the format string to allow multi-line labels to be created easily for timeseries axes:

sp.XDateFormat = "MMMM\nyyyy";

This will create a 2-line set of labels which works well with the ‘Spanned’ style to centre the year below each set of 12 months.

Shortening month names

Timeseries are often labeled with the first character of the month name JFMAM ... D which cannot be generated with a standard date formatter. To have SharpPlot label the time-axis like this, use the MMM date format and set the XLabelFormat to a picture such as ‘X~~’ which will truncate the month name down to one character.

See also ...

SharpPlot | XAxisStyle | XLabelFormat | Formatting | Using


Send comments on this topic
© Dyalog Ltd 2013