Skip to content

Commit b1a7af8

Browse files
committed
Add docs for x-labels.
Fixed a small issue where labels which have more than one characters will disappear.
1 parent 8be1689 commit b1a7af8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ self.clockChart.data = @[
8484

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

87-
Just a bar chart, no label, no interaction, no animation.
87+
Just a bar chart, no interaction, no animation.
8888

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

110+
To add x-labels to the bar chart, set ``xLabels`` property. Should be just one character per label since the bars are narrow.
111+
112+
```objective-c
113+
barChart.xLabels = @[@"A", @"B", @"C", @"D", @"E", @"F"];
114+
```
115+
110116
## Installation
111117

112118
Use CocoaPods:

TEAChart/TEABarChart.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ - (void)drawRect:(CGRect)rect
6363
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init] ;
6464
paragraphStyle.alignment = NSTextAlignmentCenter;
6565

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

0 commit comments

Comments
 (0)