-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChartConfigurationOptions.swift
More file actions
151 lines (132 loc) · 4.08 KB
/
ChartConfigurationOptions.swift
File metadata and controls
151 lines (132 loc) · 4.08 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import Foundation
/// Options for configuring a chart in our charting library
///
/// Subset of echart's options https://echarts.apache.org/en/option.html
public struct ChartConfigurationOptions: Codable, Equatable, Sendable {
/// Whether to enable animation.
public var animation: Bool?
/// Duration of the animation in milliseconds.
public var animationDuration: Int?
/// Easing function of the animation.
public var animationEasing: EasingFunction?
/// Show a tooltip for this chart
public var tooltip: ToolTipConfiguration?
public var grid: GridConfiguration?
public var xAxis: AxisOptions?
public var yAxis: AxisOptions?
public init(
animation: Bool? = nil,
animationDuration: Int? = nil,
animationEasing: EasingFunction? = nil,
tooltip: ToolTipConfiguration? = nil,
grid: GridConfiguration? = nil,
xAxis: AxisOptions? = nil,
yAxis: AxisOptions? = nil
) {
self.animation = animation
self.animationDuration = animationDuration
self.animationEasing = animationEasing
self.tooltip = tooltip
self.grid = grid
self.xAxis = xAxis
self.yAxis = yAxis
}
}
public struct ToolTipConfiguration: Codable, Equatable, Sendable {
public var show: Bool?
public init(show: Bool? = nil) {
self.show = show
}
}
public struct GridConfiguration: Codable, Equatable, Sendable {
public var top: Int?
public var bottom: Int?
public var left: Int?
public var right: Int?
public var containLabel: Bool?
public init(
top: Int? = nil,
bottom: Int? = nil,
left: Int? = nil,
right: Int? = nil,
containLabel: Bool? = nil
) {
self.top = top
self.bottom = bottom
self.left = left
self.right = right
self.containLabel = containLabel
}
}
public enum EasingFunction: String, Codable, Sendable {
case linear
case quadraticIn
case quadraticOut
case quadraticInOut
case cubicIn
case cubicOut
case cubicInOut
case quarticIn
case quarticOut
case quarticInOut
case quinticIn
case quinticOut
case quinticInOut
case sinusoidalIn
case sinusoidalOut
case sinusoidalInOut
case exponentialIn
case exponentialOut
case exponentialInOut
case circularIn
case circularOut
case circularInOut
case elasticIn
case elasticOut
case elasticInOut
case backIn
case backOut
case backInOut
case bounceIn
case bounceOut
case bounceInOut
}
public struct AxisOptions: Codable, Equatable, Sendable {
/// Set this to false to prevent the axis from showing.
public var show: Bool?
public var position: Position?
public var type: AxisType?
public var name: String?
/// Set this to true to invert the axis.
public var inverse: Bool?
public init(
show: Bool? = nil,
position: AxisOptions.Position? = nil,
type: AxisOptions.AxisType? = nil,
name: String? = nil,
inverse: Bool? = nil
) {
self.show = show
self.position = position
self.type = type
self.name = name
self.inverse = inverse
}
public enum Position: String, Codable, Equatable, Sendable {
case top
case bottom
}
public enum AxisType: String, Codable, Equatable, Sendable {
/// Numerical axis, suitable for continuous data.
case value
/// Category axis, suitable for discrete category data.
case category
/// Time axis, suitable for continuous time series data. As compared to value axis, it has a better formatting for time and a
/// different tick calculation method. For example, it decides to use month, week, day or hour for tick based on the range of
/// span.
case time
/// Log axis, suitable for log data. Stacked bar or line series with type: 'log' axes may lead to significant visual errors and
/// may have unintended effects in certain circumstances. Their use should be avoided.
case log
}
}