Giter Club home page Giter Club logo

lightcharts's Introduction

Create easy and beautiful graphs using all power of Charts Framework in a few seconds

Installation

POD Installation:

pod 'LightCharts', :git => 'https://github.com/leodegeus7/LightCharts.git'

Usage example

To use this tool you need to follow few steps:

  1. Create a UIView in your Storyboard
  2. Link an outlet of this view in your Controller and import the framework LightCharts;
  3. Create your series to plot in graph, graphs may have more than one serie, so feel free to create as many serie as you want.
let x = ["B0OO","C000","D000","E000"]
let y1:[Double] = [100,200,300,400]
let serie1 = Serie(label: "Monday", entries: y1, color: UIColor.red)
let y2:[Double] = [130,180,310,420]
let serie2 = Serie(label: "Tuesday", entries: y2, color: UIColor.yellow)
  1. Instantiate a chart config, this config need to be consistent with your graph type. ChartConfig is the way that you can customize and choose the the type of your chart. There are four types of graph in this tool: Bar, Pie, Line, Radar.
let config = BarChartConfig()
let config = PieChartConfig()
let config = LineChartConfig()
let config = RadarChartConfig()
  1. To finish, create a new object of the type LightsCharts passing the view created in Item 1, the config created in item 4, the serie created in item 3 and an array of strings to label your series.
let chart = LightCharts(graph: graph, config: config, serie: serie, xLabel: x)
chart.plot()

If you want to create a multi-serie graph, use:

let chart = LightCharts(graph: graph, config: config, series: [serie1,serie2], xLabel: x)
chart.plot()

EXTRAS 6) Customization. For example, to draw the values in the middle of the bar and change the size of label in X Axis just edit the config file: Hint: pass nil on properties you dont want to change, this tool will get the best parameters to you.

let config = BarChartConfig()
config.drawValues = .True(font: .Medium, color: UIColor.red)
config.drawXAxis = .True(font: .Medium, labelColor: nil, drawGrid: nil)
  1. Animations. To animate your graph in real time, use the functions .highlightValueInGraph() and spinGraph() in LightCharts object.
chart.spinGraph(seconds:2,indexToSpin: 3)
chart.highlightValueInGraph(xIndex: 3, dataSetIndex: 0)

Alt Text

Hints

If you want to create a colorful serie, instantiate the following code instead of Serie, this is the unique way to diferenciate data in PieChart

ColorSerie(label: String, entries: [Double], color: [UIColor])

Release History

  • 0.0.1
    • First Commit
  • 0.0.2
    • Added Animations
  • 0.0.24
    • Support to Swift 4.2

References

Charts: https://github.com/danielgindi/Charts

Meta

Leonardo Alexandre de Geus โ€“ @leodegeus7 โ€“ [email protected]

See LICENSE for more information.

https://github.com/leodegeus7

lightcharts's People

Contributors

leodegeus7 avatar

Stargazers

Diler Barbosa avatar

Watchers

James Cloos avatar Diler Barbosa avatar Carol Machado 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.