Giter Club home page Giter Club logo

ringpiechart's Introduction

RingPieChart

CI Status CocoaPods Version Carthage Compatible License Platform Swift 5.1

Add Beautiful Ring Piechart in your Project




Requirements

  • iOS 10.0+ / Mac OS X 10.9+ / watchOS 2.0+ / tvOS 9.0+
  • Xcode 8.0+

Installation

To integrate RingPieChart into your Xcode project using CocoaPods, specify it in your Podfile:

use_frameworks!

pod 'RingPieChart'

Then, run the following command:

$ pod install

To integrate RingPieChart into your Xcode project using Carthage, specify it in your Cartfile:

github "jwd-ali/RingPieChart"

Prerequisites

  • OSX

Update Package.swift

To integrate RingPieChart in your project, add the proper description to your Package.swift file:

// swift-tools-version:5.0
import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    dependencies: [
        .package(url: "https://github.com/jwd-ali/RingPieChart.git", from: "2.0.0")
    ],
    targets: [
        .target(
            name: "YOUR_TARGET_NAME",
            dependencies: ["RingPieChart"]
        ),
        ...
    ]
)

Manually

If you prefer not to use a dependency manager, you can integrate RingPieChart into your project manually.

  • Add sources into your project:
    • Drag Circular.swift

Usage

If you are using any dependency manager (pods , carthage , package manager)to integrate RingPieChart. Import RingPieChart first:

import RingPieChart

And for Manuall install you dont need to import anything

  • Init your ring with percentages and colors:
 let chart = Circular(percentages: [42,27,18,13], colors: [.blue,.purple,.orange,.red],aimationType: .animationFadeIn,showPercentageStyle: .inward)
 // OR 
 let chart = Circular(percentages: [42,27,18,13], colors: [.blue,.purple,.orange,.red])

Animation is True by default you can set frame or add constraints to chart

 chart.frame = CGRect(x: 50, y: 50, width: 250, height: 250)
 self.view .addSubview(chart)

You can add chart line width by setting lineWidth property like this

chart.lineWidth = 12 

Ring chart Has 5 values for its Animation Enum

public enum AnimationStyle: Int {
    case animationFanAll
    case animationFan
    case animationFadeIn
    case animationthreeD
    case none
}

and 4 different styles of showing percentages. You can choose accoding to your UI needs

public enum PercentageStyle : Int {
    case none
    case inward
    case outward
    case over
    
}

You can pass them in an initialiser or set there value after intialisation

chart.animationType =  .animationFan
chart.showPercentageStyle = .outward

Congratulations! You're done.

Beautiful Ring PieChart

Contributing

I’d love to have help on this project. For small changes please open a pull request, for larger changes please open an issue first to discuss what you’d like to see.

License

RingPieChart is under MIT. See LICENSE file for more info.

ringpiechart's People

Contributors

jawad-digitify avatar jwd-ali avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ringpiechart's Issues

Colors mishmash

Hi,
thank you very much for your project! I would like to generate a pie chart and change the input data. When I do this, the colors start to display poorly. Try:
`
import UIKit
import RingPieChart

class ViewController: UIViewController {

@IBOutlet weak private var percentageSegment: UISegmentedControl!
@IBOutlet weak private var animationSegment: UISegmentedControl!
private var cir :Circular!
var aaa = [[Double]]()
override func viewDidAppear(_ animated: Bool) {
 let bbb = [0.0,3.0,97.0]
    aaa.append(bbb)
    addToView()
}

private func addToView() {
    if (cir != nil)  {
        cir.removeFromSuperview()
    }
    
    print(aaa)
    
    let barva: [UIColor] = [.blue,.purple,.orange]
    cir = Circular(percentages: aaa[0], colors: barva)
    cir.animationType = AnimationStyle.init(rawValue: animationSegment.selectedSegmentIndex) ?? .animationFan
    cir.showPercentageStyle = PercentageStyle.init(rawValue: percentageSegment.selectedSegmentIndex) ?? .none
    cir.frame = CGRect(x: 50, y: 50, width: 300, height: 300)
    cir.lineWidth = 10
    cir.center = self.view.center
    
    self.view.addSubview(cir)
}

@IBAction private func animationStyles(_ sender: UISegmentedControl) {
    aaa = []
    let bbb = [97,3.0,0.0]
    aaa.append(bbb)
    addToView()
}

@IBAction private func percentagestyles(_ sender: UISegmentedControl) {
    
    aaa = []
    let bbb = [0.0,0.0,100.0]
    aaa.append(bbb)
    addToView()
}

}

`

Do you have any idea where the mistake is?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.