CorePlotを習得しようとしています。私は "codejunkster"のコード例を見つけましたが、これは "T"に従っていますが、動作しません。私はそれをnumberForPlotメソッドに絞りました。コードは以下の通りです。どちらの条件も真実ではなく、私は理由を理解できません。下記のチュートリアル、パーコアプロット "numberForPlot"が正しく実行されない
-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
if ([plot.identifier isEqual:@"chocoplot"])
{
NSDictionary *bar = [self.dataForChart objectAtIndex:index];
if(fieldEnum == CPTBarPlotFieldBarLocation)
{
return [bar valueForKey:BAR_POSITION];
NSLog(@"return [bar valueForKey:BAR_POSITION]");
}
else if(fieldEnum ==CPTBarPlotFieldBarTip){
NSLog(@"return [bar valueForKey:BAR_HEIGHT];");
return [bar valueForKey:BAR_HEIGHT];
}
}
return [NSNumber numberWithFloat:0];
}
これはおそらくバグですか、あなたは、プロットの別のタイプを初期化した
// Create bar plot and add it to the graph
CPTBarPlot *plot = [[CPTBarPlot alloc] init] ;
plot.dataSource = self;
plot.delegate = self;
plot.barWidth = [[NSDecimalNumber decimalNumberWithString:@"5.0"]
decimalValue];
plot.barOffset = [[NSDecimalNumber decimalNumberWithString:@"10.0"]
decimalValue];
plot.barCornerRadius = 5.0;
// Remove bar outlines
CPTMutableLineStyle *borderLineStyle = [CPTMutableLineStyle lineStyle];
borderLineStyle.lineColor = [CPTColor clearColor];
plot.lineStyle = borderLineStyle;
// Identifiers are handy if you want multiple plots in one graph
plot.identifier = @"chocoplot";
[self.graph addPlot:plot];
もう少しスヌーピングしました。 fieldEnumは1に等しい.CPTBarPlotFieldBarLocationおよびCPTBarPlotFieldBarTipの値はそれぞれ2および3である。どのようにfieldEnumは値を取得しますか。 CPTBarPlotメソッドはどのようにこの値を取得/保持しますか? –
"chocoplot"は棒グラフですか?どのバージョンのCore Plotを使用していますか?バープロットフィールドの列挙型は0.9以降に変更されました。 –
chocoplotは、グラフ/プロットのデータソースとデリゲートメソッドの識別子です。私はMercurialを使用してダウンロードしたCorePlotの最新バージョンを使用しています。 –