forked from gpbl/SwiftChart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChartSeries.swift
executable file
·39 lines (34 loc) · 1.04 KB
/
ChartSeries.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
//
// ChartSeries.swift
//
// Created by Giampaolo Bellavite on 07/11/14.
// Copyright (c) 2014 Giampaolo Bellavite. All rights reserved.
//
import UIKit
/**
Represent a series to draw in the line chart. Each series is defined with a dataset and appareance settings.
*/
class ChartSeries {
var data: Array<(x: Float, y: Float)>
var area: Bool = false
var line: Bool = true
var color: UIColor = ChartColors.blueColor() {
didSet {
colors = (above: color, below: color)
}
}
var colors: (above: UIColor, below: UIColor) = (above: ChartColors.blueColor(), below: ChartColors.redColor())
init(_ data: Array<Float>) {
self.data = []
for (x, y) in enumerate(data) {
let point: (x: Float, y: Float) = (x: Float(x), y: y)
self.data.append(point)
}
}
init(data: Array<(x: Float, y: Float)>) {
self.data = data
}
init(data: Array<(x: Double, y: Double)>) {
self.data = data.map ({ (Float($0.x), Float($0.y))})
}
}