A SwiftUI chart library.
ChartUI is compatible with SPM and Cocoapods.
Just add this repo as a dependency of your project. Here is the repo URL: https://github.com/theo-brlle/chart-ui.git
Add ChartUI as a dependency in your Podfile
.
pod 'ChartUI', '~> 0.2.1'
Then run pod install
and open the .xcworkspace
file in Xcode.
First, import the library to your file.
import ChartUI
Then, create the data you want to display in the chart and create the LineChartView
.
Don't forget to give it a height with .frame(height:)
.
struct ContentView: View {
let data = [
LineChartSimplePlotData(key: "Jan 1st, 2022", value: FormattedChartValue(value: CGFloat(990), formatted: "990 €")),
LineChartSimplePlotData(key: "Jan 2nd, 2022", value: FormattedChartValue(value: CGFloat(1300), formatted: "1 300 €")),
LineChartSimplePlotData(key: "Jan 3rd, 2022", value: FormattedChartValue(value: CGFloat(1200), formatted: "1 200 €")),
LineChartSimplePlotData(key: "Jan 4th, 2022", value: FormattedChartValue(value: CGFloat(600), formatted: "600 €")),
LineChartSimplePlotData(key: "Jan 5th, 2022", value: FormattedChartValue(value: CGFloat(500), formatted: "500 €")),
LineChartSimplePlotData(key: "Jan 6th, 2022", value: FormattedChartValue(value: CGFloat(600), formatted: "600 €")),
LineChartSimplePlotData(key: "Jan 7th, 2022", value: FormattedChartValue(value: CGFloat(1100), formatted: "1 100 €"))
]
var body: some View {
LineChartView(type: .oneLine(data: oneLineData, detailsViewLabel: "PRICE"))
.frame(height: 250)
.padding()
}
}
link |
Stars: 0 |
Last commit: 1 week ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics