From 4e6b3c240c386f00af293cfd47917c0004a7e6f3 Mon Sep 17 00:00:00 2001 From: Jay Momaya Date: Mon, 21 Aug 2017 12:09:18 +0530 Subject: [PATCH 1/3] added highlighting for bar title changes in bar title opacity --- ARCharts/ARChartHighlighter.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ARCharts/ARChartHighlighter.swift b/ARCharts/ARChartHighlighter.swift index bec5428..d3ae5db 100644 --- a/ARCharts/ARChartHighlighter.swift +++ b/ARCharts/ARChartHighlighter.swift @@ -20,6 +20,8 @@ public struct ARChartHighlighter { public let animationDuration: TimeInterval public var highlightedSeries: Int? public var highlightedIndex: Int? + public var dataSource: ARBarChartDataSource? + public var delegate: ARBarChartDelegate? private let defaultFadedOpacity: Float = 0.15 @@ -41,11 +43,11 @@ public struct ARChartHighlighter { guard highlightedIndex == nil && highlightedSeries == nil else { return } addAnimations(to: barChart, highlightIndex: index, highlightSeries: series, isHighlighting: true) - self.highlightedIndex = index self.highlightedSeries = series } + /** * Reverse highlighting animations on all bars except the one that was highlighted. * - parameter barChart: The `ARBarChart` from which to remove highlighting. @@ -80,7 +82,7 @@ public struct ARChartHighlighter { } } else if let labelNode = node as? ARChartLabel { if (series != nil && labelNode.type == .series && labelNode.id != series!) - || (index != nil && labelNode.type == .index && labelNode.id != index!) { + || (index != nil && labelNode.type == .index && labelNode.id != index!) || (index != nil && series != nil && labelNode.type == .title && labelNode.id != Int("\(series!)\(index!)")) { let startingOpacity: Float = isHighlighting ? 1.0 : defaultFadedOpacity let finalOpacity: Float = isHighlighting ? defaultFadedOpacity : 1.0 let opacityAnimation = CABasicAnimation.animation(forKey: "opacity", from: startingOpacity, to: finalOpacity, duration: animationDuration, delay: nil) From 09b6c8e2f0f9929afa19cbf28030212586650ce5 Mon Sep 17 00:00:00 2001 From: Jay Momaya Date: Mon, 21 Aug 2017 12:12:23 +0530 Subject: [PATCH 2/3] updated previous patch removed unused code --- ARCharts/ARChartHighlighter.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/ARCharts/ARChartHighlighter.swift b/ARCharts/ARChartHighlighter.swift index d3ae5db..c1936a7 100644 --- a/ARCharts/ARChartHighlighter.swift +++ b/ARCharts/ARChartHighlighter.swift @@ -20,8 +20,6 @@ public struct ARChartHighlighter { public let animationDuration: TimeInterval public var highlightedSeries: Int? public var highlightedIndex: Int? - public var dataSource: ARBarChartDataSource? - public var delegate: ARBarChartDelegate? private let defaultFadedOpacity: Float = 0.15 From 07affb4415a3f7bc3258e319f1345d84ba071bc4 Mon Sep 17 00:00:00 2001 From: Jay Momaya Date: Mon, 21 Aug 2017 12:14:48 +0530 Subject: [PATCH 3/3] Added protocols to apply color to title Added protocols to apply color and background color to title --- ARCharts/ARBarChartProtocols.swift | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ARCharts/ARBarChartProtocols.swift b/ARCharts/ARBarChartProtocols.swift index f8d3f41..76b597d 100644 --- a/ARCharts/ARBarChartProtocols.swift +++ b/ARCharts/ARBarChartProtocols.swift @@ -110,6 +110,15 @@ public protocol ARBarChartDelegate: class { func barChart(_ barChart: ARBarChart, colorForLabelForSeries series: Int) -> UIColor + /** + * Asks the delegate to return the color for the text of a label for a specific series (Y axis). + * - parameter barChart: The `ARBarChart` object requesting the color for the text of a series label. + * - parameter series: The series number identifying a series in the bar chart (Y axis). + * - returns: The color to use for the label corresponding to the given series. + */ + func barChart(_ barChart: ARBarChart, + colorForLabelForTitle title: Int) -> UIColor + /** * Asks the delegate to return the color for the text of a label for a specific index (X axis). * - parameter barChart: The `ARBarChart` object requesting the color for the text of a label. @@ -128,6 +137,15 @@ public protocol ARBarChartDelegate: class { func barChart(_ barChart: ARBarChart, backgroundColorForLabelForSeries series: Int) -> UIColor + /** + * Asks the delegate to return the color for the background of a label for a specific series (Z axis). + * - parameter barChart: The `ARBarChart` object requesting the color for the background of a series label. + * - parameter series: The series number identifying a series in the bar chart (Z axis). + * - returns: The color to use for the background of the label corresponding to the given series. + */ + func barChart(_ barChart: ARBarChart, + backgroundColorForLabelForTitle title: Int) -> UIColor + /** * Asks the delegate to return the color for the background of a label for a specific index (X axis). * - parameter barChart: The `ARBarChart` object requesting the color for the background of a label. @@ -147,6 +165,7 @@ public protocol ARBarChartDelegate: class { func barChart(_ barChart: ARBarChart, gapSizeAfterSeries series: Int) -> Float + /** * Asks the delegate to return the size of the gap to display after a specific index. * - parameter barChart: The `ARBarChart` object requesting the gap size. @@ -241,6 +260,11 @@ extension ARBarChartDelegate { return UIColor.white } + public func barChart(_ barChart: ARBarChart, + colorForLabelForTitle title: Int) -> UIColor { + return UIColor.white + } + func barChart(_ barChart: ARBarChart, opacityForBarAtIndex index: Int, forSeries series: Int) -> Float { @@ -259,6 +283,9 @@ extension ARBarChartDelegate { return UIColor.clear } + public func barChart(_ barChart: ARBarChart, backgroundColorForLabelForTitle title: Int) -> UIColor { + return UIColor.black + } }