Skip to content

JamesSedlacek/RatioBarChart

Repository files navigation

RatioBarChart

Swift Package Manager GitHub stars GitHub forks GitHub contributors Pull Requests Badge Issues Badge


Requirements

  • iOS: 15.0 or later.
  • macOS: 12.0 or later.

Installation

You can install RatioBarChart using the Swift Package Manager.

  1. In Xcode, select "File" > "Add Package Dependencies".
  2. Copy & paste the following into the "Search or Enter Package URL" search bar.
https://github.com/JamesSedlacek/RatioBarChart.git
  1. Xcode will fetch the repository & the "RatioBarChart" library will be added to your project.

Usage

There's a default initializer that sets the font, text, and colors for a win/loss ratio bar chart.

import RatioBarChart
import SwiftUI

struct ContentView: View {
    var body: some View {
        RatioBarChart(wins: 50, losses: 50)
    }
}

Customizations

The initializer allows you to customize the chart's colors, text, & font.

public init(firstCount: Int, secondCount: Int,
            firstColor: Color, secondColor: Color,
            topLeftText: String, topRightText: String,
            bottomLeftText: String, bottomRightText: String,
            topFont: FontRepresentable = .systemFont(ofSize: 16, weight: .semibold),
            bottomFont: FontRepresentable = .systemFont(ofSize: 14, weight: .medium))

Author

James Sedlacek, find me on X/Twitter or LinkedIn

About

SwiftUI Component for displaying a ratio in a bar chart

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages