Modify X axis on my Graph


#1

Hi All,

I have a very simple query regarding Shinobi Charts on iOS.

My current requirements is to display a graph which has the x axis to show the 7 days of the week and y axis plots some values for each day of the week. I use the default Shinobi Provided APIs and the X axis populates the data points as numbers i.e 1 through 7 . I want the X-axis to show mon , tue…to sat . However If i make the corresponding changes the X axis label is simply blank. Can someone point me to the right documentation or sample code for this. There seems to be too much material online and its really confusing  :cry:

Relevant code :

SChartNumberRange *range=[[SChartNumberRangealloc]initWithMinimum:[NSNumbernumberWithInt:1] andMaximum:[NSNumbernumberWithInt:7]];
 SChartNumberAxis *xAxis = [[SChartNumberAxisalloc] initWithRange:range];
  _arr_majorXAxis = [[NSMutableArrayalloc] init];
 [_arr_majorXAxisaddObject:[NSNumbernumberWithInt:1]];
 [_arr_majorXAxisaddObject:[NSNumbernumberWithInt:2]];
 [_arr_majorXAxisaddObject:[NSNumbernumberWithInt:3]];
 [_arr_majorXAxisaddObject:[NSNumbernumberWithInt:4]];
 [_arr_majorXAxisaddObject:[NSNumbernumberWithInt:5]];
 [_arr_majorXAxisaddObject:[NSNumbernumberWithInt:6]];
 
 [_arr_majorXAxisaddObject:[NSNumbernumberWithInt:7]];
 
 //This display the X axis from 1 to 7 , if I do the code below then X axis is blank , looks like the chart cannot recognise it
    /*
    [_arr_majorXAxis addObject:@"Mon"];
    [_arr_majorXAxis addObject:@"Tue"];
    [_arr_majorXAxis addObject:@"Wed"];
 
    [_arr_majorXAxis addObject:@"Thur"]; */

#2

Hi sim7777,

We’re always looking for ways to improve discoverability of our API and our reference/learning materials, so it would be really interesting to find out a little bit more from you on there being too much material online. It would be great if you could send an email (with a reference to this forum thread) to info@shinobicontrols.com so we can discuss this with you to find out what we can do to improve things.

With regards to the issue you’re having, I notice that you are using an SChartNumberAxis - these are designed for numeric data, so the problem may be as simple as using an axis that isn’t suited to the data. It looks like an SChartCategory axis might be a better fit to your use case - the categories being “Mon”, “Tues” etc.

Let me know how you get on with this issue :slight_smile:


#3

Thank you for the post. I got it working using the SChartCategory axis and explicitly setting the datapoint.xvalue based on my requirements