CorePlot中的断言失败

时间:2014-10-08 14:46:43

标签: ios core-plot

我最近开始在iPhone 6 plus上测试我的应用程序,当我使用绘制的图表中的核心图选择数据点时,我会收到以下错误消息:

断言失败 - [CPTXYPlotSpace setYRange:],/ Users / joshhamet / Download / core-plot-release_1.5.1 / framework / Resources / CPTXYPlotSpace.m:416

然而,它适用于我的iPhone 5非常好,所以我很好奇是否有人可以解释如何解决这个问题。这是一些代码。谢谢!

-(void)scatterPlot:(CPTScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:(NSUInteger)idx
{
/*Set the index selected and call for graph to be redrawn so selected symbol will be red*/
self.indexSelected=idx;
[self.graph reloadData];

CPTPlotRange *newXRange=[CPTPlotRange new];

/*If we have a daily graph, we need to calculate the x coordinate ourselves*/
if([self.graphTitle isEqualToString:@"Daily"]){
    double location=[[self xIndexForDailyGraph:idx]doubleValue]-1;
    if(location<=0)
        newXRange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0) length:CPTDecimalFromDouble(2)];
    else
        newXRange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(location) length:CPTDecimalFromDouble(2)];
}

/*Monthly and Weekly graphs x coordinate*/
else{
    if(!idx){
        newXRange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(idx) length:CPTDecimalFromDouble(2)];
    }
    else{
        newXRange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(idx-1) length:CPTDecimalFromDouble(2)];
    }
}

/*Determine the y index of the index (Depends on the current day or month)*/
if([self.graphTitle isEqualToString:@"Weekly"]){
    NSInteger weekday=[[NSCalendar currentCalendar]component:NSCalendarUnitWeekday fromDate:[NSDate date]];
    idx=(weekday+idx)%7;
}
if([self.graphTitle isEqualToString:@"Monthly"]){
    NSInteger currentMonth=[[NSCalendar currentCalendar]component:NSCalendarUnitMonth fromDate:[NSDate date]];
    idx=(currentMonth+idx)%12;
}

double selectedPoint=[[self.urinationDataArray[idx] objectForKey:@"amountOfUrine"]doubleValue];
CPTPlotRange *newYRange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(selectedPoint-10) length:CPTDecimalFromDouble(20)];

[CPTAnimation animate:self.plotSpace property:@"xRange" fromPlotRange:self.plotSpace.xRange toPlotRange:newXRange duration:.1 animationCurve:CPTAnimationCurveCubicInOut delegate:self];
[CPTAnimation animate:self.plotSpace property:@"yRange" fromPlotRange:self.plotSpace.yRange toPlotRange:newYRange duration:.1 animationCurve:CPTAnimationCurveCubicInOut delegate:self];

/*Add Text Annotation*/
[self addAnnotationAtRecordIndex:idx forPlot:plot];
}

1 个答案:

答案 0 :(得分:0)

这是Core Plot中的一个错误。我相信它已在GitHub的最新代码中得到修复。您需要从源代码中提取最新代码并构建Core Plot。查看change log以查看自1.5.1以来发生的所有变化。