You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To run the example project, clone the repo, and run `pod install` from the Example directory first.
56
56
57
-
###To initialize a chart
57
+
## To initialize a chart
58
58
59
-
####From the Interface Builder
59
+
### From the Interface Builder
60
60
61
61
The chart can be initialized from the Interface Builder. Drag a normal View into a View Controller and assign to it the `Chart` Custom Class from the Identity Inspector.
62
62
63
-
####Programmatically
63
+
### Programmatically
64
64
65
65
To initialize a chart programmatically, use the `Chart(frame: ...)` initializer, which requires a `frame`:
66
66
@@ -75,7 +75,7 @@ let chart = Chart(frame: CGRectZero)
75
75
// add constraints now
76
76
```
77
77
78
-
###Adding series
78
+
## Adding series
79
79
80
80
Initialize each series before adding them to the chart. To do so, pass an array to initialize a `ChartSeries` object:
81
81
@@ -84,33 +84,40 @@ let series = ChartSeries([0, 6.5, 2, 8, 4.1, 7, -3.1, 10, 8])
84
84
chart.add(series)
85
85
```
86
86
87
-
By default, the values on the x-axis are the progressive indexes of the passed array. You can customize those values by passing an array of `(x: Double, y: Double)` tuples to the series initializer:
87
+
**Result:**
88
+
89
+
<imgwidth="400"alt="screen shot 2018-01-07 at 10 51 02"src="https://user-images.githubusercontent.com/120693/34648353-b66f352a-f398-11e7-98b9-9d15dcbdd692.png">
90
+
91
+
92
+
As you can see, as default the values on the x-axis are the progressive indexes of the passed array. You can customize those values by passing an array of `(x: Double, y: Double)` tuples to the series initializer:
88
93
89
94
```swift
90
95
// Create a new series specifying x and y values
91
96
let data = [
92
-
(x: 0, y: 0),
93
-
(x: 0.5, y: 3.1),
94
-
(x: 1.2, y: 2),
95
-
(x: 2.1, y: -4.2),
96
-
(x: 2.6, y: 1.1)
97
+
(x: 0, y: 0),
98
+
(x: 1, y: 3.1),
99
+
(x: 4, y: 2),
100
+
(x: 5, y: 4.2),
101
+
(x: 7, y: 5),
102
+
(x: 9, y: 9),
103
+
(x: 10, y: 8)
97
104
]
98
105
let series =ChartSeries(data: data)
99
106
chart.add(series)
100
107
```
101
108
102
-
#### Multiple series
109
+
**Result:**
103
110
104
-
Using the `chart.add(series: ChartSeries)` and `chart.add(series: Array<ChartSeries>)` methods you can add more series. Those will be indentified with a progressive index in the chart’s `series` property.
Using the `chart.add(series: ChartSeries)` and `chart.add(series: Array<ChartSeries>)` methods you can add more series. Those will be indentified with a progressive index in the chart’s `series` property.
@@ -229,7 +305,17 @@ Some tips for debugging an hidden chart:
229
305
*`area` – draws an area below the series’ line.
230
306
*`line` – set it to `false` to hide the line (useful for drawing only the area).
231
307
*`color` – the series color.
232
-
*`colors` – a tuple to specify the color above or below the zero. For example, `(above: ChartColors.redColor(), below: ChartColors.blueColor(), -4)` will use red for values above `-4`, and blue for values below -4.
308
+
*`colors` – a tuple to specify the color above or below the zero (or another value).
309
+
310
+
For example, to use red for values above `-4`, and blue for values below `-4`.
0 commit comments