Skip to content

Commit aee4f2c

Browse files
.
1 parent e22685a commit aee4f2c

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

GraphKit/Example/ExampleLineGraph.m

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ - (void)viewDidLoad {
2424

2525
self.view.backgroundColor = [UIColor gk_cloudsColor];
2626

27+
[self _setupExampleGraph];
28+
// [self _setupTestingGraph];
29+
}
30+
31+
- (void)_setupExampleGraph {
32+
2733
self.data = @[
2834
@[@20, @40, @20, @60, @40, @140, @80],
2935
@[@40, @20, @60, @100, @60, @20, @60],
@@ -32,18 +38,35 @@ - (void)viewDidLoad {
3238
// @[@620, @650, @580, @620, @540, @400, @0]
3339
];
3440

35-
// self.data = @[
36-
// @[@10, @4, @8, @2, @9, @3, @6],
37-
// @[@1, @2, @3, @4, @5, @6, @10]
38-
// ];
41+
self.labels = @[@"2001", @"2002", @"2003", @"2004", @"2005", @"2006", @"2007"];
42+
43+
self.graph.dataSource = self;
44+
self.graph.lineWidth = 3.0;
45+
46+
self.graph.valueLabelCount = 6;
47+
48+
[self.graph draw];
49+
}
50+
51+
- (void)_setupTestingGraph {
52+
53+
/*
54+
A custom max and min values can be achieved by adding
55+
values for another line and setting its color to clear.
56+
*/
57+
58+
self.data = @[
59+
@[@10, @4, @8, @2, @9, @3, @6],
60+
@[@1, @2, @3, @4, @5, @6, @10]
61+
];
3962

4063
self.labels = @[@"2001", @"2002", @"2003", @"2004", @"2005", @"2006", @"2007"];
4164

4265
self.graph.dataSource = self;
4366
self.graph.lineWidth = 3.0;
4467

4568
// self.graph.startFromZero = YES;
46-
self.graph.valueLabelCount = 6;
69+
self.graph.valueLabelCount = 10;
4770

4871
[self.graph draw];
4972
}
@@ -73,7 +96,6 @@ - (NSInteger)numberOfLines {
7396

7497
- (UIColor *)colorForLineAtIndex:(NSInteger)index {
7598
id colors = @[[UIColor gk_turquoiseColor],
76-
// [UIColor clearColor],
7799
[UIColor gk_peterRiverColor],
78100
[UIColor gk_alizarinColor],
79101
[UIColor gk_sunflowerColor]

Source/LineGraph/GKLineGraph.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ - (CGFloat)_maxValue {
186186
}
187187

188188
- (CGFloat)_minValue {
189-
if (self.startFromZero) return 1;
189+
if (self.startFromZero) return 0;
190190
id values = [self _allValues];
191191
return [[values mk_min] floatValue];
192192
}

0 commit comments

Comments
 (0)