Skip to content

cagricolak/CoreCharts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoreCharts

Elegant way to use Graph Charts on Apple ecosystem with CoreCharts 😎

alt text alt text

Getting Started

You need a Cocoapods installed mac, if you are not familiar that visit here CocoaPods

Requirements

  • XCode 8.3+
  • iOS 9.3+

Installation

Add your pod file

pod 'CoreCharts'

and than hit the your command line

pod install 

now you are ready to use CoreCharts

Usage

import where you want to use

import CoreCharts

and than open up your storyboard or xib file and add new UIView drop your main view. afterwards change subclass to Vertical for VCoreBarChart or Horizontal chart for HCoreBarChart

alt text

referance it!

@IBOutlet weak var barChart: VCoreBarChart!

most important setup is ready, now you can use some of featuristic CoreChart's properties.

firstly you need comform your class to data source protocol,

class DemoViewController: UIViewController,CoreChartViewDataSource {

    @IBOutlet weak var barChart: VCoreBarChart!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        barChart.dataSource = self
    }

now, you have two methods, implement it.

func loadCoreChartData() -> [CoreChartEntry]

optional func didTouch(entryData: CoreChartEntry)

loadCoreChartData method is fill your bar charts, you need to convert your data to CoreChartEntry type

func loadCoreChartData() -> [CoreChartEntry] {

        var allCityData = [CoreChartEntry]()
    
        let cityNames = ["Istanbul","Antalya","Ankara","Trabzon","İzmir"]
    
        let plateNumber = [34,07,06,61,35]
        
        for index in 0..<cityNames.count {
            
            let newEntry = CoreChartEntry(id: "\(plateNumber[index])", 
                                          barTitle: cityNames[index], 
                                          barHeight: Double(plateNumber[index]), 
                                          barColor: rainbowColor())
                                          
                                          
            allCityData.append(newEntry)
            
        }
        
        return allCityData

}

CoreChartEntry properties

  • id = when you are use didTouch method and you want to access some data level for bar selection you need here.
  • barTitle = ... you now what it is :)
  • ..and the rest..

One more thing..

optional func didTouch(entryData: CoreChartEntry)

this method is optional and when you want to navigate your chart screens each other through selected your data level

data level means: Running a query on your data structures with id

Finish.

Here is the full code as you have just been told, and already in the demo project.

import CoreCharts

class DemoViewController: UIViewController,CoreChartViewDataSource {

    @IBOutlet weak var barChart: VCoreBarChart!
    
    
    func didTouch(entryData: CoreChartEntry) {
        print(entryData.barTitle)
    }
    
    func loadCoreChartData() -> [CoreChartEntry] {
        
        return getTurkeyFamouseCityList()
        
    }
    
    
    func getTurkeyFamouseCityList()->[CoreChartEntry] {
        var allCityData = [CoreChartEntry]()
        let cityNames = ["Istanbul","Antalya","Ankara","Trabzon","İzmir"]
        let plateNumber = [34,07,06,61,35]
        
        for index in 0..<cityNames.count {
            
            let newEntry = CoreChartEntry(id: "\(plateNumber[index])", 
                                          barTitle: cityNames[index], 
                                          barHeight: Double(plateNumber[index]), 
                                          barColor: rainbowColor())
                                          
                                         
            allCityData.append(newEntry)
            
        }
        
        return allCityData
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        barChart.dataSource = self
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

Contribute are Welcome 🎉

Versioning

We use SemVer for versioning. For the versions available, see the CoreCharts Tagi wagi.

Authors

  • Çağrı ÇOLAK - Sr.iOS Developer - Github
  • Kemal TÜRK - jr.iOS Developer / Android Developer - Github

License

This project is licensed under the Apache License 2.0 - see the LICENSE.md file for details

Bug Report

  • if you catch some bug please use StackOverflow, use this tag: corecharts-2018 and ask we.