所以我的問題很簡單。我試圖將我的圖表從條形圖切換到折線圖,但我的折線圖不顯示/繪圖。我爲我的CPTBarPlot'條形圖'使用類似的代碼,並且這種繪製/顯示正確。核心情節CPTScatterPlot'線圖'沒有顯示
其正確繪製我的柱狀圖中的代碼是:
CPTBarPlot *barPlot = nil;
barPlot = [CPTBarPlot tubularBarPlotWithColor:[CPTColor colorWithComponentRed:0.9294f green:0.3960f blue:0.5921f alpha:1.0f] horizontalBars:NO];
barPlot.fill = [CPTFill fillWithColor:[CPTColor colorWithComponentRed:0.9294f green:0.3960f blue:0.5921f alpha:1.0f]];
barPlot.opacity = 0.8f;
barPlot.dataSource = self;
barPlot.delegate = self;
barPlot.baseValue = CPTDecimalFromString(@"0");
barPlot.barOffset = CPTDecimalFromFloat(0.50f);
switch (graphType) {
case kWeightThreeMonth:
{
barPlot.identifier = [GraphsViewController threeMonthBarPlotIdentifier];
}
break;
case kWeightSixMonth:
{
barPlot.identifier = [GraphsViewController sixMonthBarPlotIdentifier];
}
break;
case kWeightNineMonth:
{
barPlot.identifier = [GraphsViewController nineMonthBarPlotIdentifier];
}
break;
default:
break;
}
barPlot.barCornerRadius = 2.0f;
barPlot.lineStyle = nil;
[lineGraph addPlot:barPlot toPlotSpace:plotSpace];
我的折線圖碼不顯示的是:
// Create a blue plot area
CPTScatterPlot *boundLinePlot = [[[CPTScatterPlot alloc] init] autorelease];
CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];
lineStyle.miterLimit = 1.0f;
lineStyle.lineWidth = 3.0f;
lineStyle.lineColor = [CPTColor redColor];
boundLinePlot.dataLineStyle = lineStyle;
switch (graphType) {
case kWeightThreeMonth:
{
boundLinePlot.identifier = [GraphsViewController threeMonthBarPlotIdentifier];
}
break;
case kWeightSixMonth:
{
boundLinePlot.identifier = [GraphsViewController sixMonthBarPlotIdentifier];
}
break;
case kWeightNineMonth:
{
boundLinePlot.identifier = [GraphsViewController nineMonthBarPlotIdentifier];
}
break;
default:
break;
}
boundLinePlot.dataSource = self;
boundLinePlot.delegate = self;
[lineGraph addPlot:boundLinePlot toPlotSpace:plotSpace];
// Do a blue gradient
CPTColor *areaColor1 = [CPTColor colorWithComponentRed:0.3 green:0.3 blue:1.0 alpha:0.8];
CPTGradient *areaGradient1 = [CPTGradient gradientWithBeginningColor:areaColor1 endingColor:[CPTColor clearColor]];
areaGradient1.angle = -90.0f;
CPTFill *areaGradientFill = [CPTFill fillWithGradient:areaGradient1];
boundLinePlot.areaFill = areaGradientFill;
boundLinePlot.areaBaseValue = [[NSDecimalNumber zero] decimalValue];
// Add plot symbols
CPTMutableLineStyle *symbolLineStyle = [CPTMutableLineStyle lineStyle];
symbolLineStyle.lineColor = [CPTColor blackColor];
CPTPlotSymbol *plotSymbol = [CPTPlotSymbol ellipsePlotSymbol];
plotSymbol.fill = [CPTFill fillWithColor:[CPTColor blueColor]];
plotSymbol.lineStyle = symbolLineStyle;
plotSymbol.size = CGSizeMake(10.0, 10.0);
boundLinePlot.plotSymbol = plotSymbol;
我失去了一些東西在這裏?考慮到條形圖工作正常,我會認爲數據源等都會以相同的方式工作。我只是試圖從條形圖切換到折線圖。
任何幫助將不勝感激。
親切的問候, 丹
嗨skyram。不幸的是,我已經在我的代碼底部做了這些工作(未在我的原始文章中展示過)。奇怪的是,我希望條形圖和折線圖以類似的方式工作。不知道爲什麼條形圖能夠正確地繪製和顯示,而折線圖卻沒有。兩者之間的差異基本上是我原來的帖子中的代碼。謝謝 –