| | |
| | | |
| | | self.view.backgroundColor = kUIColorFromRGB(0x0b2f76); |
| | | |
| | | UIImageView * viewBackground = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-AdaptedWidth(355))/2, NavBar_Height+AdaptedHeight(26), AdaptedWidth(355), AdaptedHeight(354+26+20+13+5+10+5))]; |
| | | UIImageView * viewBackground = [[UIImageView alloc] initWithFrame:CGRectMake(AdaptedWidth(5), NavBar_Height+AdaptedHeight(26), SCREEN_WIDTH-AdaptedWidth(10), AdaptedHeight(354+26+30+13+5+10+5))]; |
| | | viewBackground.image = [UIImage imageNamed:@"dynamic_back"]; |
| | | [self.view addSubview:viewBackground]; |
| | | |
| | | // 2, 自动计算高度的 |
| | | CGSize aSize = CGSizeMake(kScreenWidth - 20, INFINITY); |
| | | |
| | | NSMutableAttributedString *attStrM0 = [[NSMutableAttributedString alloc] initWithString:@"PM2.5动态走势图" attributes:@{NSFontAttributeName : AdaptedFontSize(14), NSForegroundColorAttributeName : [UIColor whiteColor]}]; |
| | | |
| | | NSMutableAttributedString *attStrM0 = [[NSMutableAttributedString alloc] initWithString: [NSString stringWithFormat:@"%@动态走势图",self.detailModel.name] attributes:@{NSFontAttributeName : AdaptedFontSize(14), NSForegroundColorAttributeName : [UIColor whiteColor]}]; |
| | | attStrM0.yy_lineSpacing = 10; |
| | | YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:aSize text:attStrM0]; |
| | | |
| | |
| | | titelLabel.textLayout = layout; |
| | | [self.view addSubview:titelLabel]; |
| | | |
| | | UIImageView * icon_circle = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-layout.textBoundingSize.width)/2-10-10, NavBar_Height+AdaptedHeight(26+13+5), AdaptedWidth(10), AdaptedHeight(10))]; |
| | | UIImageView * icon_circle = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-layout.textBoundingSize.width)/2-10-10, NavBar_Height+AdaptedHeight(26+13+3), AdaptedWidth(10), AdaptedHeight(10))]; |
| | | icon_circle.image = [UIImage imageNamed:@"icon_circle"]; |
| | | [self.view addSubview:icon_circle]; |
| | | |
| | | UIImageView * icon_arrow = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-layout.textBoundingSize.width)/2+layout.textBoundingSize.width+10, NavBar_Height+AdaptedHeight(26+13+5), AdaptedWidth(10), AdaptedHeight(10))]; |
| | | UIImageView * icon_arrow = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-layout.textBoundingSize.width)/2+layout.textBoundingSize.width+10, NavBar_Height+AdaptedHeight(26+13+3), AdaptedWidth(10), AdaptedHeight(10))]; |
| | | icon_arrow.image = [UIImage imageNamed:@"icon_arrow"]; |
| | | [self.view addSubview:icon_arrow]; |
| | | |
| | |
| | | -(void)drawHistoryRecordLine |
| | | { |
| | | /* Create object */ |
| | | _historyRecordLineChart = [[JHLineChart alloc] initWithFrame:CGRectMake(AdaptedWidth(10), NavBar_Height+AdaptedHeight(39+50), SCREEN_WIDTH-AdaptedWidth(20), AdaptedHeight(354)) andLineChartType:JHChartLineEveryValueForEveryX]; |
| | | _historyRecordLineChart = [[JHLineChart alloc] initWithFrame:CGRectMake(AdaptedWidth(15), NavBar_Height+AdaptedHeight(39+50), SCREEN_WIDTH-AdaptedWidth(20), AdaptedHeight(354)) andLineChartType:JHChartLineEveryValueForEveryX]; |
| | | |
| | | /* The scale value of the X axis can be passed into the NSString or NSNumber type and the data structure changes with the change of the line chart type. The details look at the document or other quadrant X axis data source sample.*/ |
| | | |
| | |
| | | |
| | | _historyRecordLineChart.lineChartQuadrantType = JHLineChartQuadrantTypeFirstQuardrant; |
| | | |
| | | _historyRecordLineChart.lineWidth = 3.0; |
| | | _historyRecordLineChart.lineWidth = 2.0; |
| | | _historyRecordLineChart.valueArr = [NSMutableArray array]; |
| | | NSMutableArray * valueTeampArr = [[NSMutableArray alloc] init]; |
| | | for (int i = 0; i < self.dynamicService.dynamicViewModels.count; i++) |
| | |
| | | _historyRecordLineChart.showValueLeadingLine = NO; |
| | | //_historyRecordLineChart.showYLine = NO; |
| | | |
| | | if( [StringUtil isPureInt:self.detailModel.upper] || [StringUtil isPureFloat:self.detailModel.upper]) |
| | | if( [StringUtil isPureInt:self.detailModel.upper] || [StringUtil isPureFloat:self.detailModel.upper]) |
| | | { |
| | | _historyRecordLineChart.yLineDataArr = [NSMutableArray array]; |
| | | float fMaxValue = [self.detailModel.upper floatValue]; |
| | | float fMinValue = 0;//[self.detailModel.lower floatValue]; |
| | | float fOffSetValue = fMaxValue - fMinValue; |
| | | float fAvgValue = fOffSetValue / 9; |
| | | int fCurrentValue = fAvgValue; |
| | | for (int index = 0; index < 10; index++) |
| | | if([self.detailModel.upper intValue] <= 1) |
| | | { |
| | | if (index == 0) |
| | | { |
| | | fCurrentValue = fAvgValue; |
| | | } |
| | | else if(index == 9) |
| | | { |
| | | fCurrentValue = fMaxValue; |
| | | } |
| | | else |
| | | { |
| | | fCurrentValue = fCurrentValue+fAvgValue; |
| | | } |
| | | |
| | | NSString * currentStr = @""; |
| | | if(fCurrentValue < 0) |
| | | { |
| | | currentStr = [NSString stringWithFormat:@"-%d",fCurrentValue]; |
| | | } |
| | | else |
| | | { |
| | | currentStr = [NSString stringWithFormat:@"%d",fCurrentValue]; |
| | | } |
| | | |
| | | [_historyRecordLineChart.yLineDataArr addObject:currentStr]; |
| | | _historyRecordLineChart.yLineDataArr = @[@"0.1",@"0.2",@"0.3",@"0.4",@"0.5",@"0.6",@"0.7",@"0.8",@"0.9",@"1"]; |
| | | } |
| | | |
| | | else |
| | | { |
| | | _historyRecordLineChart.yLineDataArr = [NSMutableArray array]; |
| | | float fMaxValue = [self.detailModel.upper floatValue]; |
| | | if( fMaxValue < [self.detailModel.value floatValue]) |
| | | { |
| | | fMaxValue = [self.detailModel.value floatValue]; |
| | | } |
| | | |
| | | float fMinValue = 0;//[self.detailModel.lower floatValue]; |
| | | float fOffSetValue = fMaxValue - fMinValue; |
| | | float fAvgValue = fOffSetValue / 9; |
| | | int fCurrentValue = fAvgValue; |
| | | for (int index = 0; index < 10; index++) |
| | | { |
| | | if (index == 0) |
| | | { |
| | | fCurrentValue = fAvgValue; |
| | | } |
| | | else if(index == 9) |
| | | { |
| | | fCurrentValue = fMaxValue; |
| | | } |
| | | else |
| | | { |
| | | fCurrentValue = fCurrentValue+fAvgValue; |
| | | } |
| | | |
| | | NSString * currentStr = @""; |
| | | if(fCurrentValue < 0) |
| | | { |
| | | currentStr = [NSString stringWithFormat:@"-%d",fCurrentValue]; |
| | | } |
| | | else |
| | | { |
| | | currentStr = [NSString stringWithFormat:@"%d",fCurrentValue]; |
| | | } |
| | | |
| | | [_historyRecordLineChart.yLineDataArr addObject:currentStr]; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | // 二氧化碳 |
| | | /* Line Chart colors 曲线颜色 */ |
| | | _historyRecordLineChart.valueLineColorArr =@[RgbColor(143, 246, 218)]; |
| | | _historyRecordLineChart.valueLineColorArr =@[RgbColor(255, 255, 255)]; |
| | | /* Colors for every line chart 坐标点的颜色*/ |
| | | _historyRecordLineChart.pointColorArr = @[RgbColor(36, 209, 215)]; |
| | | |
| | | |
| | | _historyRecordLineChart.xyFontSize = AdaptedWidth(7); |
| | | _historyRecordLineChart.numberFontSize = AdaptedWidth(10); |
| | | /* color for XY axis XY轴线条的颜色*/ |
| | | _historyRecordLineChart.xAndYLineColor = kUIColorFromRGB(0x00fcff); |
| | | /* XY axis scale color XY轴显示数值的颜色*/ |
| | |
| | | /* Dotted line color of the coordinate point */ |
| | | _historyRecordLineChart.positionLineColorArr = @[RgbColor(255, 255, 255)]; |
| | | /* 坐标点数值的颜色*/ |
| | | _historyRecordLineChart.pointNumberColorArr = @[[UIColor orangeColor]]; |
| | | _historyRecordLineChart.pointNumberColorArr = @[RgbColor(255, 255, 255)]; |
| | | /* Set whether to fill the content, the default is False 是否填充曲线内部区域 */ |
| | | _historyRecordLineChart.contentFill = NO; |
| | | /* Set whether the curve path */ |
| | |
| | | |
| | | -(void)updateDynamicData |
| | | { |
| | | [self GetDynamicDataList:1]; |
| | | //[self GetDynamicDataList:1]; |
| | | } |
| | | |
| | | -(void)GetDynamicDataList:(int)pageSize |
| | |
| | | { |
| | | if( pageSize > 1) |
| | | { |
| | | [self drawHistoryRecordLine]; |
| | | [weakself drawHistoryRecordLine]; |
| | | } |
| | | else if(pageSize == 1) |
| | | { |
| | | NSMutableArray * historyRecordArr = [weakself.historyRecordLineChart.valueArr objectAtIndex:0]; |
| | | for (NSInteger i = 0; i < self.dynamicService.dynamicViewModels.count-1; i++) |
| | | NSMutableArray * valueTeampArr = [[NSMutableArray alloc] init]; |
| | | for (int i = 0; i < self.dynamicService.dynamicViewModels.count; i++) |
| | | { |
| | | [historyRecordArr replaceObjectAtIndex:i withObject:[historyRecordArr objectAtIndex:(i+1)]]; |
| | | } |
| | | DynamicModel * model = [self.dynamicService.dynamicViewModels objectAtIndex:i]; |
| | | |
| | | [valueTeampArr addObject:model.value]; |
| | | } |
| | | |
| | | [historyRecordArr replaceObjectAtIndex:self.dynamicService.dynamicViewModels.count-1 withObject: self.dynamicService.dynamicViewModel.value]; |
| | | |
| | | [weakself.historyRecordLineChart.valueArr removeAllObjects]; |
| | | [weakself.historyRecordLineChart.valueArr addObject:valueTeampArr]; |
| | | [weakself.historyRecordLineChart clearLine]; |
| | | |
| | | // [weakself.historyRecordLineChart.xLineDataArr removeAllObjects]; |
| | | // [weakself.historyRecordLineChart.xLineDataArr addObjectsFromArray:self.dynamicService.dynamicViewModels]; |
| | | // [weakself.historyRecordLineChart clearLine]; |
| | | } |
| | | } |
| | | else |