【问题标题】:Difference on core plot CPTBarPlotFieldBarLocation and CPTBarPlotFieldBarTip?核心图 CPTBarPlotFieldBarLocation 和 CPTBarPlotFieldBarTip 的区别?
【发布时间】:2011-07-19 06:29:44
【问题描述】:
我是核心情节的新手,想知道CPTBarPlotFieldBarLocation 和CPTBarPlotFieldBarTip 的区别是什么。我一直在查看核心情节示例CPTTestApp_ipadViewController,并且我看到在使用numberForPlot-方法填充策略期间调用了这两个字段枚举,但我不明白其中的区别。
感谢您的帮助
【问题讨论】:
标签:
iphone
core-plot
cptbarplot
【解决方案1】:
差别很大。如果我们查看CPTBarPlot 中CPTBarPlotField 类型的定义,我们将看到该枚举中有三个值:
-
CPTBarPlotFieldBarLocation : 独立坐标轴上的条形位置。
-
CPTBarPlotFieldBarTip : 条形提示值。
-
CPTBarPlotFieldBarBase : 柱基(仅在 barBasesVary 为 YES 时使用)。
您可以问 - 我可以在哪里使用这些值?好的,你应该在方法-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index 中使用这个常量。在该方法中,您应该为每个单独的柱返回该属性的值。例如,
-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
int plotIndex = [(NSNumber *)plot.identifier intValue];
return [[[datas objectAtIndex:plotIndex] objectAtIndex:index] valueForKey:(fieldEnum == CPTBarPlotFieldBarLocation ? @"x" : @"y")];
}
在我的示例中,我有一个字典,其中包含 x 轴(条形位置)和 y(条形值)的值。
我想提一下,你不应该设置 plotRange 的属性 CPTBarPlot *plot 或 CorePlot 会自动设置你的酒吧的位置(在位置 0,1,2,3,4....) .