Skip to content

Commit

Permalink
The highlight breaking changes are a chance to use @objc(name) feature
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Aug 8, 2016
1 parent 9bf669a commit 5e143be
Show file tree
Hide file tree
Showing 37 changed files with 158 additions and 150 deletions.
112 changes: 56 additions & 56 deletions Charts/Charts.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Charts/Classes/Charts/BarChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class BarChartView: BarLineChartViewBase, BarChartDataProvider

renderer = BarChartRenderer(dataProvider: self, animator: _animator, viewPortHandler: _viewPortHandler)

self.highlighter = BarChartHighlighter(chart: self)
self.highlighter = BarHighlighter(chart: self)
}

internal override func calcMinMax()
Expand Down Expand Up @@ -63,7 +63,7 @@ public class BarChartView: BarLineChartViewBase, BarChartDataProvider
}

/// - returns: The Highlight object (contains x-index and DataSet index) of the selected value at the given touch point inside the BarChart.
public override func getHighlightByTouchPoint(pt: CGPoint) -> ChartHighlight?
public override func getHighlightByTouchPoint(pt: CGPoint) -> Highlight?
{
if _data === nil
{
Expand Down Expand Up @@ -125,7 +125,7 @@ public class BarChartView: BarLineChartViewBase, BarChartDataProvider
/// - parameter stackIndex: the index inside the stack - only relevant for stacked entries
public func highlightValue(x x: Double, dataSetIndex: Int, stackIndex: Int)
{
highlightValue(ChartHighlight(x: x, dataSetIndex: dataSetIndex, stackIndex: stackIndex))
highlightValue(Highlight(x: x, dataSetIndex: dataSetIndex, stackIndex: stackIndex))
}

// MARK: Accessors
Expand Down
22 changes: 11 additions & 11 deletions Charts/Classes/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public protocol ChartViewDelegate
/// Called when a value has been selected inside the chart.
/// - parameter entry: The selected Entry.
/// - parameter highlight: The corresponding highlight object that contains information about the highlighted position such as dataSetIndex etc.
optional func chartValueSelected(chartView: ChartViewBase, entry: ChartDataEntry, highlight: ChartHighlight)
optional func chartValueSelected(chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight)

// Called when nothing has been selected or an "un-select" has been made.
optional func chartValueNothingSelected(chartView: ChartViewBase)
Expand Down Expand Up @@ -123,7 +123,7 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate
private var _offsetsCalculated = false

/// array of Highlight objects that reference the highlighted slices in the chart
internal var _indicesToHighlight = [ChartHighlight]()
internal var _indicesToHighlight = [Highlight]()

/// `true` if drawing the marker is enabled when tapping on values
/// (use the `marker` property to specify a marker)
Expand Down Expand Up @@ -401,7 +401,7 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate
// MARK: - Highlighting

/// - returns: The array of currently highlighted values. This might an empty if nothing is highlighted.
public var highlighted: [ChartHighlight]
public var highlighted: [Highlight]
{
return _indicesToHighlight
}
Expand Down Expand Up @@ -432,10 +432,10 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate
/// null or an empty array to undo all highlighting.
/// This should be used to programmatically highlight values.
/// This DOES NOT generate a callback to the delegate.
public func highlightValues(highs: [ChartHighlight]?)
public func highlightValues(highs: [Highlight]?)
{
// set the indices to highlight
_indicesToHighlight = highs ?? [ChartHighlight]()
_indicesToHighlight = highs ?? [Highlight]()

if (_indicesToHighlight.isEmpty)
{
Expand All @@ -454,7 +454,7 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate
/// Highlights the values represented by the provided Highlight object
/// This DOES NOT generate a callback to the delegate.
/// - parameter highlight: contains information about which entry should be highlighted
public func highlightValue(highlight: ChartHighlight?)
public func highlightValue(highlight: Highlight?)
{
highlightValue(highlight: highlight, callDelegate: false)
}
Expand Down Expand Up @@ -482,12 +482,12 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate
}
else
{
highlightValue(highlight: ChartHighlight(x: x, dataSetIndex: dataSetIndex), callDelegate: callDelegate)
highlightValue(highlight: Highlight(x: x, dataSetIndex: dataSetIndex), callDelegate: callDelegate)
}
}

/// Highlights the value selected by touch gesture.
public func highlightValue(highlight highlight: ChartHighlight?, callDelegate: Bool)
public func highlightValue(highlight highlight: Highlight?, callDelegate: Bool)
{
var entry: ChartDataEntry?
var h = highlight
Expand Down Expand Up @@ -531,7 +531,7 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate
/// - returns: The Highlight object (contains x-index and DataSet index) of the
/// selected value at the given touch point inside the Line-, Scatter-, or
/// CandleStick-Chart.
public func getHighlightByTouchPoint(pt: CGPoint) -> ChartHighlight?
public func getHighlightByTouchPoint(pt: CGPoint) -> Highlight?
{
if _data === nil
{
Expand All @@ -543,7 +543,7 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate
}

/// The last value that was highlighted via touch.
public var lastHighlighted: ChartHighlight?
public var lastHighlighted: Highlight?

// MARK: - Markers

Expand Down Expand Up @@ -589,7 +589,7 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate
}

/// - returns: The actual position in pixels of the MarkerView for the given Entry in the given DataSet.
public func getMarkerPosition(highlight highlight: ChartHighlight) -> CGPoint
public func getMarkerPosition(highlight highlight: Highlight) -> CGPoint
{
return CGPoint(x: highlight.drawX, y: highlight.drawY)
}
Expand Down
6 changes: 3 additions & 3 deletions Charts/Classes/Charts/HorizontalBarChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class HorizontalBarChartView: BarChartView
_rightYAxisRenderer = ChartYAxisRendererHorizontalBarChart(viewPortHandler: _viewPortHandler, yAxis: _rightAxis, transformer: _rightAxisTransformer)
_xAxisRenderer = ChartXAxisRendererHorizontalBarChart(viewPortHandler: _viewPortHandler, xAxis: _xAxis, transformer: _leftAxisTransformer, chart: self)

self.highlighter = HorizontalBarChartHighlighter(chart: self)
self.highlighter = HorizontalBarHighlighter(chart: self)
}

internal override func calculateOffsets()
Expand Down Expand Up @@ -100,7 +100,7 @@ public class HorizontalBarChartView: BarChartView
_leftAxisTransformer.prepareMatrixValuePx(chartXMin: _leftAxis._axisMinimum, deltaX: CGFloat(_leftAxis.axisRange), deltaY: CGFloat(_xAxis.axisRange), chartYMin: _xAxis._axisMinimum)
}

public override func getMarkerPosition(highlight highlight: ChartHighlight) -> CGPoint
public override func getMarkerPosition(highlight highlight: Highlight) -> CGPoint
{
return CGPoint(x: highlight.drawY, y: highlight.drawX)
}
Expand Down Expand Up @@ -138,7 +138,7 @@ public class HorizontalBarChartView: BarChartView
return vals
}

