From f99cf1d5cc50407394501853be06cb39f38a092c Mon Sep 17 00:00:00 2001 From: 单军华 <WindShan@danjunhuas-MacBook-Pro.local> Date: Wed, 28 Mar 2018 14:09:19 +0800 Subject: [PATCH] 界面更换与适配调整 --- pregnancy_guard/BaseProject/ThirdClass/JHChart/JHLineChart.m | 69 +++++++++++++++++++--------------- 1 files changed, 39 insertions(+), 30 deletions(-) diff --git a/pregnancy_guard/BaseProject/ThirdClass/JHChart/JHLineChart.m b/pregnancy_guard/BaseProject/ThirdClass/JHChart/JHLineChart.m index 7ddfc55..c94310c 100755 --- a/pregnancy_guard/BaseProject/ThirdClass/JHChart/JHLineChart.m +++ b/pregnancy_guard/BaseProject/ThirdClass/JHChart/JHLineChart.m @@ -45,19 +45,19 @@ _lineWidth = 0.5; _xyFontSize = 7.0; self.contentInsets = UIEdgeInsetsMake(10, 20, 10, 10); - _yLineDataArr = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8"];//[NSMutableArray array]; + _yLineDataArr = @[@"100",@"200",@"300",@"400",@"500",@"600",@"700",@"800"];//[NSMutableArray array]; _xLineDataArr = [NSMutableArray array]; -// _xAndYLineColor = [UIColor darkGrayColor]; -// _pointNumberColorArr = @[[UIColor redColor]]; -// _positionLineColorArr = @[[UIColor darkGrayColor]]; -// _pointColorArr = @[[UIColor orangeColor]]; -// _xAndYNumberColor = [UIColor darkGrayColor]; -// _valueLineColorArr = @[[UIColor redColor]]; + _xAndYLineColor = [UIColor darkGrayColor]; + _pointNumberColorArr = @[[UIColor redColor]]; + _positionLineColorArr = @[[UIColor darkGrayColor]]; + _pointColorArr = @[[UIColor orangeColor]]; + _xAndYNumberColor = [UIColor darkGrayColor]; + _valueLineColorArr = @[[UIColor redColor]]; _layerArr = [NSMutableArray array]; _showYLine = YES; _showYLevelLine = NO; _showValueLeadingLine = YES; -// _contentFillColorArr = @[[UIColor lightGrayColor]]; + _contentFillColorArr = @[[UIColor lightGrayColor]]; [self configChartXAndYLength]; [self configChartOrigin]; [self configPerXAndPerY]; @@ -475,7 +475,8 @@ case JHLineChartQuadrantTypeFirstQuardrant:{ [self drawLineWithContext:context andStarPoint:self.chartOrigin andEndPoint:P_M(self.contentInsets.left+_xLength, self.chartOrigin.y) andIsDottedLine:NO andColor:_xAndYLineColor]; - if (_showYLine) { + if (_showYLine) + { [self drawLineWithContext:context andStarPoint:self.chartOrigin andEndPoint:P_M(self.chartOrigin.x,self.chartOrigin.y-_yLength) andIsDottedLine:NO andColor:_xAndYLineColor]; } @@ -487,7 +488,15 @@ { CGPoint p = P_M(i*xPace+self.chartOrigin.x, self.chartOrigin.y); CGFloat len = [self getTextWithWhenDrawWithText:_xLineDataArr[i]]; - [self drawLineWithContext:context andStarPoint:p andEndPoint:P_M(p.x, p.y-3) andIsDottedLine:NO andColor:_xAndYLineColor]; + if (_showYLevelLine) + { + _xLength = CGRectGetWidth(self.frame)-self.contentInsets.left-self.contentInsets.right; + + [self drawLineWithContext:context andStarPoint:p andEndPoint:P_M(self.chartOrigin.x+self.perXLen*i,self.chartOrigin.y-_yLength) andIsDottedLine:NO andColor:_xAndYLineColor]; + + } + else + [self drawLineWithContext:context andStarPoint:p andEndPoint:P_M(p.x, p.y-3) andIsDottedLine:NO andColor:_xAndYLineColor]; [self drawText:[NSString stringWithFormat:@"%@",_xLineDataArr[i]] andContext:context atPoint:P_M(p.x-len/2, p.y+2) WithColor:_xAndYNumberColor andFontSize:_xyFontSize]; } @@ -496,26 +505,26 @@ } -// if (_yLineDataArr.count>0) -// { -// CGFloat yPace = (_yLength - kXandYSpaceForSuperView)/(_yLineDataArr.count); -// for (NSInteger i = 0; i<_yLineDataArr.count; i++) -// { -// CGPoint p = P_M(self.chartOrigin.x, self.chartOrigin.y - (i+1)*yPace); -// CGFloat len = [self getTextWithWhenDrawWithText:_yLineDataArr[i]]; -// if (_showYLevelLine) -// { -// [self drawLineWithContext:context andStarPoint:p andEndPoint:P_M(self.contentInsets.left+_xLength, p.y) andIsDottedLine:NO andColor:_xAndYLineColor]; -// -// } -// else -// { -// [self drawLineWithContext:context andStarPoint:p andEndPoint:P_M(p.x+3, p.y) andIsDottedLine:NO andColor:_xAndYLineColor]; -// } -// -// [self drawText:[NSString stringWithFormat:@"%@",_yLineDataArr[i]] andContext:context atPoint:P_M(p.x-len-3, p.y-3) WithColor:_xAndYNumberColor andFontSize:_xyFontSize]; -// } -// } + if (_yLineDataArr.count>0) + { + CGFloat yPace = (_yLength - kXandYSpaceForSuperView)/(_yLineDataArr.count); + for (NSInteger i = 0; i<_yLineDataArr.count; i++) + { + CGPoint p = P_M(self.chartOrigin.x, self.chartOrigin.y - (i+1)*yPace); + CGFloat len = [self getTextWithWhenDrawWithText:_yLineDataArr[i]]; + if (_showYLevelLine) + { + [self drawLineWithContext:context andStarPoint:p andEndPoint:P_M(self.contentInsets.left+_xLength, p.y) andIsDottedLine:NO andColor:_xAndYLineColor]; + + } + else + { + [self drawLineWithContext:context andStarPoint:p andEndPoint:P_M(p.x+3, p.y) andIsDottedLine:NO andColor:_xAndYLineColor]; + } + + [self drawText:[NSString stringWithFormat:@"%@",_yLineDataArr[i]] andContext:context atPoint:P_M(p.x-len-3, p.y-3) WithColor:_xAndYNumberColor andFontSize:_xyFontSize]; + } + } }break; case JHLineChartQuadrantTypeFirstAndSecondQuardrant:{ -- Gitblit v1.8.0