Skip to content

Commit 2eb510f

Browse files
authored
Add docs for LineView (#45)
This patch adds documentation (images) for line view.
1 parent f8f6217 commit 2eb510f

File tree

12 files changed

+39
-6
lines changed

12 files changed

+39
-6
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ PlotView {
4242
.frame(width: 500, height: 300)
4343
```
4444

45+
You can use `LineView` to define a line chart:
46+
```swift
47+
PlotView{
48+
LineView(
49+
x: [0, 1, 2, 3, 4, 5],
50+
y: [10, 20, 0, 45, 30, 50]
51+
)
52+
}
53+
.tickInsets(bottom: 20, trailing: 20)
54+
.contentDisposition(minX: -5, maxX: 15, minY: 0)
55+
.frame(width: 600, height: 300)
56+
```
57+
4558
## License
4659

4760
PlotUI is [MIT licensed](LICENSE).

Sources/PlotUI/Line.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import SwiftUI
1111
/// ```swift
1212
/// LineView(
1313
/// x: [0, 1, 2, 3, 4, 5],
14-
/// y: [0, 3, 7, 12, 18, 30]
14+
/// y: [10, 20, 0, 45, 30, 50]
1515
/// )
1616
/// ```
17+
/// ![A line view with line view](lineview.png)
18+
///
1719
/// Usually `LineView` is used within ``PlotView`` container that automatically defines
1820
/// axes with appropriate ticks. You can use ``PlotView/contentDisposition(minX:maxX:minY:maxY:)``
1921
/// to adjust the limits of the axes to position the view's content as you want.
@@ -26,22 +28,24 @@ import SwiftUI
2628
/// PlotView {
2729
/// LineView(
2830
/// x: [1, 2, 3, 4, 5, 6]
29-
/// y: [10, 20, 5, 15, 18, 3]
31+
/// y: [10, 20, 0, 45, 30, 50]
3032
/// )
3133
/// .lineStroke(style: StrokeStyle(lineWidth: 1.0, dash: [2]))
3234
/// }
3335
/// ```
36+
/// ![A line view with dashed stroke 1 pixel width](lineview-linestroke.png)
3437
///
3538
/// You can also change the default color of the line using ``LineView/lineColor(_:)``:
3639
/// ```swift
3740
/// PlotView {
3841
/// LineView(
3942
/// x: [1, 2, 3, 4, 5, 6]
40-
/// y: [10, 20, 5, 15, 18, 3]
43+
/// y: [10, 20, 0, 45, 30, 50]
4144
/// )
42-
/// .lineColor(.black)
45+
/// .lineColor(.mint)
4346
/// }
4447
/// ```
48+
/// ![A linew view with mint color line](lineview-linecolor.png)
4549
///
4650
/// Additionally, you can modify the background overlay of the line chart using
4751
/// ``LineView/lineFill(_:)``:
@@ -54,6 +58,7 @@ import SwiftUI
5458
/// .lineFill(.green.opacity(0.3))
5559
/// }
5660
/// ```
61+
/// ![A line view with opaque green fill](lineview-linefill.png)
5762
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
5863
public struct LineView: FuncView {
5964

Sources/PlotUI/Plot.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public struct VAxis: View {
240240
///
241241
/// For example, to make the horizontal and vertical ticks visible, adjust limits of the
242242
/// axes by setting content disposition:
243-
243+
///
244244
/// ```swift
245245
/// PlotView {
246246
/// BarView(

Sources/PlotUI/PlotUI.docc/PlotUI.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ Integrate beautiful minimalistic plots into your app.
77
PlotUI provides views and view modifiers for creating plots.
88

99
Define your plot using the ``PlotView`` structure, and populate it with concrete data
10-
representation, like ``BarView``, to render data in your app's user interface.
10+
representation, like ``BarView`` or ``LineView``, to render data in your app's user
11+
interface.
1112

1213
![Logo](logo.png)
14+
15+
## Topics
16+
17+
### Essentials
18+
19+
- ``PlotView``
20+
- ``HAxis``
21+
- ``VAxis``
22+
- ``Tick``
23+
24+
### Creating Plots
25+
26+
- ``BarView``
27+
- ``LineView``
90.3 KB
Loading
91.5 KB
Loading
44.9 KB
Loading
45.6 KB
Loading
89.1 KB
Loading
89.7 KB
Loading

0 commit comments

Comments
 (0)