public override func getHighlightByTouchPoint(pt: CGPoint) -> ChartHighlight?
public override func getHighlightByTouchPoint(pt: CGPoint) -> Highlight?
{
if _data === nil
{
Expand Down
4 changes: 2 additions & 2 deletions Charts/Classes/Charts/PieChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class PieChartView: PieRadarChartViewBase
renderer = PieChartRenderer(chart: self, animator: _animator, viewPortHandler: _viewPortHandler)
_xAxis = nil

self.highlighter = PieChartHighlighter(chart: self)
self.highlighter = PieHighlighter(chart: self)
}

public override func drawRect(rect: CGRect)
Expand Down Expand Up @@ -152,7 +152,7 @@ public class PieChartView: PieRadarChartViewBase
calcAngles()
}

public override func getMarkerPosition(highlight highlight: ChartHighlight) -> CGPoint
public override func getMarkerPosition(highlight highlight: Highlight) -> CGPoint
{
let center = self.centerCircleBox
var r = self.radius
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Charts/PieRadarChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ public class PieRadarChartViewBase: ChartViewBase
}

/// reference to the last highlighted object
private var _lastHighlight: ChartHighlight!
private var _lastHighlight: Highlight!

@objc private func tapGestureRecognized(recognizer: NSUITapGestureRecognizer)
{
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Charts/RadarChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class RadarChartView: PieRadarChartViewBase
_yAxisRenderer = ChartYAxisRendererRadarChart(viewPortHandler: _viewPortHandler, yAxis: _yAxis, chart: self)
_xAxisRenderer = ChartXAxisRendererRadarChart(viewPortHandler: _viewPortHandler, xAxis: _xAxis, chart: self)

self.highlighter = RadarChartHighlighter(chart: self)
self.highlighter = RadarHighlighter(chart: self)
}

internal override func calcMinMax()
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Components/IMarker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public protocol IMarker: NSObjectProtocol
///
/// - parameter entry: The Entry the IMarker belongs to. This can also be any subclass of Entry, like BarEntry or CandleEntry, simply cast it at runtime.
/// - parameter highlight: The highlight object contains information about the highlighted value such as it's dataset-index, the selected range or stack-index (only stacked bar entries).
func refreshContent(entry entry: ChartDataEntry, highlight: ChartHighlight)
func refreshContent(entry entry: ChartDataEntry, highlight: Highlight)

/// Draws the IMarker on the given position on the given context
func draw(context context: CGContext, point: CGPoint)
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Components/MarkerImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class MarkerImage: NSObject, IMarker
return offset
}

public func refreshContent(entry entry: ChartDataEntry, highlight: ChartHighlight)
public func refreshContent(entry entry: ChartDataEntry, highlight: Highlight)
{
// Do nothing here...
}
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Components/MarkerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class MarkerView: NSUIView, IMarker
return offset
}

