diff --git a/LifeLog/LifeLog/HistoryViewController.h b/LifeLog/LifeLog/HistoryViewController.h index 67d0d67..d25d815 100644 --- a/LifeLog/LifeLog/HistoryViewController.h +++ b/LifeLog/LifeLog/HistoryViewController.h @@ -7,6 +7,7 @@ // #import +#import #import "CollectionView.h" @@ -17,6 +18,8 @@ @property (weak, nonatomic) IBOutlet CollectionView *viewCollectionType; @property (weak, nonatomic) IBOutlet CollectionView *viewCollectionShare; +@property (weak, nonatomic) IBOutlet BarChartView *viewBarChart; + @property (weak, nonatomic) IBOutlet UITableView *tableListHistory; @property (weak, nonatomic) IBOutlet UIScrollView *scrollView; @end diff --git a/LifeLog/LifeLog/HistoryViewController.m b/LifeLog/LifeLog/HistoryViewController.m index 184d6e8..831d08a 100644 --- a/LifeLog/LifeLog/HistoryViewController.m +++ b/LifeLog/LifeLog/HistoryViewController.m @@ -23,6 +23,27 @@ self.title = NSLocalizedString(@"lifelog.tapbar.history", nil); self.lblHeader.text = NSLocalizedString(@"lifelog.tapbar.history", nil); + [self setupView]; + [self setupChartView]; + //register nib for table view + [self.tableListHistory registerNib:[UINib nibWithNibName:@"HistoryListTableViewCell" bundle:nil] forCellReuseIdentifier:@"HistoryListCell"]; +} + +- (void)viewDidAppear:(BOOL) animated +{ + [super viewDidAppear:animated]; + self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 400); + [self.scrollView setNeedsLayout]; + [self.scrollView setNeedsUpdateConstraints]; + +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)setupView { [self.viewCollectionTime setButtonNumber:5]; [self.viewCollectionTime setSpacing:2]; [self.viewCollectionTime setArrayTitle:[NSArray arrayWithObjects:@"1日", @"1週間", @"1ヶ月", @"3ヶ月", @"6ヶ月", nil]]; @@ -37,22 +58,58 @@ [self.viewCollectionShare setSpacing:3]; [self.viewCollectionShare setSelectedIndex:-1]; [self.viewCollectionShare setArrayTitle:[NSArray arrayWithObjects:@"facebook", @"twitter", @"line", @"メール", @"その他", nil]]; - - [self.tableListHistory registerNib:[UINib nibWithNibName:@"HistoryListTableViewCell" bundle:nil] forCellReuseIdentifier:@"HistoryListCell"]; } -- (void)viewDidAppear:(BOOL) animated -{ - [super viewDidAppear:animated]; - self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 400); - [self.scrollView setNeedsLayout]; - [self.scrollView setNeedsUpdateConstraints]; - -} +- (void)setupChartView { + self.viewBarChart.chartDescription.enabled = NO; + self.viewBarChart.leftAxis.drawGridLinesEnabled = NO; + self.viewBarChart.rightAxis.drawGridLinesEnabled = NO; + self.viewBarChart.legend.enabled = NO; -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. + ChartXAxis *xAxis = self.viewBarChart.xAxis; + xAxis.labelPosition = XAxisLabelPositionBottom; + xAxis.drawGridLinesEnabled = NO; + xAxis.drawAxisLineEnabled = NO; + xAxis.drawLabelsEnabled = YES; + xAxis.labelPosition = XAxisLabelPositionBottom; + xAxis.labelFont = [UIFont systemFontOfSize:10.f]; + xAxis.labelTextColor = [UIColor whiteColor]; + xAxis.granularity = 1.0; // only intervals of 1 day + xAxis.labelCount = 8; + + self.viewBarChart.leftAxis.drawAxisLineEnabled = NO; + self.viewBarChart.rightAxis.drawAxisLineEnabled = NO; + + /*fake data for test*/ + NSMutableArray *yVals = [[NSMutableArray alloc] init]; + + for (int i = 0; i < 24; i++) + { + double val = (double) (arc4random_uniform(100)); + [yVals addObject:[[BarChartDataEntry alloc] initWithX:i y:val]]; + } + + BarChartDataSet *set1 = nil; + if (self.viewBarChart.data.dataSetCount > 0) + { + set1 = (BarChartDataSet *)self.viewBarChart.data.dataSets[0]; + set1.values = yVals; + [self.viewBarChart.data notifyDataChanged]; + [self.viewBarChart notifyDataSetChanged]; + } + else + { + set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@""]; + [set1 setColor:[UIColor whiteColor]]; + + NSMutableArray *dataSets = [[NSMutableArray alloc] init]; + [dataSets addObject:set1]; + + BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets]; + data.barWidth = 0.5f; + + self.viewBarChart.data = data; + } } #pragma mark UITableView Delegate diff --git a/LifeLog/LifeLog/HistoryViewController.xib b/LifeLog/LifeLog/HistoryViewController.xib index e7dffaf..51a9f72 100644 --- a/LifeLog/LifeLog/HistoryViewController.xib +++ b/LifeLog/LifeLog/HistoryViewController.xib @@ -1,5 +1,5 @@ - + @@ -15,6 +15,7 @@ + @@ -362,9 +363,9 @@ - - - + + + @@ -382,7 +383,7 @@ - + @@ -392,7 +393,7 @@ - + diff --git a/LifeLog/Podfile b/LifeLog/Podfile index 8487187..5155032 100644 --- a/LifeLog/Podfile +++ b/LifeLog/Podfile @@ -4,4 +4,5 @@ use_frameworks! target 'LifeLog' do pod 'CircleProgressBar' pod 'MBProgressHUD', '~> 1.0.0' + pod 'Charts' end