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:

Configure a TKChartCategoryAxis

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

NSMutableArray *array = [[NSMutableArray alloc] init];
NSArray *categories = @[ @"Apple", @"Google", @"Microsoft", @"Samsung" ];
for (int i = 0; i<categories.count; i++) {
    [array addObject:[[TKChartDataPoint alloc] initWithX:categories[i] Y:@(arc4random() % 100)]];
TKChartColumnSeries *series = [[TKChartColumnSeries alloc] initWithItems:array];
series.selection = TKChartSeriesSelectionSeries;

TKChartCategoryAxis *xAxis = [[TKChartCategoryAxis alloc] initWithCategories:categories];
xAxis.position = TKChartAxisPositionBottom;
xAxis.plotMode = TKChartAxisPlotModeBetweenTicks;
xAxis.range = [TKRange rangeWithMinimumIndex:0 andMaximumIndex:3];
_chart.xAxis = xAxis;
var array = [TKChartBubbleDataPoint]()
let categories = ["Apple", "Google", "Microsoft", "Samsung"]

for item in 0..<categories.count {
    array.append(TKChartBubbleDataPoint(x: categories[item], y: Int(arc4random()%100), area: 0))

let series = TKChartColumnSeries(items:array)
series.selection = TKChartSeriesSelection.series

let xAxis = TKChartCategoryAxis(categories:categories)
xAxis.position = TKChartAxisPosition.bottom
xAxis.range = TKRange(minimumIndex: 0, andMaximumIndex: 3)
chart.xAxis = xAxis
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 = TKChartAxisPlotModeBetweenTicks;
xAxis.PlotMode = TKChartAxisPlotMode.BetweenTicks;

xAxis.plotMode = TKChartAxisPlotModeOnTicks;
xAxis.PlotMode = TKChartAxisPlotMode.OnTicks;