Chart Axes: Categoric

TKChart uses Categoric axes to plot data that contains categoric values. The axis is valid only in the context of Cartesian series. It also introduces several important properties:

  • majorTickInterval - defines an interval among major axis ticks.

  • minorTickInterval - defines an interval among minor axis ticks.

  • baseline - contains a value, which 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 TKChartCategoryAxis

You can configure a category axis by settings its categories property. You should use the following code snippet as a sample:

List<TKChartDataPoint> list = new List<TKChartDataPoint> ();
string[] categories = new []{"Apple", "Google", "Microsoft", "Samsung"};
for (int i = 0; i < categories.Length; i++) {
    list.Add(new TKChartDataPoint(new NSString(categories[i]), new NSNumber(r.Next() % 100))); 
}

TKChartColumnSeries series = new TKChartColumnSeries (list.ToArray());
series.Selection = TKChartSeriesSelection.Series;

TKChartCategoryAxis xAxis = new TKChartCategoryAxis ();
xAxis.Position = TKChartAxisPosition.Bottom;
xAxis.PlotMode = TKChartAxisPlotMode.BetweenTicks;
series.XAxis = xAxis;

You can specify the axis range by setting the minimum and maximum indexes of categories.

Setting the plot 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;

xAxis.PlotMode = TKChartAxisPlotMode.OnTicks;