From 93f3595a13dd36008b46e507e7d60246d3bb705a Mon Sep 17 00:00:00 2001 From: Khanak Date: Sat, 13 Jul 2024 01:41:27 +0530 Subject: [PATCH 1/4] Add corner radius in Barchart --- Source/Charts/Charts/BarChartView.swift | 7 +++++-- Source/Charts/Renderers/BarChartRenderer.swift | 10 ++++++++-- .../Charts/Renderers/HorizontalBarChartRenderer.swift | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/Charts/Charts/BarChartView.swift b/Source/Charts/Charts/BarChartView.swift index 92332774d7..416f4117a3 100644 --- a/Source/Charts/Charts/BarChartView.swift +++ b/Source/Charts/Charts/BarChartView.swift @@ -20,12 +20,15 @@ open class BarChartView: BarLineChartViewBase, BarChartDataProvider /// if set to true, a grey area is drawn behind each bar that indicates the maximum value private var _drawBarShadowEnabled = false + public var barChartCornerRedius : Int = 0 internal override func initialize() { super.initialize() - - renderer = BarChartRenderer(dataProvider: self, animator: chartAnimator, viewPortHandler: viewPortHandler) + } + + public func initializeChart() { + renderer = BarChartRenderer(dataProvider: self, animator: chartAnimator, viewPortHandler: viewPortHandler,barChartCornerRedius: self.barChartCornerRedius) self.highlighter = BarHighlighter(chart: self) diff --git a/Source/Charts/Renderers/BarChartRenderer.swift b/Source/Charts/Renderers/BarChartRenderer.swift index 2aa69a828f..743b38302f 100644 --- a/Source/Charts/Renderers/BarChartRenderer.swift +++ b/Source/Charts/Renderers/BarChartRenderer.swift @@ -42,13 +42,16 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer private typealias Buffer = [CGRect] + public var barChartCornerRedius : Int = 0 + @objc open weak var dataProvider: BarChartDataProvider? - @objc public init(dataProvider: BarChartDataProvider, animator: Animator, viewPortHandler: ViewPortHandler) + @objc public init(dataProvider: BarChartDataProvider, animator: Animator, viewPortHandler: ViewPortHandler, barChartCornerRedius : Int = 0) { super.init(animator: animator, viewPortHandler: viewPortHandler) self.dataProvider = dataProvider + self.barChartCornerRedius = barChartCornerRedius } // [CGRect] per dataset @@ -379,7 +382,10 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer context.setFillColor(dataSet.color(atIndex: j).cgColor) } - context.fill(barRect) + let rectCorners: UIRectCorner = [.topLeft, .topRight] + let bezierPath = UIBezierPath(roundedRect: barRect, byRoundingCorners: rectCorners, cornerRadii: CGSize(width: self.barChartCornerRedius, height: self.barChartCornerRedius)) //(roundedRect: barRect, byRoundingCorners: rectCorners, cornerRadi: 5) + context.addPath(bezierPath.cgPath) + context.drawPath(using: .fill) if drawBorder { diff --git a/Source/Charts/Renderers/HorizontalBarChartRenderer.swift b/Source/Charts/Renderers/HorizontalBarChartRenderer.swift index d2fed814f3..78a24b86f0 100644 --- a/Source/Charts/Renderers/HorizontalBarChartRenderer.swift +++ b/Source/Charts/Renderers/HorizontalBarChartRenderer.swift @@ -24,7 +24,7 @@ open class HorizontalBarChartRenderer: BarChartRenderer var rects = [CGRect]() } - public override init(dataProvider: BarChartDataProvider, animator: Animator, viewPortHandler: ViewPortHandler) + public override init(dataProvider: BarChartDataProvider, animator: Animator, viewPortHandler: ViewPortHandler, barChartCornerRedius : Int = 0) { super.init(dataProvider: dataProvider, animator: animator, viewPortHandler: viewPortHandler) } From 597a2be169a039fc16e39f9c2483e3d4043aeca0 Mon Sep 17 00:00:00 2001 From: Khanak Date: Sat, 13 Jul 2024 02:11:54 +0530 Subject: [PATCH 2/4] change the version --- DGCharts.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DGCharts.podspec b/DGCharts.podspec index 7ba0dea717..5d93e81b87 100644 --- a/DGCharts.podspec +++ b/DGCharts.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "DGCharts" - s.version = "5.1.0" + s.version = "5.1.1" s.summary = "DGCharts is a powerful & easy to use chart library for iOS, tvOS and OSX (and Android)" s.homepage = "https://github.com/danielgindi/Charts" s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" } From 5ae46f0701bcfc87bd96e53cca1330416f9e49a9 Mon Sep 17 00:00:00 2001 From: Khanak Date: Sat, 13 Jul 2024 02:51:15 +0530 Subject: [PATCH 3/4] reverse the version --- DGCharts.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DGCharts.podspec b/DGCharts.podspec index 5d93e81b87..7ba0dea717 100644 --- a/DGCharts.podspec +++ b/DGCharts.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "DGCharts" - s.version = "5.1.1" + s.version = "5.1.0" s.summary = "DGCharts is a powerful & easy to use chart library for iOS, tvOS and OSX (and Android)" s.homepage = "https://github.com/danielgindi/Charts" s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" } From a558f17c63baf8c5cc7dad15deeee24b4215d8ad Mon Sep 17 00:00:00 2001 From: Khanak Date: Sat, 13 Jul 2024 03:07:56 +0530 Subject: [PATCH 4/4] change in pod spec --- DGCharts.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DGCharts.podspec b/DGCharts.podspec index 7ba0dea717..a54271ce34 100644 --- a/DGCharts.podspec +++ b/DGCharts.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = "12.0" s.tvos.deployment_target = "12.0" s.osx.deployment_target = "10.13" - s.source = { :git => "https://github.com/danielgindi/Charts.git", :tag => "#{s.version}" } + s.source = { :git => "https://github.com/Khanak1521/Charts.git", :tag => "#{s.version}" } s.default_subspec = "Core" s.swift_version = '5.7' s.cocoapods_version = '>= 1.5.0'