comparison README.md @ 129:b8549a53d732

Add images to readme
author Dennis C. M. <dennis@denniscm.com>
date Wed, 20 Nov 2024 09:06:16 +0000
parents 212573e8b5d4
children ce6bfc2702fb
comparison
equal deleted inserted replaced
128:212573e8b5d4 129:b8549a53d732
1 1
2 # stock-charts 2 # stock-charts
3 3
4 This library has been deprecated. Use the native API -> [Charts](https://developer.apple.com/documentation/charts). 4 <a href="https://www.producthunt.com/posts/stockcharts-for-swiftui?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-stockcharts-for-swiftui" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=295975&theme=dark" alt="StockCharts for SwiftUI - Display interactive stock charts easily 🎉 | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
5 5
6 A library to display interactive charts in SwiftUI. 6 This project is now deprecated in favor of the [Apple’s native framework](https://developer.apple.com/documentation/charts). At the time of archiving this project, it has accumulated 98 stars and 11 forks on Github.
7 7
8 <a href="https://www.producthunt.com/posts/stockcharts-for-swiftui?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-stockcharts-for-swiftui" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=295975&theme=dark" alt="StockCharts for SwiftUI - Display interactive stock charts easily 🎉 | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a> 8 StockCharts is a library to create intertactive charts in SwiftUI.
9
10 ## Installation
11 In Xcode go to File -> Swift packages -> Add package dependency
12 Copy and paste https://github.com/denniscmartin/stock-charts.git
13 I’ve created a demo app using StockCharts called Trades. Check out the code in my Github
14
15 ## Usage
16
17 ```swift
18 import StockCharts
19 ```
20
21 ### Line chart
22
23 ```swift
24 let lineChartController = LineChartController(prices: [Double])
25 LineChartView(lineChartController: lineChartController)
26 ```
27
28 You can customise the line chart with LineChartController
29
30 ```swift
31 LineChartController(
32 prices: [Double],
33 dates: [String]?, // format: yy-MM-dd
34 hours: [String]?, // has to correspond to dates
35 labelColor: Color,
36 indicatorPointColor: Color,
37 showingIndicatorLineColor: Color,
38 flatTrendLineColor: Color,
39 uptrendLineColor: Color,
40 downtrendLineColor: Color,
41 dragGesture: Bool
42 )
43 ```
44
45 To enable the drag gesture set dragGesture to true in the LineChartController
46
47 ```swift
48 LineChartView(
49 lineChartController:
50 LineChartController(
51 prices: [Double],
52 dragGesture: true
53 )
54 )
55 ```
56
57 ### Capsule chart
58
59 ```swift
60 CapsuleChartView(percentageOfWidth: CGFloat)
61 // percentageOfWidth: must be 0 <= x <= 1
62 import SwiftUI
63 import StockCharts
64
65 struct ContentView: View {
66 var body: some View {
67 RoundedRectangle(cornerRadius: 25)
68 .frame(width: 400, height: 120)
69 .foregroundColor(.white)
70 .shadow(color: Color(.gray).opacity(0.15), radius: 10)
71 .overlay(
72 VStack(alignment: .leading) {
73 Text("Dennis Concepcion")
74 .font(.title3)
75 .fontWeight(.semibold)
76
77 Text("Random guy")
78
79 CapsuleChartView(percentageOfWidth: 0.6, style: CapsuleChartStyle(capsuleColor: Color.blue))
80 .padding(.top)
81 }
82 .padding()
83 )
84 }
85 }
86 ```