0
沒有看到折線圖的執行情況顯示
- (void)viewDidLoad
{
[super viewDidLoad];
PCLineChartView *chartLine=[[PCLineChartView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-30)];
[chartLine setAutoresizingMask:UIViewAutoresizingFlexibleWidth| UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin];
chartLine.minValue=0;
chartLine.maxValue=100;
[self.view addSubview:chartLine];
NSError *error;
NSString *strFileContent = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]
pathForResource: @"sample_linechart_data" ofType: @"json"] encoding:NSUTF8StringEncoding error:&error];
NSData *data = [strFileContent dataUsingEncoding:NSUTF8StringEncoding];
NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
//NSLog(@"js:%@",json);
NSMutableArray *secondJson=[json valueForKeyPath:@"data"];
//NSLog(@"sec js:%@",secondJson);
NSMutableArray *components=[NSMutableArray array];
for (NSDictionary *graphInfo in secondJson) {
PCLineChartViewComponent *component=[[PCLineChartViewComponent alloc]init];
[component setTitle:graphInfo[@"title"]];
[component setPoints:graphInfo[@"data"]];
[component setShouldLabelValues:NO];
[component setColour:PCColorBlue];
[components addObject:component];
}
[chartLine setComponents:components];
[chartLine setXLabels:[json valueForKeyPath:@"xLabels"]];
}