我使用CorePlot 1.0,並想一個傳說添加到我的條形圖(這是一個子類XYGraph)。我有viewController中的數據源和圖例標題方法,它實例化條形圖並將其自身設置爲其委託。核心情節1.0:提供自定義標籤的傳奇
我已經花了不少的時間用不同的委託和圖例設置,但找不到我的錯誤。你能給我提示我可能犯了什麼錯誤嗎?
我有子類XYGraph生成柱狀圖如下:
.h
@interface BarLineChart : CPTXYGraph
@property (strong, nonatomic) id <CPTPlotDataSource, CPTBarPlotDataSource, CPTBarPlotDelegate, CPTPlotSpaceDelegate> delegate;
@end
我在執行.M,我成立了傳說如下:
// 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
永遠不會被調用。
你有沒有得到任何解決方案呢?我也有類似的問題 – SPatil 2012-03-26 13:10:35