0
我已升級到最新版本的Coreplot(1.2)並遇到問題。Coreplot滑在ScatterPLot位置
我的圖裏面有兩個圖。條形圖和散點圖。散點圖是連接條的線表示形式。在1.1版本中都運行良好,但是當我切換到1.2時,Scatter情節似乎錯位了。這是從左邊開始的。以下是圖像:
那些plotsymbols和整個散點圖是正確與柱狀圖同步(即符號是在freen條的中間,而不是它的外部和符號是上網格線),因爲它應該是。從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
編輯:雖然我已經快要完成了,甚至持續的問題在這裏張貼代碼時散點圖是單獨在圖中。我發現了這個問題,但我不知道這是正常還是錯誤。問題在於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;
當我刪除的影子,劇情適合的線路。
這是在iOS或Mac OS X上?什麼版本?如果調整窗口大小/旋轉設備或滾動圖表會發生什麼情況? – 2013-05-07 00:29:57
它在iPad上。旋轉/滾動/調整大小沒有任何變化。希望有一個快速解決方案,雖然我似乎無法找到它。 – 2013-05-07 07:17:19
我在您發佈的代碼中看不到任何內容。你可以發佈這兩個地塊的設置代碼嗎?這些地塊是否有共享一個地塊空間,或者你有多個地塊? – 2013-05-08 01:27:06