Coder Social home page Coder Social logo

flowerchart's Introduction

FlowerChart - custom chart written in Swift

Fully vector flower-shaped chart written in Swift

Swift Version License Platform

Flower-shaped chart written in Swift, this repo is a sample project you can build directly on your iPhone. The charts generated are fully vector and scale without any rasterization and annying pixels. Part of the Awesome iOS curated list.

The chart itself looks as follows:

alt tag

Features

  • Fully vector petals, well adjusted to any screen size
  • Supports any number of petals
  • All petals can be color-coded

Requirements

  • iOS 8.0+
  • Xcode 7.3

Installation & usage

Manually

  1. Download and drop FlowerChart.swift in your project.
  2. Congratulations, you are all set!

Usage example

You can set arbitrary number of "petals" for the flower while creating an instance of the FlowerChart class, draw the flower itself with drawFlower method (providing an array of UIColors for petals to look the way you like) and set sizes to them using the setPetalSizes method. Size for each petal has to be a Double 0.0 ..< 10.0 (no failsafe check in place yet, to be added in future releases). In the sample project there is a Refresh button that generates random sizes for all the petals to show how the chart might look like.

To use flower charts in your own project - just add the FlowerChart.swift file to it. You'd need a pre-set UIView which will serve as a canvas for the chart to appear on (just create a basic outlet for it), it's auto-fitted inside the view so no restrictions on its layout.

In the ViewController you need the following properties:

var flowerChart: FlowerChart!
var sizesArray = [Double]()
var colorsArray = [UIColor]()
let totalPetals = 9 // Set any number of petals you need

Ensure sizesArray and colorsArray contain necessary amount of elements to draw the number of petals you need. Create an instance of FlowerChart class on viewDidAppear and set it up in just 4 lines of code:

let flowerChart = FlowerChart(petalCanvas: petalCanvas, totalPetals: totalPetals)
self.flowerChart = flowerChart
flowerChart.drawFlower(colorsArray)
flowerChart.setPetalSizes(sizesArray)

Release History

  • 0.1.0
    • The first release, current version

Contribute

We would love for you to contribute to Flowerchart, check the LICENSE file for more info.

Meta

Alexander Telegin โ€“ @drinkius โ€“ [email protected]

Distributed under the MIT license. See LICENSE for more information.

https://github.com/drinkius/flowerchart

Good luck and feel free to report any issues, I'll fix them shortly!

flowerchart's People

Contributors

drinkius avatar

Watchers

 avatar  avatar

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.