2012-03-15 13 views
0

のためのカスタムラベルを提供します。私は、データソースと凡例のタイトルメソッドをviewControllerに持っています。これは棒グラフをインスタンス化し、デリゲートとして自身を設定します。コアプロット1.0:私は<strong>CorePlot</strong> 1.0を使用していますが、(サブクラス化XYGraphである)私の<strong>棒グラフ</strong>に<strong>伝説</strong>を追加したいと思い伝説

私は、異なる代理人と伝説のセットアップでかなりの時間を費やしましたが、私のエラーは見つかりませんでした。私が間違いを犯した可能性がある箇所について私は何かヒントを教えてください。

私は次のように棒グラフを生成するXYGraphをサブクラス化している次のように私の実装.M

.h

@interface BarLineChart : CPTXYGraph 
@property (strong, nonatomic) id <CPTPlotDataSource, CPTBarPlotDataSource, CPTBarPlotDelegate, CPTPlotSpaceDelegate> delegate; 
@end 

、私は伝説を設定します。

// Add legend 
CPTLegend *legend   = [CPTLegend legendWithGraph:self]; 
legend.fill     = [CPTFill fillWithColor:[CPTColor colorWithGenericGray:0.15]]; 
legend.borderLineStyle  = axisLineStyle; 
legend.cornerRadius   = 10.0; 
legend.swatchSize   = CGSizeMake(16.0, 16.0); 
CPTMutableTextStyle *legendTextStyle = [CPTMutableTextStyle textStyle]; 
legendTextStyle.color  = [CPTColor whiteColor]; 
legendTextStyle.fontSize = 10.0; 
legend.textStyle   = legendTextStyle; 
legend.rowMargin   = 1.0; 
legend.numberOfRows   = 3; 
legend.paddingLeft   = 10.0; 
legend.paddingTop   = 10.0; 
legend.paddingRight   = 10.0; 
legend.paddingBottom  = 10.0; 
legend.delegate = self.delegate; 

self.legend     = legend; 
self.legendAnchor   = CPTRectAnchorTop; 
self.defaultPlotSpace.delegate = self.delegate; 

私は別のviewControllerにデータソースメソッドを保持しています。そのために、デリゲートを設定しています(self.delegateに格納されています)。 この私のViewControllerのインターフェイスされています

`@interface FinstatViewController : CompanyViewController <UITableViewDelegate, UITableViewDataSource, UISplitViewControllerDelegate, UIPopoverControllerDelegate, CompanyPresenter, ChartSelectionDelegate, CPTPlotDataSource, CPTBarPlotDataSource, CPTBarPlotDelegate, CPTPlotSpaceDelegate, CPTLegendDelegate, CPTScatterPlotDataSource, CPTScatterPlotDelegate>` 

マイデータソースメソッドプロットデータを取得するためには、正常に動作しますが、凡例のタイトル方法

-(NSString *)legendTitleForBarPlot:(CPTBarPlot *)barPlot recordIndex:(NSUInteger)index 

が呼び出されることはありません。

+0

これに関する解決方法はありますか?私も同様の問題があります – SPatil

答えて

1

凡例タイトルメソッドは、データソースの一部であり、デリゲートではありません。データソースとデリゲートが異なるクラスにある場合は、titleメソッドが正しいクラスに実装されていることを確認してください。

+0

エリック、私はデータソースメソッドを実装している私のビューコントローラで、タイトルメソッドを実装している。私はデバッガを使用して、私の代議員 'CPTPlotDataSource、CPTPlotSpaceDelegate、CPTBarPlotDataSource、CPTBarPlotDelegate、CPTLegendDelegate'を確認しており、正しく設定されているようです。私はデリゲートが恋しいですか?ありがとうございました! – AlexR

+0

同じデリゲートを使用する 'barFillForBarPlot'メソッドが正しく呼び出されます。ありがとうございました! – AlexR

関連する問題

 関連する問題