Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to set the xRange and yRange for the plotspace to set the range of values the plot will show. Something like:</p> <pre><code>plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace; plotSpace.xRange = [CPTPlotRange plotRangeWithLocation: CPTDecimalFromDouble(-5.0) length: CPTDecimalFromDouble(10.0)]; plotSpace.yRange = [CPTPlotRange plotRangeWithLocation: CPTDecimalFromDouble(-5.0) length: CPTDecimalFromDouble(10.0)]; </code></pre> <p>To get actual points to show up, you need to set up the graph's dataSource object, and it needs to respond to the datasource methods:</p> <pre><code>-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot; -(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index; </code></pre> <p>If you only have one plot, you can ignore the first argument to numberForPlot:. The second argument will be 0 when it wants the x axis value for the point, and it will be 1 when it wants the Y axis value for the point. Index is the point number for your plot. So assuming you have the data in an NSArray called myDataArray, where each object in that array is another NSArray of x,y values, you'll have something like:</p> <pre><code>-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot; { return [myDataArray count]; } -(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index; { return [[myDataArray objectAtIndex: index] objectAtIndex: fieldEnum]; } </code></pre> <p>You can set up the data array with fixed data like:</p> <pre><code>NSArray *myDataArray = [NSArray arrayWithObjects: [NSArray arrayWithObjects: [NSNumber numberWithInt: 2], [NSNumber numberWithInt: 3], nil], [NSArray arrayWithObjects: [NSNumber numberWithInt: 3], [NSNumber numberWithInt: 2], nil], [NSArray arrayWithObjects: [NSNumber numberWithInt: 5], [NSNumber numberWithInt: 5], nil], nil]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload