kevin

Fix #8 #5 and #6

@@ -28,8 +28,8 @@ @@ -28,8 +28,8 @@
28 28
29 PNChart * lineChart = [[PNChart alloc] initWithFrame:CGRectMake(0, 75.0, SCREEN_WIDTH, 200.0)]; 29 PNChart * lineChart = [[PNChart alloc] initWithFrame:CGRectMake(0, 75.0, SCREEN_WIDTH, 200.0)];
30 lineChart.backgroundColor = [UIColor clearColor]; 30 lineChart.backgroundColor = [UIColor clearColor];
31 - [lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]]; 31 + [lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5",@"SEP 6",@"SEP 7"]];
32 - [lineChart setYValues:@[@"1",@"240",@"122",@"186",@"300"]]; 32 + [lineChart setYValues:@[@1,@24,@12,@18,@30,@10,@21]];
33 [lineChart strokeChart]; 33 [lineChart strokeChart];
34 [self.chartScrollView addSubview:lineChartLabel]; 34 [self.chartScrollView addSubview:lineChartLabel];
35 [self.chartScrollView addSubview:lineChart]; 35 [self.chartScrollView addSubview:lineChart];
@@ -45,8 +45,8 @@ @@ -45,8 +45,8 @@
45 PNChart * barChart = [[PNChart alloc] initWithFrame:CGRectMake(0, 335.0, SCREEN_WIDTH, 200.0)]; 45 PNChart * barChart = [[PNChart alloc] initWithFrame:CGRectMake(0, 335.0, SCREEN_WIDTH, 200.0)];
46 barChart.backgroundColor = [UIColor clearColor]; 46 barChart.backgroundColor = [UIColor clearColor];
47 barChart.type = PNBarType; 47 barChart.type = PNBarType;
48 - [barChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]]; 48 + [barChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5",@"SEP 6",@"SEP 7"]];
49 - [barChart setYValues:@[@"1",@"240",@"122",@"186",@"300"]]; 49 + [barChart setYValues:@[@1,@24,@12,@18,@30,@10,@21]];
50 [barChart strokeChart]; 50 [barChart strokeChart];
51 [self.chartScrollView addSubview:barChartLabel]; 51 [self.chartScrollView addSubview:barChartLabel];
52 [self.chartScrollView addSubview:barChart]; 52 [self.chartScrollView addSubview:barChart];
@@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@
58 -(void)setXLabels:(NSArray *)xLabels 58 -(void)setXLabels:(NSArray *)xLabels
59 { 59 {
60 _xLabels = xLabels; 60 _xLabels = xLabels;
61 - _xLabelWidth = (self.frame.size.width - chartMargin*2)/5.0; 61 + _xLabelWidth = (self.frame.size.width - chartMargin*2)/[xLabels count];
62 62
63 for (NSString * labelText in xLabels) { 63 for (NSString * labelText in xLabels) {
64 NSInteger index = [xLabels indexOfObject:labelText]; 64 NSInteger index = [xLabels indexOfObject:labelText];
@@ -55,7 +55,7 @@ @@ -55,7 +55,7 @@
55 55
56 _yValueMax = (int)max; 56 _yValueMax = (int)max;
57 57
58 - float level = max /5.0; 58 + float level = max /[yLabels count];
59 59
60 NSInteger index = 0; 60 NSInteger index = 0;
61 NSInteger num = [yLabels count] + 1; 61 NSInteger num = [yLabels count] + 1;
@@ -75,7 +75,7 @@ @@ -75,7 +75,7 @@
75 -(void)setXLabels:(NSArray *)xLabels 75 -(void)setXLabels:(NSArray *)xLabels
76 { 76 {
77 _xLabels = xLabels; 77 _xLabels = xLabels;
78 - _xLabelWidth = (self.frame.size.width - chartMargin - 30.0 - ([xLabels count] -1) * xLabelMargin)/5.0; 78 + _xLabelWidth = (self.frame.size.width - chartMargin - 30.0 - ([xLabels count] -1) * xLabelMargin)/[xLabels count];
79 79
80 for (NSString * labelText in xLabels) { 80 for (NSString * labelText in xLabels) {
81 NSInteger index = [xLabels indexOfObject:labelText]; 81 NSInteger index = [xLabels indexOfObject:labelText];