Skip to content

Commit fccf3ca

Browse files
committed
Update README.md
1 parent dd91a86 commit fccf3ca

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ let chart = Chart(frame: CGRectZero)
8080
Initialize each series before adding them to the chart. To do so, pass an array to initialize a `ChartSeries` object:
8181

8282
```swift
83+
let chart = Chart(frame: CGRect(x: 0, y: 0, width: 200, height: 100))
8384
let series = ChartSeries([0, 6.5, 2, 8, 4.1, 7, -3.1, 10, 8])
8485
chart.add(series)
8586
```
@@ -92,6 +93,7 @@ chart.add(series)
9293
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:
9394

9495
```swift
96+
let chart = Chart(frame: CGRect(x: 0, y: 0, width: 200, height: 100))
9597
// Create a new series specifying x and y values
9698
let data = [
9799
(x: 0, y: 0),
@@ -127,8 +129,13 @@ let data = [
127129
]
128130
let series = ChartSeries(data: data)
129131
series.area = true
132+
133+
// Use `xLabels` to add more labels, even if empty
130134
chart.xLabels = [0, 3, 6, 9, 12, 15, 18, 21, 24]
135+
136+
// Format the labels with a unit
131137
chart.xLabelsFormatter = { String(Int(round($1))) + "h" }
138+
132139
chart.add(series)
133140
```
134141

0 commit comments

Comments
 (0)