| | |
| | | _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]; |
| | |
| | | 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]; |
| | | } |
| | | |
| | |
| | | { |
| | | CGPoint p = P_M(i*xPace+self.chartOrigin.x, self.chartOrigin.y); |
| | | CGFloat len = [self getTextWithWhenDrawWithText:_xLineDataArr[i]]; |
| | | 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]; |
| | |
| | | |
| | | } |
| | | |
| | | // 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:{ |