https://github.com/denniscmcom/stock-charts
A library to display interactive charts in SwiftUI
https://github.com/denniscmcom/stock-charts
Last synced: 13 days ago
JSON representation
A library to display interactive charts in SwiftUI
- Host: GitHub
- URL: https://github.com/denniscmcom/stock-charts
- Owner: denniscmcom
- License: mit
- Created: 2021-04-26T09:08:10.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-20T09:06:21.000Z (6 months ago)
- Last Synced: 2025-04-19T06:39:36.178Z (about 1 month ago)
- Language: Swift
- Homepage:
- Size: 1.64 MB
- Stars: 101
- Watchers: 4
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-swiftui-libraries - stock-charts - SwiftUI stock charts for iOS (Chart / Content)
README
# stock-charts
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.
StockCharts is a library to create intertactive charts in SwiftUI.
## Installation
In Xcode go to File -> Swift packages -> Add package dependency
Copy and paste https://github.com/denniscmartin/stock-charts.git
I’ve created a demo app using StockCharts called Trades. Check out the code in my Github## Usage
```swift
import StockCharts
```### Line chart
```swift
let lineChartController = LineChartController(prices: [Double])
LineChartView(lineChartController: lineChartController)
```You can customise the line chart with LineChartController
```swift
LineChartController(
prices: [Double],
dates: [String]?, // format: yy-MM-dd
hours: [String]?, // has to correspond to dates
labelColor: Color,
indicatorPointColor: Color,
showingIndicatorLineColor: Color,
flatTrendLineColor: Color,
uptrendLineColor: Color,
downtrendLineColor: Color,
dragGesture: Bool
)
```To enable the drag gesture set dragGesture to true in the LineChartController
```swift
LineChartView(
lineChartController:
LineChartController(
prices: [Double],
dragGesture: true
)
)
```### Capsule chart
```swift
CapsuleChartView(percentageOfWidth: CGFloat)
// percentageOfWidth: must be 0 <= x <= 1
import SwiftUI
import StockChartsstruct ContentView: View {
var body: some View {
RoundedRectangle(cornerRadius: 25)
.frame(width: 400, height: 120)
.foregroundColor(.white)
.shadow(color: Color(.gray).opacity(0.15), radius: 10)
.overlay(
VStack(alignment: .leading) {
Text("Dennis Concepcion")
.font(.title3)
.fontWeight(.semibold)Text("Random guy")
CapsuleChartView(percentageOfWidth: 0.6, style: CapsuleChartStyle(capsuleColor: Color.blue))
.padding(.top)
}
.padding()
)
}
}
```