-
-
Notifications
You must be signed in to change notification settings - Fork 6k
/
BubbleChartView.swift
63 lines (50 loc) · 1.55 KB
/
BubbleChartView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// BubbleChartView.swift
// Charts
//
// Bubble chart implementation:
// Copyright 2015 Pierre-Marc Airoldi
// Licensed under Apache License 2.0
//
// https://github.com/danielgindi/ios-charts
//
import Foundation
import CoreGraphics
public class BubbleChartView: BarLineChartViewBase, BubbleChartDataProvider
{
public override func initialize()
{
super.initialize()
renderer = BubbleChartRenderer(dataProvider: self, animator: _animator, viewPortHandler: _viewPortHandler)
}
public override func calcMinMax()
{
super.calcMinMax()
guard let data = _data else { return }
if (_deltaX == 0.0 && data.yValCount > 0)
{
_deltaX = 1.0
}
_chartXMin = -0.5
_chartXMax = Double(data.xVals.count) - 0.5
if renderer as? BubbleChartRenderer !== nil,
let sets = data.dataSets as? [IBubbleChartDataSet]
{
for set in sets {
let xmin = set.xMin
let xmax = set.xMax
if (xmin < _chartXMin)
{
_chartXMin = xmin
}
if (xmax > _chartXMax)
{
_chartXMax = xmax
}
}
}
_deltaX = CGFloat(abs(_chartXMax - _chartXMin))
}
// MARK: - BubbleChartDataProbider
public var bubbleData: BubbleChartData? { return _data as? BubbleChartData }
}