xAxis label formatting


#1

Hi, 

I’m trying to present the labels on the X axis as a string, but not sure how to go about it. 

How do I get it to display a string and not numbers? I’ve looked at the examples and cant figure it out :slight_smile:

My DataPointAtIndex method looks like this:

-(id<SChartData>)sChart:(ShinobiChart *)chart dataPointAtIndex:(int)dataIndex forSeriesAtIndex:(int)seriesIndex {
    
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setDateStyle:NSDateFormatterShortStyle];
    
    SChartDataPoint *datapoint = [[SChartDataPoint alloc] init];
    
    datapoint.xValue = [df stringFromDate:[[weights objectAtIndex:dataIndex] date]];
    datapoint.yValue = [[weights objectAtIndex:dataIndex] weight];
    
    return datapoint;
}

#2

OK, so I figured it (thankyou Google)

When I instantiated the Chart I set the Axis type to SChartNumberAxis and not SChartCategoryAxis. It mentions this in the docs, but if you dont know what you are looking for… http://www.shinobicontrols.com/docs/ShinobiControls/ShinobiCharts/2.2.0/Standard/Normal/Classes/SChartAxis.html

 So here is what I needed to do:

SChartCategoryAxis *xAxis = [SChartCategoryAxis new];