0

我已经升级到最新版本的 Coreplot (1.2) 并遇到了一个问题。

我的图表里面有两个图。条形图和散点图。散点图是连接条的线表示。在 1.1 版本中一切正常,但是当我切换到 1.2 时,散点图似乎放错了位置。这是从左一点开始的孩子。这是图像:

在此处输入图像描述

这些绘图符号和整个散点图与条形图完全同步(即符号在自由条的中间,而不是在它之外,符号在网格线上)应该是这样。返回的点numberForPlot是相同的值。

这是我的numberForPlot方法以防万一:

- (NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)idx
{
if ([plot.identifier isEqual:kBarPlot] )
{
    if (fieldEnum == CPTBarPlotFieldBarLocation)
        return [NSNumber numberWithInt:[self.intervalStringArray indexOfObject:[allKeys objectAtIndex:idx]]];

    NSArray *activitiesForDate = [activitiesByDate valueForKey:[allKeys objectAtIndex:idx]];
    double activityAmount = 0.0;
    if (activitiesForDate)
    {
        //compute value
    }

    DebugLog(@"Barplot returning Y= %f forindex = %d", activityAmount, idx);
    return [NSNumber numberWithDouble:activityAmount];
}
if ([plot.identifier isEqual:kScatterPlot])
{
    NSString *currentDate = [[self activityDatesAsString] objectAtIndex:idx];
    if (fieldEnum == CPTScatterPlotFieldX)
    {
        int currentIndex = [self.intervalStringArray indexOfObject:currentDate];
        return [NSNumber numberWithInt:currentIndex];
    }


    NSArray *activitiesForDate = [self activitiesForDate:[self.dateFormatter dateFromString:currentDate]];
    float netActivity = 0.0;

    //compute netActvity
    DebugLog(@"SCATTERPLOT returning %@ for index %d", [NSNumber numberWithFloat:netActivity], idx);
    return [NSNumber numberWithFloat:netActivity];
}
return nil;

}

最后,日志输出是;

SCATTERPLOT returning -8 for index 0
SCATTERPLOT returning -4 for index 1
Barplot returning Y= -8.000000 for  index = 0
Barplot returning Y= -4.000000 for  index = 1

编辑:虽然我几乎已经在这里发布了代码,但即使散点图在图中单独存在,问题仍然存在。已经找到问题了,不知道是正常的还是bug。问题在于CPTMutableShadow

CPTScatterPlot *netActivityPlot = [[[CPTScatterPlot alloc] init] autorelease];
   netActivityPlot.identifier = kNetActivityPlot;
   netActivityPlot.title = @"Net Activity";

   CPTMutableLineStyle *lineStyle = [[netActivityPlot.dataLineStyle mutableCopy] autorelease];
   lineStyle.lineWidth              = 2.0;
   lineStyle.lineColor              = _cptNetActivityLineColor;
   netActivityPlot.dataLineStyle = lineStyle;
   netActivityPlot.dataSource    = self;
   CPTMutableShadow *shadow = [CPTMutableShadow shadow];
   shadow.shadowColor = [CPTColor lightGrayColor];
   shadow.shadowOffset = CGSizeMake(2.0, -2.0);
   shadow.shadowBlurRadius = 4.0f;
   netActivityPlot.shadow = shadow;
   [activityGraph addPlot:netActivityPlot];

   netActivityPlot.plotSpace = (CPTXYPlotSpace *)activityGraph.defaultPlotSpace;

当我移除阴影时,情节适合线条。

4

1 回答 1

0

据报道这是一个错误。作为新问题放置在 Core Plot问题跟踪器上。

于 2013-05-10T08:37:51.710 回答