Skip to content

Commit

Permalink
Add docs for x-labels.
Browse files Browse the repository at this point in the history
Fixed a small issue where labels which have more than one characters
will disappear.
  • Loading branch information
xhacker committed Dec 22, 2014
1 parent 8be1689 commit b1a7af8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ self.clockChart.data = @[

![Bar Chart](http://i.imgur.com/ScJksKh.png)

Just a bar chart, no label, no interaction, no animation.
Just a bar chart, no interaction, no animation.

```objective-c
#import "TEAChart.h"
Expand All @@ -107,6 +107,12 @@ barChart.data = @[@2, @7, @1, @8, @2, @8];
[self.view addSubview:barChart];
```

To add x-labels to the bar chart, set ``xLabels`` property. Should be just one character per label since the bars are narrow.

```objective-c
barChart.xLabels = @[@"A", @"B", @"C", @"D", @"E", @"F"];
```

## Installation

Use CocoaPods:
Expand Down
2 changes: 1 addition & 1 deletion TEAChart/TEABarChart.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (void)drawRect:(CGRect)rect
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init] ;
paragraphStyle.alignment = NSTextAlignmentCenter;

[label drawInRect:CGRectMake(idx * (barWidth + self.barSpacing), barMaxHeight + labelsTopMargin, barWidth, barWidth)
[label drawInRect:CGRectMake(idx * (barWidth + self.barSpacing), barMaxHeight + labelsTopMargin, barWidth, fontSize * 1.2)
withAttributes:@{
NSFontAttributeName:[UIFont fontWithName:@"HelveticaNeue" size:fontSize],
NSForegroundColorAttributeName:[UIColor colorWithWhite:0.56 alpha:1],
Expand Down

0 comments on commit b1a7af8

Please sign in to comment.