Swiftpack.co - theo-brlle/chart-ui as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by theo-brlle.
theo-brlle/chart-ui 0.2.1
📈 A SwiftUI chart library
⭐️ 0
🕓 1 week ago
iOS
.package(url: "https://github.com/theo-brlle/chart-ui.git", from: "0.2.1")

ChartUI

A SwiftUI chart library.

Installation

ChartUI is compatible with SPM and Cocoapods.

SPM

Just add this repo as a dependency of your project. Here is the repo URL: https://github.com/theo-brlle/chart-ui.git

Cocoapods

Add ChartUI as a dependency in your Podfile.

pod 'ChartUI', '~> 0.2.1'

Then run pod install and open the .xcworkspace file in Xcode.

Sample usage

Line chart (with one line)

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()
    }
}

GitHub

link
Stars: 0
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

0.2.1
1 week ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics