views:

55

answers:

0

I apologize for cross-posting to this and to the discussion list, but more eyes are better.

I'm trying to create a discontinuous plot using the method described here: http://groups.google.com/group/coreplot-discuss/browse_thread/thread/..., and I'm having trouble getting the plots to render. I have one continuous plot that is associated with the default plotspace that works just fine. In order to create the discontinuous plots, I create new plots and plotspaces as shown here: http://gist.github.com/479204 (code pasted below for convenience). What am I doing wrong? The numberForPlot:field:recordIndex: method is never asked about these other plot segments - only the plots that are added to the default plotspace.

NSMutableArray *plots = [NSMutableArray arrayWithCapacity:5];
CPScatterPlot *plot = nil;
CPXYPlotSpace *plotSpace = nil;

for (id record in data) {
  // determine beginning and end of plot segment
  // ...

  if (beginning) {
    plot = [[[CPScatterPlot alloc] init] autorelease];
    plot.identifier = /* set to unique string */;
    plot.dataLineStyle = [CPlineStyle lineStyle];
    plot.dataLineStyle.lineColor = [CPColor colorWithCGColor:[[UIColor whiteColor] CGColor]];
    plot.dataSource = self;
  }

  if (end) {
    plotSpace = [[[CPXYPlotSpace alloc] init] autorelease];
    plotSpace.xRange = [CPPlotRange plotRangeWithLocation:beginning length:end - beginning];
    plot.plotSpace = plotSpace;
    [plots addObject:plot];
  }
}

for (CPPlot *p in plots) {
    /*
        I may be missing a cast here - but that's a bit beside the point, which is simply to ensure 
        that all these segments have the same yRange as the default.
    */
    ((CPXYPlotSpace*)p.plotSpace).yRange = graph.defaultPlotSpace.yRange;  
    [graph addPlot:p toPlotSpace:p.plotSpace];
}