diff --git a/ZFChartView/.DS_Store b/ZFChartView/.DS_Store index d777541..d04ec8d 100644 Binary files a/ZFChartView/.DS_Store and b/ZFChartView/.DS_Store differ diff --git a/ZFChartView/ZFChartView/ViewController/WaveChartViewController.m b/ZFChartView/ZFChartView/ViewController/WaveChartViewController.m index 25f895f..66cfc13 100644 --- a/ZFChartView/ZFChartView/ViewController/WaveChartViewController.m +++ b/ZFChartView/ZFChartView/ViewController/WaveChartViewController.m @@ -38,6 +38,8 @@ - (void)viewDidLoad{ self.waveChart.dataSource = self; self.waveChart.delegate = self; self.waveChart.topicLabel.text = @"xx小学各年级人数"; + self.waveChart.wavePatternType = kWavePatternTypeSharp; + self.waveChart.isVerticalClose = YES; self.waveChart.unit = @"人"; // self.waveChart.isShowYLineSeparate = YES; // self.waveChart.pathColor = ZFGrassGreen; diff --git a/ZFChartView/ZFChartView/ZFChart/ZFGenericChart/ZFGenericChart.h b/ZFChartView/ZFChartView/ZFChart/ZFGenericChart/ZFGenericChart.h old mode 100644 new mode 100755 index e7ed218..f45dcfa --- a/ZFChartView/ZFChartView/ZFChart/ZFGenericChart/ZFGenericChart.h +++ b/ZFChartView/ZFChartView/ZFChart/ZFGenericChart/ZFGenericChart.h @@ -170,6 +170,9 @@ /** 是否显示坐标轴箭头(默认为YES) */ @property (nonatomic, assign) BOOL isShowAxisArrows; +/** 最后一个关闭区域是否垂直关闭 */ +@property (nonatomic, assign) BOOL isVerticalClose; + #pragma mark - 此方法不需理会(Ignore this method) diff --git a/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWave.h b/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWave.h old mode 100644 new mode 100755 index ce801f1..046d0b4 --- a/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWave.h +++ b/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWave.h @@ -36,6 +36,9 @@ typedef enum{ /** 是否带动画显示(默认为YES,带动画) */ @property (nonatomic, assign) BOOL isAnimated; +/** 最后一个关闭区域是否垂直关闭 Riber添加 适用于kWavePatternTypeSharp样式*/ +@property (nonatomic, assign) BOOL isVerticalClose; + #pragma mark - public method /** @@ -43,4 +46,6 @@ typedef enum{ */ - (void)strokePath; + + @end diff --git a/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWave.m b/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWave.m old mode 100644 new mode 100755 index 70ba8d5..89848f9 --- a/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWave.m +++ b/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWave.m @@ -99,12 +99,22 @@ - (UIBezierPath *)fill{ [subBezier addLineToPoint:CGPointMake([currentPoint[ZFWaveChartXPos] floatValue], [currentPoint[ZFWaveChartYPos] floatValue])]; } } + //判断绘画直线还是曲线 subBezier = attribute.isCurve ? [subBezier smoothedPathWithGranularity:_padding] : subBezier; [bezier appendPath:subBezier]; UIBezierPath * closeBezier = [UIBezierPath bezierPath]; - [closeBezier moveToPoint:CGPointMake(self.frame.size.width, self.frame.size.height)]; + + if (_isVerticalClose) { + NSDictionary * lastPoint = [attribute.pointArray lastObject]; + [closeBezier moveToPoint:CGPointMake([lastPoint[ZFWaveChartXPos] floatValue], self.frame.size.height)]; + } + else + { + [closeBezier moveToPoint:CGPointMake(self.frame.size.width, self.frame.size.height)]; + } + [closeBezier addLineToPoint:CGPointMake(0, self.frame.size.height)]; [bezier appendPath:closeBezier]; } @@ -118,8 +128,18 @@ - (UIBezierPath *)fill{ NSDictionary * point = _valuePointArray[i]; [bezier addLineToPoint:CGPointMake([point[ZFWaveChartXPos] floatValue], [point[ZFWaveChartYPos] floatValue])]; } - - [bezier addLineToPoint:CGPointMake(self.frame.size.width, self.frame.size.height)]; + + if (_isVerticalClose) { + NSDictionary * lastPoint = [_valuePointArray lastObject]; + [bezier addLineToPoint:CGPointMake([lastPoint[ZFWaveChartXPos] floatValue], self.frame.size.height)]; + } + else + { + [bezier addLineToPoint:CGPointMake(self.frame.size.width, self.frame.size.height)]; + } + + + [bezier closePath]; return bezier; } diff --git a/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWaveChart.m b/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWaveChart.m old mode 100644 new mode 100755 index 366a7b0..4e39328 --- a/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWaveChart.m +++ b/ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWaveChart.m @@ -69,6 +69,7 @@ - (void)drawWavePath{ self.wave.padding = self.genericAxis.groupPadding; self.wave.wavePatternType = _wavePatternType; self.wave.isAnimated = self.isAnimated; + self.wave.isVerticalClose = self.isVerticalClose; self.wave.opacity = self.opacity; self.wave.gradientAttribute = _gradientAttribute; [self.genericAxis addSubview:self.wave];