Skip to content

Stacked bar chart#21

Open
erwald wants to merge 7 commits intomichalkonturek:masterfrom
erwald:stacked
Open

Stacked bar chart#21
erwald wants to merge 7 commits intomichalkonturek:masterfrom
erwald:stacked

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