I want to plot a bar-graph in my application. How should I do it exactly ?(I have no idea in Graphs). Please suggest some steps to start with and go on.
Thanks
depends on what you really want. If you just need a bunch of ugly bars core-plot might be a bit too much for you.
It takes this much code to implement a bargraph. I think this is like half the code you would need for core-plot datasources. And even a nice implementation will take less time than integrating core-plot into your project.
Core-plot is a big fat monster. Like all those "I can do everything you want"-frameworks.
- (void)drawRect:(CGRect)rect {
CGFloat height = self.bounds.size.height;
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClearRect(context, rect);
CGContextSetFillColorWithColor(context, [UIColor grayColor].CGColor);
CGFloat barWidth = 30;
int count = 0;
for (NSNumber *num in values) {
CGFloat x = count * (barWidth + 10);
CGRect barRect = CGRectMake(x, height - ([num floatValue] * height), barWidth, [num floatValue] * height);
CGContextAddRect(context, barRect);
count++;
}
CGContextFillPath(context);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With