how to set new plot data for bar chart using core-plot?
I am new to objective-c and xcode. It would be开发者_开发百科 very thankful if someone can point how to set new plot data for bar chart using core-plot. I need to set data like : y-axis and x-axis : as (10,1), (5,2), (20,3), (15,4) and the output should come as :
--------------------- 30 25 20 # 15 # # 10 # # # 5 # # # # 1 2 3 4 ---------------------
It would be great if someone can provide me the .m and .h file Thanks in advance
Joshua
Look at the programs in the examples folder in your Core Plot directory. All three CPTestApp programs (Mac, iPhone, and iPad) have bar plots.
The function numberForPlot is where you define your datas you want to plot:
-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
NSNumber *num = nil;
if ( [plot isKindOfClass:[CPBarPlot class]] ) {
switch ( fieldEnum ) {
case CPBarPlotFieldBarLocation:
num = (NSNumber *)[NSNumber numberWithFloat:[[*yourArray* objectAtIndex:index] floatValue]];
break;
case CPBarPlotFieldBarLength:
num = (NSNumber *)[NSNumber numberWithFloat:[[*yourOtherArray* objectAtIndex:index] floatValue]];
break;
}
}
return num;
}
You just have to insert datas in your arrays.
精彩评论