|
|
@@ -9,15 +9,13 @@
|
|
|
// https://github.com/danielgindi/Charts
|
|
|
//
|
|
|
|
|
|
-import Foundation
|
|
|
import CoreGraphics
|
|
|
+import Foundation
|
|
|
|
|
|
#if canImport(UIKit)
|
|
|
- import UIKit
|
|
|
-#endif
|
|
|
-
|
|
|
-#if canImport(Cocoa)
|
|
|
-import Cocoa
|
|
|
+import UIKit
|
|
|
+#elseif canImport(AppKit)
|
|
|
+import AppKit
|
|
|
#endif
|
|
|
|
|
|
/// Base-class of LineChart, BarChart, ScatterChart and CandleStickChart.
|
|
|
@@ -76,19 +74,19 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
|
|
|
/// The left Y axis renderer. This is a read-write property so you can set your own custom renderer here.
|
|
|
/// **default**: An instance of YAxisRenderer
|
|
|
- @objc open lazy var leftYAxisRenderer = YAxisRenderer(viewPortHandler: _viewPortHandler, yAxis: leftAxis, transformer: _leftAxisTransformer)
|
|
|
+ @objc open lazy var leftYAxisRenderer = YAxisRenderer(viewPortHandler: viewPortHandler, axis: leftAxis, transformer: _leftAxisTransformer)
|
|
|
|
|
|
/// The right Y axis renderer. This is a read-write property so you can set your own custom renderer here.
|
|
|
/// **default**: An instance of YAxisRenderer
|
|
|
- @objc open lazy var rightYAxisRenderer = YAxisRenderer(viewPortHandler: _viewPortHandler, yAxis: rightAxis, transformer: _rightAxisTransformer)
|
|
|
-
|
|
|
+ @objc open lazy var rightYAxisRenderer = YAxisRenderer(viewPortHandler: viewPortHandler, axis: rightAxis, transformer: _rightAxisTransformer)
|
|
|
+
|
|
|
internal var _leftAxisTransformer: Transformer!
|
|
|
internal var _rightAxisTransformer: Transformer!
|
|
|
|
|
|
/// The X axis renderer. This is a read-write property so you can set your own custom renderer here.
|
|
|
/// **default**: An instance of XAxisRenderer
|
|
|
- @objc open lazy var xAxisRenderer = XAxisRenderer(viewPortHandler: _viewPortHandler, xAxis: _xAxis, transformer: _leftAxisTransformer)
|
|
|
-
|
|
|
+ @objc open lazy var xAxisRenderer = XAxisRenderer(viewPortHandler: viewPortHandler, axis: xAxis, transformer: _leftAxisTransformer)
|
|
|
+
|
|
|
internal var _tapGestureRecognizer: NSUITapGestureRecognizer!
|
|
|
internal var _doubleTapGestureRecognizer: NSUITapGestureRecognizer!
|
|
|
#if !os(tvOS)
|
|
|
@@ -118,9 +116,9 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
{
|
|
|
super.initialize()
|
|
|
|
|
|
- _leftAxisTransformer = Transformer(viewPortHandler: _viewPortHandler)
|
|
|
- _rightAxisTransformer = Transformer(viewPortHandler: _viewPortHandler)
|
|
|
-
|
|
|
+ _leftAxisTransformer = Transformer(viewPortHandler: viewPortHandler)
|
|
|
+ _rightAxisTransformer = Transformer(viewPortHandler: viewPortHandler)
|
|
|
+
|
|
|
self.highlighter = ChartHighlighter(chart: self)
|
|
|
|
|
|
_tapGestureRecognizer = NSUITapGestureRecognizer(target: self, action: #selector(tapGestureRecognized(_:)))
|
|
|
@@ -138,10 +136,10 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
_panGestureRecognizer.isEnabled = _dragXEnabled || _dragYEnabled
|
|
|
|
|
|
#if !os(tvOS)
|
|
|
- _pinchGestureRecognizer = NSUIPinchGestureRecognizer(target: self, action: #selector(BarLineChartViewBase.pinchGestureRecognized(_:)))
|
|
|
- _pinchGestureRecognizer.delegate = self
|
|
|
- self.addGestureRecognizer(_pinchGestureRecognizer)
|
|
|
- _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
|
|
|
+ _pinchGestureRecognizer = NSUIPinchGestureRecognizer(target: self, action: #selector(BarLineChartViewBase.pinchGestureRecognized(_:)))
|
|
|
+ _pinchGestureRecognizer.delegate = self
|
|
|
+ self.addGestureRecognizer(_pinchGestureRecognizer)
|
|
|
+ _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
@@ -198,9 +196,9 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
rightYAxisRenderer.computeAxis(min: rightAxis._axisMinimum, max: rightAxis._axisMaximum, inverted: rightAxis.isInverted)
|
|
|
}
|
|
|
|
|
|
- if _xAxis.isEnabled
|
|
|
+ if xAxis.isEnabled
|
|
|
{
|
|
|
- xAxisRenderer.computeAxis(min: _xAxis._axisMinimum, max: _xAxis._axisMaximum, inverted: false)
|
|
|
+ xAxisRenderer.computeAxis(min: xAxis._axisMinimum, max: xAxis._axisMaximum, inverted: false)
|
|
|
}
|
|
|
|
|
|
xAxisRenderer.renderAxisLine(context: context)
|
|
|
@@ -215,7 +213,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
rightYAxisRenderer.renderGridLines(context: context)
|
|
|
}
|
|
|
|
|
|
- if _xAxis.isEnabled && _xAxis.isDrawLimitLinesBehindDataEnabled
|
|
|
+ if xAxis.isEnabled && xAxis.isDrawLimitLinesBehindDataEnabled
|
|
|
{
|
|
|
xAxisRenderer.renderLimitLines(context: context)
|
|
|
}
|
|
|
@@ -231,10 +229,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
}
|
|
|
|
|
|
context.saveGState()
|
|
|
+
|
|
|
// make sure the data cannot be drawn outside the content-rect
|
|
|
if clipDataToContentEnabled {
|
|
|
- context.clip(to: _viewPortHandler.contentRect)
|
|
|
+ context.clip(to: viewPortHandler.contentRect)
|
|
|
}
|
|
|
+
|
|
|
renderer.drawData(context: context)
|
|
|
|
|
|
// The renderers are responsible for clipping, to account for line-width center etc.
|
|
|
@@ -248,14 +248,14 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
// if highlighting is enabled
|
|
|
if (valuesToHighlight())
|
|
|
{
|
|
|
- renderer.drawHighlighted(context: context, indices: _indicesToHighlight)
|
|
|
+ renderer.drawHighlighted(context: context, indices: highlighted)
|
|
|
}
|
|
|
|
|
|
context.restoreGState()
|
|
|
|
|
|
renderer.drawExtras(context: context)
|
|
|
|
|
|
- if _xAxis.isEnabled && !_xAxis.isDrawLimitLinesBehindDataEnabled
|
|
|
+ if xAxis.isEnabled && !xAxis.isDrawLimitLinesBehindDataEnabled
|
|
|
{
|
|
|
xAxisRenderer.renderLimitLines(context: context)
|
|
|
}
|
|
|
@@ -277,7 +277,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
if clipValuesToContentEnabled
|
|
|
{
|
|
|
context.saveGState()
|
|
|
- context.clip(to: _viewPortHandler.contentRect)
|
|
|
+ context.clip(to: viewPortHandler.contentRect)
|
|
|
|
|
|
renderer.drawValues(context: context)
|
|
|
|
|
|
@@ -288,9 +288,9 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
renderer.drawValues(context: context)
|
|
|
}
|
|
|
|
|
|
- _legendRenderer.renderLegend(context: context)
|
|
|
+ legendRenderer.renderLegend(context: context)
|
|
|
|
|
|
- drawDescription(context: context)
|
|
|
+ drawDescription(in: context)
|
|
|
|
|
|
drawMarkers(context: context)
|
|
|
}
|
|
|
@@ -301,12 +301,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// Performs auto scaling of the axis by recalculating the minimum and maximum y-values based on the entries currently in view.
|
|
|
internal func autoScale()
|
|
|
{
|
|
|
- guard let data = _data
|
|
|
+ guard let data = data
|
|
|
else { return }
|
|
|
|
|
|
data.calcMinMaxY(fromX: self.lowestVisibleX, toX: self.highestVisibleX)
|
|
|
|
|
|
- _xAxis.calculate(min: data.xMin, max: data.xMax)
|
|
|
+ xAxis.calculate(min: data.xMin, max: data.xMax)
|
|
|
|
|
|
// calculate axis range (min / max) according to provided data
|
|
|
|
|
|
@@ -325,7 +325,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
|
|
|
internal func prepareValuePxMatrix()
|
|
|
{
|
|
|
- _rightAxisTransformer.prepareMatrixValuePx(chartXMin: _xAxis._axisMinimum, deltaX: CGFloat(xAxis.axisRange), deltaY: CGFloat(rightAxis.axisRange), chartYMin: rightAxis._axisMinimum)
|
|
|
+ _rightAxisTransformer.prepareMatrixValuePx(chartXMin: xAxis._axisMinimum, deltaX: CGFloat(xAxis.axisRange), deltaY: CGFloat(rightAxis.axisRange), chartYMin: rightAxis._axisMinimum)
|
|
|
_leftAxisTransformer.prepareMatrixValuePx(chartXMin: xAxis._axisMinimum, deltaX: CGFloat(xAxis.axisRange), deltaY: CGFloat(leftAxis.axisRange), chartYMin: leftAxis._axisMinimum)
|
|
|
}
|
|
|
|
|
|
@@ -344,17 +344,14 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
leftYAxisRenderer.computeAxis(min: leftAxis._axisMinimum, max: leftAxis._axisMaximum, inverted: leftAxis.isInverted)
|
|
|
rightYAxisRenderer.computeAxis(min: rightAxis._axisMinimum, max: rightAxis._axisMaximum, inverted: rightAxis.isInverted)
|
|
|
|
|
|
- if let data = _data
|
|
|
+ if let data = data
|
|
|
{
|
|
|
xAxisRenderer.computeAxis(
|
|
|
- min: _xAxis._axisMinimum,
|
|
|
- max: _xAxis._axisMaximum,
|
|
|
+ min: xAxis._axisMinimum,
|
|
|
+ max: xAxis._axisMaximum,
|
|
|
inverted: false)
|
|
|
|
|
|
- if _legend !== nil
|
|
|
- {
|
|
|
- legendRenderer?.computeLegend(data: data)
|
|
|
- }
|
|
|
+ legendRenderer.computeLegend(data: data)
|
|
|
}
|
|
|
|
|
|
calculateOffsets()
|
|
|
@@ -365,39 +362,39 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
internal override func calcMinMax()
|
|
|
{
|
|
|
// calculate / set x-axis range
|
|
|
- _xAxis.calculate(min: _data?.xMin ?? 0.0, max: _data?.xMax ?? 0.0)
|
|
|
+ xAxis.calculate(min: data?.xMin ?? 0.0, max: data?.xMax ?? 0.0)
|
|
|
|
|
|
// calculate axis range (min / max) according to provided data
|
|
|
- leftAxis.calculate(min: _data?.getYMin(axis: .left) ?? 0.0, max: _data?.getYMax(axis: .left) ?? 0.0)
|
|
|
- rightAxis.calculate(min: _data?.getYMin(axis: .right) ?? 0.0, max: _data?.getYMax(axis: .right) ?? 0.0)
|
|
|
+ leftAxis.calculate(min: data?.getYMin(axis: .left) ?? 0.0, max: data?.getYMax(axis: .left) ?? 0.0)
|
|
|
+ rightAxis.calculate(min: data?.getYMin(axis: .right) ?? 0.0, max: data?.getYMax(axis: .right) ?? 0.0)
|
|
|
}
|
|
|
|
|
|
internal func calculateLegendOffsets(offsetLeft: inout CGFloat, offsetTop: inout CGFloat, offsetRight: inout CGFloat, offsetBottom: inout CGFloat)
|
|
|
{
|
|
|
// setup offsets for legend
|
|
|
- if _legend !== nil && _legend.isEnabled && !_legend.drawInside
|
|
|
+ if legend.isEnabled, !legend.drawInside
|
|
|
{
|
|
|
- switch _legend.orientation
|
|
|
+ switch legend.orientation
|
|
|
{
|
|
|
case .vertical:
|
|
|
|
|
|
- switch _legend.horizontalAlignment
|
|
|
+ switch legend.horizontalAlignment
|
|
|
{
|
|
|
case .left:
|
|
|
- offsetLeft += min(_legend.neededWidth, _viewPortHandler.chartWidth * _legend.maxSizePercent) + _legend.xOffset
|
|
|
+ offsetLeft += min(legend.neededWidth, viewPortHandler.chartWidth * legend.maxSizePercent) + legend.xOffset
|
|
|
|
|
|
case .right:
|
|
|
- offsetRight += min(_legend.neededWidth, _viewPortHandler.chartWidth * _legend.maxSizePercent) + _legend.xOffset
|
|
|
+ offsetRight += min(legend.neededWidth, viewPortHandler.chartWidth * legend.maxSizePercent) + legend.xOffset
|
|
|
|
|
|
case .center:
|
|
|
|
|
|
- switch _legend.verticalAlignment
|
|
|
+ switch legend.verticalAlignment
|
|
|
{
|
|
|
case .top:
|
|
|
- offsetTop += min(_legend.neededHeight, _viewPortHandler.chartHeight * _legend.maxSizePercent) + _legend.yOffset
|
|
|
+ offsetTop += min(legend.neededHeight, viewPortHandler.chartHeight * legend.maxSizePercent) + legend.yOffset
|
|
|
|
|
|
case .bottom:
|
|
|
- offsetBottom += min(_legend.neededHeight, _viewPortHandler.chartHeight * _legend.maxSizePercent) + _legend.yOffset
|
|
|
+ offsetBottom += min(legend.neededHeight, viewPortHandler.chartHeight * legend.maxSizePercent) + legend.yOffset
|
|
|
|
|
|
default:
|
|
|
break
|
|
|
@@ -406,13 +403,13 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
|
|
|
case .horizontal:
|
|
|
|
|
|
- switch _legend.verticalAlignment
|
|
|
+ switch legend.verticalAlignment
|
|
|
{
|
|
|
case .top:
|
|
|
- offsetTop += min(_legend.neededHeight, _viewPortHandler.chartHeight * _legend.maxSizePercent) + _legend.yOffset
|
|
|
+ offsetTop += min(legend.neededHeight, viewPortHandler.chartHeight * legend.maxSizePercent) + legend.yOffset
|
|
|
|
|
|
case .bottom:
|
|
|
- offsetBottom += min(_legend.neededHeight, _viewPortHandler.chartHeight * _legend.maxSizePercent) + _legend.yOffset
|
|
|
+ offsetBottom += min(legend.neededHeight, viewPortHandler.chartHeight * legend.maxSizePercent) + legend.yOffset
|
|
|
|
|
|
default:
|
|
|
break
|
|
|
@@ -471,7 +468,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
offsetBottom += self.extraBottomOffset
|
|
|
offsetLeft += self.extraLeftOffset
|
|
|
|
|
|
- _viewPortHandler.restrainViewPort(
|
|
|
+ viewPortHandler.restrainViewPort(
|
|
|
offsetLeft: max(self.minOffset, offsetLeft),
|
|
|
offsetTop: max(self.minOffset, offsetTop),
|
|
|
offsetRight: max(self.minOffset, offsetRight),
|
|
|
@@ -494,14 +491,14 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
{
|
|
|
// draw the grid background
|
|
|
context.setFillColor(gridBackgroundColor.cgColor)
|
|
|
- context.fill(_viewPortHandler.contentRect)
|
|
|
+ context.fill(viewPortHandler.contentRect)
|
|
|
}
|
|
|
|
|
|
if drawBordersEnabled
|
|
|
{
|
|
|
context.setLineWidth(borderLineWidth)
|
|
|
context.setStrokeColor(borderColor.cgColor)
|
|
|
- context.stroke(_viewPortHandler.contentRect)
|
|
|
+ context.stroke(viewPortHandler.contentRect)
|
|
|
}
|
|
|
|
|
|
if drawGridBackgroundEnabled || drawBordersEnabled
|
|
|
@@ -522,7 +519,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
private var _isDragging = false
|
|
|
private var _isScaling = false
|
|
|
private var _gestureScaleAxis = GestureScaleAxis.both
|
|
|
- private var _closestDataSetToTouch: IChartDataSet!
|
|
|
+ private var _closestDataSetToTouch: ChartDataSetProtocol!
|
|
|
private var _panGestureReachedEdge: Bool = false
|
|
|
private weak var _outerScrollView: NSUIScrollView?
|
|
|
|
|
|
@@ -534,7 +531,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
|
|
|
@objc private func tapGestureRecognized(_ recognizer: NSUITapGestureRecognizer)
|
|
|
{
|
|
|
- if _data === nil
|
|
|
+ if data === nil
|
|
|
{
|
|
|
return
|
|
|
}
|
|
|
@@ -560,31 +557,28 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
|
|
|
@objc private func doubleTapGestureRecognized(_ recognizer: NSUITapGestureRecognizer)
|
|
|
{
|
|
|
- if _data === nil
|
|
|
+ if data === nil
|
|
|
{
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if recognizer.state == NSUIGestureRecognizerState.ended
|
|
|
{
|
|
|
- if _data !== nil && _doubleTapToZoomEnabled && (data?.entryCount ?? 0) > 0
|
|
|
+ if data !== nil && _doubleTapToZoomEnabled && (data?.entryCount ?? 0) > 0
|
|
|
{
|
|
|
var location = recognizer.location(in: self)
|
|
|
- location.x = location.x - _viewPortHandler.offsetLeft
|
|
|
+ location.x = location.x - viewPortHandler.offsetLeft
|
|
|
|
|
|
if isTouchInverted()
|
|
|
{
|
|
|
- location.y = -(location.y - _viewPortHandler.offsetTop)
|
|
|
+ location.y = -(location.y - viewPortHandler.offsetTop)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- location.y = -(self.bounds.size.height - location.y - _viewPortHandler.offsetBottom)
|
|
|
+ location.y = -(self.bounds.size.height - location.y - viewPortHandler.offsetBottom)
|
|
|
}
|
|
|
-
|
|
|
- let scaleX: CGFloat = isScaleXEnabled ? 1.4 : 1.0
|
|
|
- let scaleY: CGFloat = isScaleYEnabled ? 1.4 : 1.0
|
|
|
-
|
|
|
- self.zoom(scaleX: scaleX, scaleY: scaleY, x: location.x, y: location.y)
|
|
|
+
|
|
|
+ self.zoom(scaleX: isScaleXEnabled ? 1.4 : 1.0, scaleY: isScaleYEnabled ? 1.4 : 1.0, x: location.x, y: location.y)
|
|
|
delegate?.chartScaled?(self, scaleX: scaleX, scaleY: scaleY)
|
|
|
}
|
|
|
}
|
|
|
@@ -597,7 +591,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
{
|
|
|
stopDeceleration()
|
|
|
|
|
|
- if _data !== nil &&
|
|
|
+ if data !== nil &&
|
|
|
(_pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled)
|
|
|
{
|
|
|
_isScaling = true
|
|
|
@@ -637,8 +631,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
else if recognizer.state == NSUIGestureRecognizerState.changed
|
|
|
{
|
|
|
let isZoomingOut = (recognizer.nsuiScale < 1)
|
|
|
- var canZoomMoreX = isZoomingOut ? _viewPortHandler.canZoomOutMoreX : _viewPortHandler.canZoomInMoreX
|
|
|
- var canZoomMoreY = isZoomingOut ? _viewPortHandler.canZoomOutMoreY : _viewPortHandler.canZoomInMoreY
|
|
|
+ var canZoomMoreX = isZoomingOut ? viewPortHandler.canZoomOutMoreX : viewPortHandler.canZoomInMoreX
|
|
|
+ var canZoomMoreY = isZoomingOut ? viewPortHandler.canZoomOutMoreY : viewPortHandler.canZoomInMoreY
|
|
|
|
|
|
if _isScaling
|
|
|
{
|
|
|
@@ -647,15 +641,15 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
if canZoomMoreX || canZoomMoreY
|
|
|
{
|
|
|
var location = recognizer.location(in: self)
|
|
|
- location.x = location.x - _viewPortHandler.offsetLeft
|
|
|
+ location.x = location.x - viewPortHandler.offsetLeft
|
|
|
|
|
|
if isTouchInverted()
|
|
|
{
|
|
|
- location.y = -(location.y - _viewPortHandler.offsetTop)
|
|
|
+ location.y = -(location.y - viewPortHandler.offsetTop)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- location.y = -(_viewPortHandler.chartHeight - location.y - _viewPortHandler.offsetBottom)
|
|
|
+ location.y = -(viewPortHandler.chartHeight - location.y - viewPortHandler.offsetBottom)
|
|
|
}
|
|
|
|
|
|
let scaleX = canZoomMoreX ? recognizer.nsuiScale : 1.0
|
|
|
@@ -665,10 +659,10 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
matrix = matrix.scaledBy(x: scaleX, y: scaleY)
|
|
|
matrix = matrix.translatedBy(x: -location.x, y: -location.y)
|
|
|
|
|
|
- matrix = _viewPortHandler.touchMatrix.concatenating(matrix)
|
|
|
-
|
|
|
- _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: true)
|
|
|
+ matrix = viewPortHandler.touchMatrix.concatenating(matrix)
|
|
|
|
|
|
+ viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: true)
|
|
|
+
|
|
|
if delegate !== nil
|
|
|
{
|
|
|
delegate?.chartScaled?(self, scaleX: scaleX, scaleY: scaleY)
|
|
|
@@ -687,7 +681,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
{
|
|
|
stopDeceleration()
|
|
|
|
|
|
- if _data === nil || !self.isDragEnabled
|
|
|
+ if data === nil || !self.isDragEnabled
|
|
|
{ // If we have no data, we have nothing to pan and no data to highlight
|
|
|
return
|
|
|
}
|
|
|
@@ -739,6 +733,10 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
// We will only handle highlights on NSUIGestureRecognizerState.Changed
|
|
|
|
|
|
_isDragging = false
|
|
|
+
|
|
|
+ // Prevent the parent scroll view from scrolling
|
|
|
+ _outerScrollView?.nsuiIsScrollEnabled = false
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
else if recognizer.state == NSUIGestureRecognizerState.changed
|
|
|
@@ -790,8 +788,6 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
}
|
|
|
|
|
|
_isDragging = false
|
|
|
-
|
|
|
- delegate?.chartViewDidEndPanning?(self)
|
|
|
}
|
|
|
|
|
|
if _outerScrollView !== nil
|
|
|
@@ -799,6 +795,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
_outerScrollView?.nsuiIsScrollEnabled = true
|
|
|
_outerScrollView = nil
|
|
|
}
|
|
|
+
|
|
|
+ delegate?.chartViewDidEndPanning?(self)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -818,12 +816,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- let originalMatrix = _viewPortHandler.touchMatrix
|
|
|
+ let originalMatrix = viewPortHandler.touchMatrix
|
|
|
|
|
|
var matrix = CGAffineTransform(translationX: translation.x, y: translation.y)
|
|
|
matrix = originalMatrix.concatenating(matrix)
|
|
|
|
|
|
- matrix = _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: true)
|
|
|
+ matrix = viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: true)
|
|
|
|
|
|
if matrix != originalMatrix
|
|
|
{
|
|
|
@@ -888,7 +886,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
if gestureRecognizer == _panGestureRecognizer
|
|
|
{
|
|
|
let velocity = _panGestureRecognizer.velocity(in: self)
|
|
|
- if _data === nil || !isDragEnabled ||
|
|
|
+ if data === nil || !isDragEnabled ||
|
|
|
(self.hasNoDragOffset && self.isFullyZoomedOut && !self.isHighlightPerDragEnabled) ||
|
|
|
(!_dragYEnabled && abs(velocity.y) > abs(velocity.x)) ||
|
|
|
(!_dragXEnabled && abs(velocity.y) < abs(velocity.x))
|
|
|
@@ -899,13 +897,13 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
else
|
|
|
{
|
|
|
#if !os(tvOS)
|
|
|
- if gestureRecognizer == _pinchGestureRecognizer
|
|
|
- {
|
|
|
- if _data === nil || (!_pinchZoomEnabled && !_scaleXEnabled && !_scaleYEnabled)
|
|
|
+ if gestureRecognizer == _pinchGestureRecognizer
|
|
|
{
|
|
|
- return false
|
|
|
+ if data === nil || (!_pinchZoomEnabled && !_scaleXEnabled && !_scaleYEnabled)
|
|
|
+ {
|
|
|
+ return false
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
@@ -913,7 +911,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
}
|
|
|
|
|
|
#if !os(OSX)
|
|
|
- open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool
|
|
|
+ open override func gestureRecognizerShouldBegin(_ gestureRecognizer: NSUIGestureRecognizer) -> Bool
|
|
|
{
|
|
|
if !super.gestureRecognizerShouldBegin(gestureRecognizer)
|
|
|
{
|
|
|
@@ -925,7 +923,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
#endif
|
|
|
|
|
|
#if os(OSX)
|
|
|
- public func gestureRecognizerShouldBegin(gestureRecognizer: NSGestureRecognizer) -> Bool
|
|
|
+ public func gestureRecognizerShouldBegin(gestureRecognizer: NSUIGestureRecognizer) -> Bool
|
|
|
{
|
|
|
return nsuiGestureRecognizerShouldBegin(gestureRecognizer)
|
|
|
}
|
|
|
@@ -934,11 +932,11 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
open func gestureRecognizer(_ gestureRecognizer: NSUIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: NSUIGestureRecognizer) -> Bool
|
|
|
{
|
|
|
#if !os(tvOS)
|
|
|
- if ((gestureRecognizer is NSUIPinchGestureRecognizer && otherGestureRecognizer is NSUIPanGestureRecognizer) ||
|
|
|
- (gestureRecognizer is NSUIPanGestureRecognizer && otherGestureRecognizer is NSUIPinchGestureRecognizer))
|
|
|
- {
|
|
|
- return true
|
|
|
- }
|
|
|
+ if ((gestureRecognizer is NSUIPinchGestureRecognizer && otherGestureRecognizer is NSUIPanGestureRecognizer) ||
|
|
|
+ (gestureRecognizer is NSUIPanGestureRecognizer && otherGestureRecognizer is NSUIPinchGestureRecognizer))
|
|
|
+ {
|
|
|
+ return true
|
|
|
+ }
|
|
|
#endif
|
|
|
|
|
|
if gestureRecognizer is NSUIPanGestureRecognizer,
|
|
|
@@ -986,10 +984,10 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// Zooms in by 1.4, into the charts center.
|
|
|
@objc open func zoomIn()
|
|
|
{
|
|
|
- let center = _viewPortHandler.contentCenter
|
|
|
+ let center = viewPortHandler.contentCenter
|
|
|
|
|
|
- let matrix = _viewPortHandler.zoomIn(x: center.x, y: -center.y)
|
|
|
- _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false)
|
|
|
+ let matrix = viewPortHandler.zoomIn(x: center.x, y: -center.y)
|
|
|
+ viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false)
|
|
|
|
|
|
// Range might have changed, which means that Y-axis labels could have changed in size, affecting Y-axis size. So we need to recalculate offsets.
|
|
|
calculateOffsets()
|
|
|
@@ -999,10 +997,10 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// Zooms out by 0.7, from the charts center.
|
|
|
@objc open func zoomOut()
|
|
|
{
|
|
|
- let center = _viewPortHandler.contentCenter
|
|
|
+ let center = viewPortHandler.contentCenter
|
|
|
|
|
|
- let matrix = _viewPortHandler.zoomOut(x: center.x, y: -center.y)
|
|
|
- _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false)
|
|
|
+ let matrix = viewPortHandler.zoomOut(x: center.x, y: -center.y)
|
|
|
+ viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false)
|
|
|
|
|
|
// Range might have changed, which means that Y-axis labels could have changed in size, affecting Y-axis size. So we need to recalculate offsets.
|
|
|
calculateOffsets()
|
|
|
@@ -1012,9 +1010,9 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// Zooms out to original size.
|
|
|
@objc open func resetZoom()
|
|
|
{
|
|
|
- let matrix = _viewPortHandler.resetZoom()
|
|
|
- _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false)
|
|
|
-
|
|
|
+ let matrix = viewPortHandler.resetZoom()
|
|
|
+ viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false)
|
|
|
+
|
|
|
// Range might have changed, which means that Y-axis labels could have changed in size, affecting Y-axis size. So we need to recalculate offsets.
|
|
|
calculateOffsets()
|
|
|
setNeedsDisplay()
|
|
|
@@ -1034,9 +1032,9 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
x: CGFloat,
|
|
|
y: CGFloat)
|
|
|
{
|
|
|
- let matrix = _viewPortHandler.zoom(scaleX: scaleX, scaleY: scaleY, x: x, y: -y)
|
|
|
- _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false)
|
|
|
-
|
|
|
+ let matrix = viewPortHandler.zoom(scaleX: scaleX, scaleY: scaleY, x: x, y: -y)
|
|
|
+ viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false)
|
|
|
+
|
|
|
// Range might have changed, which means that Y-axis labels could have changed in size, affecting Y-axis size. So we need to recalculate offsets.
|
|
|
calculateOffsets()
|
|
|
setNeedsDisplay()
|
|
|
@@ -1119,7 +1117,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
transformer: getTransformer(forAxis: axis),
|
|
|
view: self,
|
|
|
yAxis: getAxis(axis),
|
|
|
- xAxisRange: _xAxis.axisRange,
|
|
|
+ xAxisRange: xAxis.axisRange,
|
|
|
scaleX: scaleX,
|
|
|
scaleY: scaleY,
|
|
|
xOrigin: viewPortHandler.scaleX,
|
|
|
@@ -1180,8 +1178,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// Resets all zooming and dragging and makes the chart fit exactly it's bounds.
|
|
|
@objc open func fitScreen()
|
|
|
{
|
|
|
- let matrix = _viewPortHandler.fitScreen()
|
|
|
- _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false)
|
|
|
+ let matrix = viewPortHandler.fitScreen()
|
|
|
+ viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false)
|
|
|
|
|
|
calculateOffsets()
|
|
|
setNeedsDisplay()
|
|
|
@@ -1190,8 +1188,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// Sets the minimum scale value to which can be zoomed out. 1 = fitScreen
|
|
|
@objc open func setScaleMinima(_ scaleX: CGFloat, scaleY: CGFloat)
|
|
|
{
|
|
|
- _viewPortHandler.setMinimumScaleX(scaleX)
|
|
|
- _viewPortHandler.setMinimumScaleY(scaleY)
|
|
|
+ viewPortHandler.setMinimumScaleX(scaleX)
|
|
|
+ viewPortHandler.setMinimumScaleY(scaleY)
|
|
|
}
|
|
|
|
|
|
@objc open var visibleXRange: Double
|
|
|
@@ -1206,8 +1204,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// If you call this method, chart must have data or it has no effect.
|
|
|
@objc open func setVisibleXRangeMaximum(_ maxXRange: Double)
|
|
|
{
|
|
|
- let xScale = _xAxis.axisRange / maxXRange
|
|
|
- _viewPortHandler.setMinimumScaleX(CGFloat(xScale))
|
|
|
+ let xScale = xAxis.axisRange / maxXRange
|
|
|
+ viewPortHandler.setMinimumScaleX(CGFloat(xScale))
|
|
|
}
|
|
|
|
|
|
/// Sets the size of the area (range on the x-axis) that should be minimum visible at once (no further zooming in allowed).
|
|
|
@@ -1217,8 +1215,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// If you call this method, chart must have data or it has no effect.
|
|
|
@objc open func setVisibleXRangeMinimum(_ minXRange: Double)
|
|
|
{
|
|
|
- let xScale = _xAxis.axisRange / minXRange
|
|
|
- _viewPortHandler.setMaximumScaleX(CGFloat(xScale))
|
|
|
+ let xScale = xAxis.axisRange / minXRange
|
|
|
+ viewPortHandler.setMaximumScaleX(CGFloat(xScale))
|
|
|
}
|
|
|
|
|
|
/// Limits the maximum and minimum value count that can be visible by pinching and zooming.
|
|
|
@@ -1229,9 +1227,9 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// If you call this method, chart must have data or it has no effect.
|
|
|
@objc open func setVisibleXRange(minXRange: Double, maxXRange: Double)
|
|
|
{
|
|
|
- let minScale = _xAxis.axisRange / maxXRange
|
|
|
- let maxScale = _xAxis.axisRange / minXRange
|
|
|
- _viewPortHandler.setMinMaxScaleX(
|
|
|
+ let minScale = xAxis.axisRange / maxXRange
|
|
|
+ let maxScale = xAxis.axisRange / minXRange
|
|
|
+ viewPortHandler.setMinMaxScaleX(
|
|
|
minScaleX: CGFloat(minScale),
|
|
|
maxScaleX: CGFloat(maxScale))
|
|
|
}
|
|
|
@@ -1244,7 +1242,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
@objc open func setVisibleYRangeMaximum(_ maxYRange: Double, axis: YAxis.AxisDependency)
|
|
|
{
|
|
|
let yScale = getAxisRange(axis: axis) / maxYRange
|
|
|
- _viewPortHandler.setMinimumScaleY(CGFloat(yScale))
|
|
|
+ viewPortHandler.setMinimumScaleY(CGFloat(yScale))
|
|
|
}
|
|
|
|
|
|
/// Sets the size of the area (range on the y-axis) that should be minimum visible at once, no further zooming in possible.
|
|
|
@@ -1255,7 +1253,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
@objc open func setVisibleYRangeMinimum(_ minYRange: Double, axis: YAxis.AxisDependency)
|
|
|
{
|
|
|
let yScale = getAxisRange(axis: axis) / minYRange
|
|
|
- _viewPortHandler.setMaximumScaleY(CGFloat(yScale))
|
|
|
+ viewPortHandler.setMaximumScaleY(CGFloat(yScale))
|
|
|
}
|
|
|
|
|
|
/// Limits the maximum and minimum y range that can be visible by pinching and zooming.
|
|
|
@@ -1268,7 +1266,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
{
|
|
|
let minScale = getAxisRange(axis: axis) / minYRange
|
|
|
let maxScale = getAxisRange(axis: axis) / maxYRange
|
|
|
- _viewPortHandler.setMinMaxScaleY(minScaleY: CGFloat(minScale), maxScaleY: CGFloat(maxScale))
|
|
|
+ viewPortHandler.setMinMaxScaleY(minScaleY: CGFloat(minScale), maxScaleY: CGFloat(maxScale))
|
|
|
}
|
|
|
|
|
|
/// Moves the left side of the current viewport to the specified x-value.
|
|
|
@@ -1293,7 +1291,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// - axis: - which axis should be used as a reference for the y-axis
|
|
|
@objc open func moveViewToY(_ yValue: Double, axis: YAxis.AxisDependency)
|
|
|
{
|
|
|
- let yInView = getAxisRange(axis: axis) / Double(_viewPortHandler.scaleY)
|
|
|
+ let yInView = getAxisRange(axis: axis) / Double(viewPortHandler.scaleY)
|
|
|
|
|
|
let job = MoveViewJob(
|
|
|
viewPortHandler: viewPortHandler,
|
|
|
@@ -1314,7 +1312,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// - axis: - which axis should be used as a reference for the y-axis
|
|
|
@objc open func moveViewTo(xValue: Double, yValue: Double, axis: YAxis.AxisDependency)
|
|
|
{
|
|
|
- let yInView = getAxisRange(axis: axis) / Double(_viewPortHandler.scaleY)
|
|
|
+ let yInView = getAxisRange(axis: axis) / Double(viewPortHandler.scaleY)
|
|
|
|
|
|
let job = MoveViewJob(
|
|
|
viewPortHandler: viewPortHandler,
|
|
|
@@ -1346,7 +1344,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
point: CGPoint(x: viewPortHandler.contentLeft, y: viewPortHandler.contentTop),
|
|
|
axis: axis)
|
|
|
|
|
|
- let yInView = getAxisRange(axis: axis) / Double(_viewPortHandler.scaleY)
|
|
|
+ let yInView = getAxisRange(axis: axis) / Double(viewPortHandler.scaleY)
|
|
|
|
|
|
let job = AnimatedMoveViewJob(
|
|
|
viewPortHandler: viewPortHandler,
|
|
|
@@ -1411,8 +1409,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
yValue: Double,
|
|
|
axis: YAxis.AxisDependency)
|
|
|
{
|
|
|
- let yInView = getAxisRange(axis: axis) / Double(_viewPortHandler.scaleY)
|
|
|
- let xInView = xAxis.axisRange / Double(_viewPortHandler.scaleX)
|
|
|
+ let yInView = getAxisRange(axis: axis) / Double(viewPortHandler.scaleY)
|
|
|
+ let xInView = xAxis.axisRange / Double(viewPortHandler.scaleX)
|
|
|
|
|
|
let job = MoveViewJob(
|
|
|
viewPortHandler: viewPortHandler,
|
|
|
@@ -1443,8 +1441,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
point: CGPoint(x: viewPortHandler.contentLeft, y: viewPortHandler.contentTop),
|
|
|
axis: axis)
|
|
|
|
|
|
- let yInView = getAxisRange(axis: axis) / Double(_viewPortHandler.scaleY)
|
|
|
- let xInView = xAxis.axisRange / Double(_viewPortHandler.scaleX)
|
|
|
+ let yInView = getAxisRange(axis: axis) / Double(viewPortHandler.scaleY)
|
|
|
+ let xInView = xAxis.axisRange / Double(viewPortHandler.scaleX)
|
|
|
|
|
|
let job = AnimatedMoveViewJob(
|
|
|
viewPortHandler: viewPortHandler,
|
|
|
@@ -1503,7 +1501,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
|
|
|
if Thread.isMainThread
|
|
|
{
|
|
|
- self._viewPortHandler.restrainViewPort(offsetLeft: left, offsetTop: top, offsetRight: right, offsetBottom: bottom)
|
|
|
+ self.viewPortHandler.restrainViewPort(offsetLeft: left, offsetTop: top, offsetRight: right, offsetBottom: bottom)
|
|
|
prepareOffsetMatrix()
|
|
|
prepareValuePxMatrix()
|
|
|
}
|
|
|
@@ -1601,7 +1599,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
_scaleXEnabled = enabled
|
|
|
_scaleYEnabled = enabled
|
|
|
#if !os(tvOS)
|
|
|
- _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
|
|
|
+ _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
|
|
|
#endif
|
|
|
}
|
|
|
}
|
|
|
@@ -1618,7 +1616,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
{
|
|
|
_scaleXEnabled = newValue
|
|
|
#if !os(tvOS)
|
|
|
- _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
|
|
|
+ _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
|
|
|
#endif
|
|
|
}
|
|
|
}
|
|
|
@@ -1636,7 +1634,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
{
|
|
|
_scaleYEnabled = newValue
|
|
|
#if !os(tvOS)
|
|
|
- _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
|
|
|
+ _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
|
|
|
#endif
|
|
|
}
|
|
|
}
|
|
|
@@ -1716,44 +1714,35 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
{
|
|
|
if let h = getHighlightByTouchPoint(pt)
|
|
|
{
|
|
|
- return _data!.entryForHighlight(h)
|
|
|
+ return data!.entry(for: h)
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
/// - Returns: The DataSet object displayed at the touched position of the chart
|
|
|
- @objc open func getDataSetByTouchPoint(point pt: CGPoint) -> IBarLineScatterCandleBubbleChartDataSet?
|
|
|
+ @objc open func getDataSetByTouchPoint(point pt: CGPoint) -> BarLineScatterCandleBubbleChartDataSetProtocol?
|
|
|
{
|
|
|
- let h = getHighlightByTouchPoint(pt)
|
|
|
- if h !== nil
|
|
|
- {
|
|
|
- return _data?.getDataSetByIndex(h!.dataSetIndex) as? IBarLineScatterCandleBubbleChartDataSet
|
|
|
+ guard let h = getHighlightByTouchPoint(pt) else {
|
|
|
+ return nil
|
|
|
}
|
|
|
- return nil
|
|
|
+
|
|
|
+ return data?[h.dataSetIndex] as? BarLineScatterCandleBubbleChartDataSetProtocol
|
|
|
}
|
|
|
|
|
|
/// The current x-scale factor
|
|
|
@objc open var scaleX: CGFloat
|
|
|
{
|
|
|
- if _viewPortHandler === nil
|
|
|
- {
|
|
|
- return 1.0
|
|
|
- }
|
|
|
- return _viewPortHandler.scaleX
|
|
|
+ return viewPortHandler.scaleX
|
|
|
}
|
|
|
|
|
|
/// The current y-scale factor
|
|
|
@objc open var scaleY: CGFloat
|
|
|
{
|
|
|
- if _viewPortHandler === nil
|
|
|
- {
|
|
|
- return 1.0
|
|
|
- }
|
|
|
- return _viewPortHandler.scaleY
|
|
|
+ return viewPortHandler.scaleY
|
|
|
}
|
|
|
|
|
|
/// if the chart is fully zoomed out, return true
|
|
|
- @objc open var isFullyZoomedOut: Bool { return _viewPortHandler.isFullyZoomedOut }
|
|
|
+ @objc open var isFullyZoomedOut: Bool { return viewPortHandler.isFullyZoomedOut }
|
|
|
|
|
|
/// - Returns: The y-axis object to the corresponding AxisDependency. In the
|
|
|
/// horizontal bar-chart, LEFT == top, RIGHT == BOTTOM
|
|
|
@@ -1782,7 +1771,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
{
|
|
|
_pinchZoomEnabled = newValue
|
|
|
#if !os(tvOS)
|
|
|
- _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
|
|
|
+ _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
|
|
|
#endif
|
|
|
}
|
|
|
}
|
|
|
@@ -1796,18 +1785,18 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
|
|
|
/// bounds on the x-axis.
|
|
|
@objc open func setDragOffsetX(_ offset: CGFloat)
|
|
|
{
|
|
|
- _viewPortHandler.setDragOffsetX(offset)
|
|
|
+ viewPortHandler.setDragOffsetX(offset)
|
|
|
}
|
|
|
|
|
|
/// Set an offset in dp that allows the user to drag the chart over it's
|
|
|
/// bounds on the y-axis.
|
|
|
@objc open func setDragOffsetY(_ offset: CGFloat)
|
|
|
{
|
|
|
- _viewPortHandler.setDragOffsetY(offset)
|
|
|
+ viewPortHandler.setDragOffsetY(offset)
|
|
|
}
|
|
|
|
|
|
/// `true` if both drag offsets (x and y) are zero or smaller.
|
|
|
- @objc open var hasNoDragOffset: Bool { return _viewPortHandler.hasNoDragOffset }
|
|
|
+ @objc open var hasNoDragOffset: Bool { return viewPortHandler.hasNoDragOffset }
|
|
|
|
|
|
open override var chartYMax: Double
|
|
|
{
|