Mercurial > public > stock-charts
comparison DOCS.md @ 127:fc066e00f4b6
Change info files
author | Dennis <dennis@denniscm.com> |
---|---|
date | Fri, 11 Aug 2023 18:53:38 +0000 |
parents | |
children | ce6bfc2702fb |
comparison
equal
deleted
inserted
replaced
126:22b9e6834fc0 | 127:fc066e00f4b6 |
---|---|
1 | |
2 # Table of Contents | |
3 | |
4 1. [Installation](#orgd9f2fd7) | |
5 2. [Demo app](#orgbd9420c) | |
6 3. [Usage](#org57f1418) | |
7 1. [Line chart](#org19fa053) | |
8 2. [Capsule chart](#orgc225fff) | |
9 1. [Example](#org71304cd) | |
10 | |
11 | |
12 <a id="orgd9f2fd7"></a> | |
13 | |
14 # Installation | |
15 | |
16 - In Xcode go to `File` -> `Swift packages` -> `Add package dependency` | |
17 - Copy and paste `https://github.com/denniscmartin/stock-charts.git` | |
18 | |
19 | |
20 <a id="orgbd9420c"></a> | |
21 | |
22 # Demo app | |
23 | |
24 I've created an example app to show real use cases of this framework, check -> [Trades app](https://github.com/denniscmartin/trades-demo) | |
25 | |
26 | |
27 <a id="org57f1418"></a> | |
28 | |
29 # Usage | |
30 | |
31 import StockCharts | |
32 | |
33 | |
34 <a id="org19fa053"></a> | |
35 | |
36 ## Line chart | |
37 | |
38 let lineChartController = LineChartController(prices: [Double]) | |
39 LineChartView(lineChartController: lineChartController) | |
40 | |
41 You can customise the line chart with `LineChartController` | |
42 | |
43 LineChartController( | |
44 prices: [Double], | |
45 dates: [String]?, // format: yy-MM-dd | |
46 hours: [String]?, // has to correspond to dates | |
47 labelColor: Color, | |
48 indicatorPointColor: Color, | |
49 showingIndicatorLineColor: Color, | |
50 flatTrendLineColor: Color, | |
51 uptrendLineColor: Color, | |
52 downtrendLineColor: Color, | |
53 dragGesture: Bool | |
54 ) | |
55 | |
56 To enable the drag gesture set `dragGesture` to `true` in the `LineChartController` | |
57 | |
58 LineChartView( | |
59 lineChartController: | |
60 LineChartController( | |
61 prices: [Double], | |
62 dragGesture: true | |
63 ) | |
64 ) | |
65 | |
66 | |
67 <a id="orgc225fff"></a> | |
68 | |
69 ## Capsule chart | |
70 | |
71 CapsuleChartView(percentageOfWidth: CGFloat) | |
72 // percentageOfWidth: must be 0 <= x <= 1 | |
73 | |
74 | |
75 <a id="org71304cd"></a> | |
76 | |
77 ### Example | |
78 | |
79 import SwiftUI | |
80 import StockCharts | |
81 | |
82 struct ContentView: View { | |
83 var body: some View { | |
84 RoundedRectangle(cornerRadius: 25) | |
85 .frame(width: 400, height: 120) | |
86 .foregroundColor(.white) | |
87 .shadow(color: Color(.gray).opacity(0.15), radius: 10) | |
88 .overlay( | |
89 VStack(alignment: .leading) { | |
90 Text("Dennis Concepcion") | |
91 .font(.title3) | |
92 .fontWeight(.semibold) | |
93 | |
94 Text("Random guy") | |
95 | |
96 CapsuleChartView(percentageOfWidth: 0.6, style: CapsuleChartStyle(capsuleColor: Color.blue)) | |
97 .padding(.top) | |
98 } | |
99 .padding() | |
100 ) | |
101 } | |
102 } | |
103 |