public func refreshContent(entry entry: ChartDataEntry, highlight: ChartHighlight)
public func refreshContent(entry entry: ChartDataEntry, highlight: Highlight)
{
// Do nothing here...
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BarChartDataEntry: ChartDataEntry
private var _yVals: [Double]?

/// the ranges for the individual stack values - automatically calculated
private var _ranges: [ChartRange]?
private var _ranges: [Range]?

/// the sum of all negative values this entry (if stacked) contains
private var _negativeSum: Double = 0.0
Expand Down Expand Up @@ -134,7 +134,7 @@ public class BarChartDataEntry: ChartDataEntry

if _ranges == nil
{
_ranges = [ChartRange]()
_ranges = [Range]()
}
else
{
Expand All @@ -152,12 +152,12 @@ public class BarChartDataEntry: ChartDataEntry

if value < 0
{
_ranges?.append(ChartRange(from: negRemain, to: negRemain + abs(value)))
_ranges?.append(Range(from: negRemain, to: negRemain + abs(value)))
negRemain += abs(value)
}
else
{
_ranges?.append(ChartRange(from: posRemain, to: posRemain+value))
_ranges?.append(Range(from: posRemain, to: posRemain+value))
posRemain += value
}
}
Expand All @@ -182,7 +182,7 @@ public class BarChartDataEntry: ChartDataEntry
}

/// - returns: The ranges of the individual stack-entries. Will return null if this entry is not stacked.
public var ranges: [ChartRange]?
public var ranges: [Range]?
{
return _ranges
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public class ChartData: NSObject
///
/// - parameter highlight:
/// - returns: The entry that is highlighted
public func entryForHighlight(highlight: ChartHighlight) -> ChartDataEntry?
public func entryForHighlight(highlight: Highlight) -> ChartDataEntry?
{
if highlight.dataSetIndex >= dataSets.count
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public class CombinedChartData: BarLineScatterCandleBubbleChartData
///
/// - parameter highlight:
/// - returns: The entry that is highlighted
public override func entryForHighlight(highlight: ChartHighlight) -> ChartDataEntry?
public override func entryForHighlight(highlight: Highlight) -> ChartDataEntry?
{
let dataObjects = allData

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class PieChartData: ChartData
return nil
}

public override func entryForHighlight(highlight: ChartHighlight) -> ChartDataEntry?
public override func entryForHighlight(highlight: Highlight) -> ChartDataEntry?
{
return dataSet?.entryForIndex(Int(highlight.x))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class RadarChartData: ChartData
super.init(dataSets: dataSets)
}

public override func entryForHighlight(highlight: ChartHighlight) -> ChartDataEntry?
public override func entryForHighlight(highlight: Highlight) -> ChartDataEntry?
{
return getDataSetByIndex(highlight.dataSetIndex)?.entryForIndex(Int(highlight.x))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
import Foundation
import CoreGraphics

public class BarChartHighlighter: ChartHighlighter
@objc(BarChartHighlighter)
public class BarHighlighter: ChartHighlighter
{
public override func getHighlight(x x: CGFloat, y: CGFloat) -> ChartHighlight?
public override func getHighlight(x x: CGFloat, y: CGFloat) -> Highlight?
{
let high = super.getHighlight(x: x, y: y)

Expand Down Expand Up @@ -55,10 +56,10 @@ public class BarChartHighlighter: ChartHighlighter
/// - parameter xIndex:
/// - parameter yValue:
/// - returns:
public func getStackedHighlight(high high: ChartHighlight,
public func getStackedHighlight(high high: Highlight,
set: IBarChartDataSet,
xValue: Double,
yValue: Double) -> ChartHighlight?
yValue: Double) -> Highlight?
{
guard let
chart = self.chart as? BarLineScatterCandleBubbleChartDataProvider,
Expand All @@ -79,14 +80,14 @@ public class BarChartHighlighter: ChartHighlighter
let pixel = chart
.getTransformer(set.axisDependency)
.pixelForValues(x: high.x, y: ranges[stackIndex].to)

return ChartHighlight(x: entry.x,
y: entry.y,
xPx: pixel.x,
yPx: pixel.y,
dataSetIndex: high.dataSetIndex,
stackIndex: stackIndex,
axis: high.axis)
return Highlight(x: entry.x,
y: entry.y,
xPx: pixel.x,
yPx: pixel.y,
dataSetIndex: high.dataSetIndex,
stackIndex: stackIndex,
axis: high.axis)
}

return nil
Expand All @@ -96,7 +97,7 @@ public class BarChartHighlighter: ChartHighlighter
/// - parameter entry:
/// - parameter value:
/// - returns:
public func getClosestStackIndex(ranges ranges: [ChartRange]?, value: Double) -> Int
public func getClosestStackIndex(ranges ranges: [Range]?, value: Double) -> Int
{
if ranges == nil
{
Expand Down
Loading

0 comments on commit 5e143be

Please sign in to comment.