sChartdataPointAtIndexforSeriesAtIndex returning nil


#1

Hello, 

on the - (id<SChartData>)sChart:(ShinobiChart*)chart dataPointAtIndex:(int)dataIndex forSeriesAtIndex:(int)seriesIndex; 

i am creating a SChartDataPoint, i also make a log of it just before the return witch prints …  { index=0, x=Service, y=31, selected=N }

but after the app crashes with Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil’

Any ideas ? 


#2

I currently have 3 series and for each series 1 datapoint.

It stop on the series index 0 dataPoint index 0. 


#3

Where is the stack error:

*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil’

*** First throw call stack:

(

0   CoreFoundation                      0x0258e5e4 __exceptionPreprocess + 180

1   libobjc.A.dylib                     0x023118b6 objc_exception_throw + 44

2   CoreFoundation                      0x02540c3c -[__NSArrayM insertObject:atIndex:] + 844

3   CoreFoundation                      0x025408e0 -[__NSArrayM addObject:] + 64

4   managed-services                    0x0019291d -[SChartOrderedDictionary setObject:forKey:] + 358

5   managed-services                    0x0014b272 -[SChartSeries addDataBinWithStartValue:] + 83

6   managed-services                    0x0014b2bc -[SChartSeries addDataBinToContainDataPoint:] + 64

7   managed-services                    0x0014af78 -[SChartSeries addDataPoint:] + 307

8   managed-services                    0x00191631 -[SChartDataLoader addChartDataPoint:toChartSeries:withIndex:atDataIndex:xAxis:yAxis:] + 229

9   managed-services                    0x0018f7dd -[SChartDataLoader populateChartSeries:atIndex:xAxis:yAxis:] + 841

10  managed-services                    0x0016ddc1 -[ShinobiChart loadNewChartSeriesEntries] + 1562

11  managed-services                    0x00174716 -[ShinobiChart layoutSubviews] + 2608

12  UIKit                               0x01436dd7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355

13  libobjc.A.dylib                     0x0232381f -[NSObject performSelector:withObject:] + 70

14  QuartzCore                          0x0119472a -[CALayer layoutSublayers] + 148

15  QuartzCore                          0x01188514 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380

16  QuartzCore                          0x01188380 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26

17  QuartzCore                          0x010f0156 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294

18  QuartzCore                          0x010f14e1 _ZN2CA11Transaction6commitEv + 393

19  QuartzCore                          0x010f1bb4 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92

20  CoreFoundation                      0x0255653e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30

21  CoreFoundation                      0x0255648f __CFRunLoopDoObservers + 399

22  CoreFoundation                      0x025343b4 __CFRunLoopRun + 1076

23  CoreFoundation                      0x02533b33 CFRunLoopRunSpecific + 467

24  CoreFoundation                      0x0253394b CFRunLoopRunInMode + 123

25  GraphicsServices                    0x0372b9d7 GSEventRunModal + 192

26  GraphicsServices                    0x0372b7fe GSEventRun + 104

27  UIKit                               0x013cc94b UIApplicationMain + 1225

28  managed-services                    0x0000cd9d main + 141

29  libdyld.dylib                       0x02acd725 start + 0

30  ???                                 0x00000001 0x0 + 1

)

libc++abi.dylib: terminating with uncaught exception of type NSException


#4

i have just added the following code on the (id<SChartData>)sChart:(ShinobiChart*)chart dataPointAtIndex:(int)dataIndex forSeriesAtIndex:(int)seriesIndex; 

and still gives me the same error…

    SChartDataPoint *dp = [SChartDataPointnew];

    dp.xValue = @“hue hue hue”;

    dp.yValue = [NSNumber numberWithInt:10];


#5

Everything seems to be OK with your datasource - sChart:dataPointAtIndex:forSeriesAtIndex: returns data in the right way. I had the same problem. Most likely you have forgotten to instantiate X and Y axes. In your viewDidLoad method (or wherever you set up your chart) add these lines:

- (void)viewDidLoad
{
    ShinobiChart *chartView = [[ShinobiChart alloc] initWithFrame:[self.view bounds]];
    // set up the chart
    // ...
    // Add axes
    [chartView setXAxis:[[SChartNumberAxis alloc] init]];
    [chartView setYAxis:[[SChartNumberAxis alloc] init]];
    // ...
    // Finally, add chart to your view
    [self.view addSubview:chartView];
}

#6

Thx was able to fix this problem a long time ago and forgot to post the aswer. 

Indid that was the solution :wink:  … the simple mistakes are the ones that take the most time.

Best regards and thx for help