-
-
Notifications
You must be signed in to change notification settings - Fork 6k
/
Copy pathChartLimitLine.swift
82 lines (70 loc) · 1.99 KB
/
ChartLimitLine.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// ChartLimitLine.swift
// Charts
//
// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda
// A port of MPAndroidChart for iOS
// Licensed under Apache License 2.0
//
// https://github.com/danielgindi/Charts
//
import Foundation
import CoreGraphics
#if canImport(UIKit)
import UIKit
#endif
#if canImport(AppKit)
import AppKit
#endif
/// The limit line is an additional feature for all Line, Bar and ScatterCharts.
/// It allows the displaying of an additional line in the chart that marks a certain maximum / limit on the specified axis (x- or y-axis).
open class ChartLimitLine: ComponentBase
{
@objc(ChartLimitLabelPosition)
public enum LabelPosition: Int
{
case leftTop
case leftBottom
case rightTop
case rightBottom
}
/// limit / maximum (the y-value or xIndex)
@objc open var limit: Double = 0.0
private var _lineWidth: CGFloat = 2.0
@objc open var lineColor = NSUIColor(red: 237.0/255.0, green: 91.0/255.0, blue: 91.0/255.0, alpha: 1.0)
@objc open var lineDashPhase: CGFloat = 0.0
@objc open var lineDashLengths: [CGFloat]?
@objc open var valueTextColor = NSUIColor.labelOrBlack
@objc open var valueFont = NSUIFont.systemFont(ofSize: 13.0)
@objc open var drawLabelEnabled = true
@objc open var label = ""
@objc open var labelPosition = LabelPosition.rightTop
@objc open var labelRotationAngle = CGFloat(0.0)
public override init()
{
super.init()
}
@objc public init(limit: Double)
{
super.init()
self.limit = limit
}
@objc public init(limit: Double, label: String)
{
super.init()
self.limit = limit
self.label = label
}
/// set the line width of the chart (min = 0.2, max = 12); default 2
@objc open var lineWidth: CGFloat
{
get
{
return _lineWidth
}
set
{
_lineWidth = newValue.clamped(to: 0.2...12)
}
}
}