Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions ARCharts/ARBarChartProtocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -259,6 +283,9 @@ extension ARBarChartDelegate {
return UIColor.clear
}

public func barChart(_ barChart: ARBarChart, backgroundColorForLabelForTitle title: Int) -> UIColor {
return UIColor.black
}


}
4 changes: 2 additions & 2 deletions ARCharts/ARChartHighlighter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,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.
Expand Down Expand Up @@ -80,7 +80,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)
Expand Down