Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacked bar chart #21

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Stacked bar chart #21

wants to merge 7 commits into from

Conversation

erwald
Copy link

@erwald erwald commented Apr 27, 2015

Hey,
I needed to write a GKStackedBarGraph class based on the regular GKBarGraph class, and figured it may be of general interest. It's basically the same as the bar chart, except each bar consists of several segments (stacks) of colour. I added an example so that you can take a look.

The protocol looks like so:

- (NSInteger)numberOfBars;
- (NSInteger)numberOfStacks;
- (NSNumber *)valueForBarAtIndex:(NSInteger)index stack:(NSInteger)stack;

@optional
- (UIColor *)colorForBarAtIndex:(NSInteger)index stack:(NSInteger)stack;
- (UIColor *)colorForBarBackgroundAtIndex:(NSInteger)index;
- (CFTimeInterval)animationDurationForBarAtIndex:(NSInteger)index;
- (NSString *)titleForBarAtIndex:(NSInteger)index;

Note: It's not very well tested. Also, its draw animation is not as pretty as it could be.
// E. G.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants