Chart Axes: Datetime

The TKChartDateTimeAxis Categoric axis is an axis with NSDate values sorted chronologically. It also allows definitions of categories based on specific date time components – year, month, day etc. For example, if data values fall in the range of one year, the points can be plotted in categories for each month. If data values fall in the range of one month, the values can be categorized by days. It also introduces several important properties:

  • majorTickInterval - defines an interval between major axis ticks.

  • baseline - defines how the series data should be aligned. For example: The TKChartBarSeries might render its bars up and down depending on whether its value is greater or less than the baseline value.

  • offset - determines an axis value where the axis is crossed with another axis.

Configure a TKChartDateTimeAxis

You can configure a date-time axis by initializing it and setting it as the main x-axis or y-axis of the chart:

TKChartDateTimeAxis xAxis = new TKChartDateTimeAxis (minDate, maxDate);
xAxis.MajorTickIntervalUnit = TKChartDateTimeAxisIntervalUnit.Months;
xAxis.MajorTickInterval = 1;

You can define the axis categories by changing the interval unit property to one of the following values: TKChartDateTimeAxisIntervalUnitSeconds - The majorTickInterval is measured in seconds. TKChartDateTimeAxisIntervalUnitMinutes - The majorTickInterval is measured in minutes. TKChartDateTimeAxisIntervalUnitHours - The majorTickInterval is measured in hours. TKChartDateTimeAxisIntervalUnitDays - The majorTickInterval is measured in days. TKChartDateTimeAxisIntervalUnitWeeks - The majorTickInterval is measured in weeks. TKChartDateTimeAxisIntervalUnitMonths - The majorTickInterval is measured in months. TKChartDateTimeAxisIntervalUnitYears - The majorTickInterval is measured in years. TKChartDateTimeAxisIntervalUnitCustom - The majorTickInterval is measured in ticks.

Setting a plotting mode of axis

The TKChartAxisPlotMode is used by the axis to plot the data. Possible values are TKChartAxisPlotModeBetweenTicks and TKChartAxisPlotModeOnTicks. TKChartAxisPlotModeBetweenTicks plots points in the middle of the range, defined by two ticks. OnTicks plots the points over each tick.

You should use the following lines of code to alter this behavior:

xAxis.PlotMode = TKChartAxisPlotMode.BetweenTicks;

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article