From ba2fa8039ab6c9719a08060bec154ec6e484c94b Mon Sep 17 00:00:00 2001 From: Riber <314420972@qq.com> Date: Wed, 6 Sep 2017 14:04:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由于项目需求 在直线样式的波浪图下 新增一个属性控制是否垂直关闭折线图 --- .../ZFChart/ZFGenericChart/ZFGenericChart.h | 3 +++ .../ZFChartView/ZFChart/ZFWaveChart/ZFWave.h | 5 ++++ .../ZFChartView/ZFChart/ZFWaveChart/ZFWave.m | 26 ++++++++++++++++--- .../ZFChart/ZFWaveChart/ZFWaveChart.m | 1 + 4 files changed, 32 insertions(+), 3 deletions(-) mode change 100644 => 100755 ZFChartView/ZFChartView/ZFChart/ZFGenericChart/ZFGenericChart.h mode change 100644 => 100755 ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWave.h mode change 100644 => 100755 ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWave.m mode change 100644 => 100755 ZFChartView/ZFChartView/ZFChart/ZFWaveChart/ZFWaveChart.m 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]; From 0a35abd9c82d08e0dc85e155f3a9cb0204a6f2b9 Mon Sep 17 00:00:00 2001 From: Riber <314420972@qq.com> Date: Thu, 7 Sep 2017 16:07:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9B=B4=E7=BA=BF?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=20=E5=9E=82=E7=9B=B4=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=8A=98=E7=BA=BF=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 设置直线样式 垂直关闭折线图 --- ZFChartView/.DS_Store | Bin 8196 -> 8196 bytes .../ViewController/WaveChartViewController.m | 2 ++ 2 files changed, 2 insertions(+) diff --git a/ZFChartView/.DS_Store b/ZFChartView/.DS_Store index d777541b7786e01b3ef3cc6bf0934fd1434e0b23..d04ec8d2e364887df1ec55bd05404b118052791a 100644 GIT binary patch delta 73 zcmZp1XmQxUDZBMC8e|^nSlW&Bv6oH7@VA+ VTfhJUj0Fsn^~F>+zY>w+1^}zi7uf&+ delta 73 zcmZp1XmQxUDZjj3%`eG`ZUx`R@0|2$;7-|3j 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;