Skip to content

Commit 03ff4fd

Browse files
Streamlined interface.
1 parent d014e3f commit 03ff4fd

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

GraphKit/Example/ExampleBarGraphVC.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ - (void)viewDidLoad {
3232
// self.graphView.barWidth = 22;
3333
// self.graphView.barHeight = 140;
3434
// self.graphView.marginBar = 25;
35-
self.graphView.dataSource = self;
3635

37-
[self.graphView construct];
3836
self.graphView.animationDuration = 2.0;
37+
self.graphView.dataSource = self;
38+
3939
[self.graphView draw];
4040

4141
self.green = YES;

Source/BarGraph/GKBarGraph.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
@property (nonatomic, assign) CGFloat barWidth;
2626
@property (nonatomic, assign) CGFloat marginBar;
2727

28-
- (instancetype)redraw;
29-
- (instancetype)construct;
30-
- (instancetype)draw;
31-
- (instancetype)reset;
28+
- (void)draw;
29+
//- (void)construct;
30+
//- (instancetype)draw;
31+
- (void)reset;
3232

3333
@end
3434

Source/BarGraph/GKBarGraph.m

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,28 @@ - (void)setBarColor:(UIColor *)color {
6565
}];
6666
}
6767

68-
- (instancetype)redraw {
69-
return [[self construct] draw];
68+
- (void)draw {
69+
[self construct];
70+
[self _drawBars];
7071
}
7172

72-
- (instancetype)construct {
73+
- (void)construct {
7374
NSAssert(self.dataSource, @"GKBarGraph : No data source is assgined.");
7475

75-
[self _construct];
76-
[self _positionBars];
77-
[self _positionLabels];
78-
79-
return self;
80-
}
81-
82-
- (void)_construct {
8376
if ([self _hasBars]) [self _removeBars];
8477
if ([self _hasLabels]) [self _removeLabels];
8578

8679
[self _constructBars];
8780
[self _constructLabels];
81+
82+
[self _positionBars];
83+
[self _positionLabels];
8884
}
8985

86+
//- (void)_construct {
87+
//
88+
//}
89+
9090
- (BOOL)_hasBars {
9191
return ![self.bars mk_isEmpty];
9292
}
@@ -186,7 +186,7 @@ - (void)_positionLabels {
186186
}];
187187
}
188188

189-
- (instancetype)draw {
189+
- (void)_drawBars {
190190
__block NSInteger idx = 0;
191191
id source = self.dataSource;
192192
[self.bars mk_each:^(GKBar *item) {
@@ -202,14 +202,12 @@ - (instancetype)draw {
202202
item.percentage = [[source valueForBarAtIndex:idx] doubleValue];
203203
idx++;
204204
}];
205-
return self;
206205
}
207206

208-
- (instancetype)reset {
207+
- (void)reset {
209208
[self.bars mk_each:^(GKBar *item) {
210209
[item reset];
211210
}];
212-
return self;
213211
}
214212

215213
@end

0 commit comments

Comments
 (0)