开发者

Difference on core plot CPTBarPlotFieldBarLocation and CPTBarPlotFieldBarTip?

开发者_运维知识库

I'm new to core plot and wondering what the difference is on CPTBarPlotFieldBarLocation and CPTBarPlotFieldBarTip. I have been looking at the core plot example CPTTestApp_ipadViewController and I have seen that both of these field enum are called during filling the ploy with the numberForPlot-method but I don't understand the difference.

Thanks for any help


The difference is very huge. If we look at definition of type CPTBarPlotField in CPTBarPlot we will see that there are three values in that enum:

  1. CPTBarPlotFieldBarLocation : Bar location on independent coordinate axis.
  2. CPTBarPlotFieldBarTip : Bar tip value.
  3. CPTBarPlotFieldBarBase : Bar base (used only if barBasesVary is YES).

You can ask - where can I use that values? Ok, you should use this constants in method -(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index. In that method you should return values of that properties for each individual bar. For example,

-(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")];
}

In my example I have dictionary which contains values for x axis (locations of bars) and y (values of bars).

I want to mention, that you should not set property plotRange of your CPTBarPlot *plot or CorePlot will set locations of your bars automatically (at position 0,1,2,3,4....).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