Coder Social home page Coder Social logo

corecharts's Introduction

Core Charts | Basic Chart Library for iOS

CocoaPods Compatible CocoaPods Compatible

HCoreBarChart VCoreBarChart

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 conform 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!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        barChart.dataSource = self
    }
    
    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
        
    }
 
}

Appearance Customization

CoreBarChartsDisplayConfig Class

You can change ui appearance for charts with CoreBarChartsDisplayConfig class and there have properties, here is the how to do this.

Direct use

You can use one shot initializer

import CoreCharts

class DemoViewController: UIViewController,CoreChartViewDataSource {

    @IBOutlet weak var barChart: VCoreBarChart!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        barChart.dataSource = self
        
        barChart.displayConfig = CoreBarChartsDisplayConfig(barWidth: 40.0,
                                                            barSpace: 20.0,
                                                            bottomSpace: 20.0,
                                                            topSpace: 20.0,
                                                            backgroundColor: UIColor.black,
                                                            titleFontSize: 12,
                                                            valueFontSize: 14,
                                                            titleFont: UIFont(),
                                                            valueFont: UIFont(),
                                                            titleLength: 12)
    }

Spesific use

You can use only what you just need.

import CoreCharts

class DemoViewController: UIViewController,CoreChartViewDataSource {

    @IBOutlet weak var barChart: VCoreBarChart!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        barChart.dataSource = self
        
        bbarChart.displayConfig.barWidth = 10
        barChart.displayConfig.barSpace = 20
        barChart.displayConfig.titleFontSize = 15
    }

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 MIT - see the LICENSE.md file for details

Bug Report

  • if you catch some bug please use add issue section.

Add new feature

  • you can write a suggestion for the next new feature in the project section.

Other My Repos

  • TextSphere - TextSphere is a small framework for customized TextView

corecharts's People

Contributors

cagricolak avatar kodeflow 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  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  avatar  avatar  avatar  avatar

corecharts's Issues

y axis title

how to show range of numbers on y-axis like 5 then abow it 10 then 15 then 20m and so on. please reply

Can't change the appreance

Thanks for making this library. I am not able to figure it out how to change the appearance such as 'bar width', 'Bar gap'. I am using the following code in viewDidLoad method

` func initChartUI() {
    chartView.displayConfig = CoreBarChartsDisplayConfig(barWidth: 10.0,
                                                         barSpace: 10.0,
                                                         bottomSpace: 20.0,
                                                         topSpace: 20.0,
                                                         backgroundColor: UIColor.red,
                                                         titleFontSize: 12,
                                                         valueFontSize: 14,
                                                         titleFont: UIFont(),
                                                         valueFont: UIFont(),
                                                         titleLength: 12)
}`

The output is : https://ibb.co/gvyk7Z1
How can I change the bar gap and bar width?

Red Background

Hi every time I reload the chart with new data the background colour is changed to red.

It seems this cannot be overridden.

Thanks

Two view as coreChats in the same view controller

Hi i am using two view as coreChats in the same view controller. please let me know how to handle this situation. i am only getting same value in both the views.i want to show different values there.

Thanks & Regards
Tapan Raut

Set Background Color after Reload

Thank you for providing CoreChart for use.
I've tried the method you mentioned in the Red Background issue, but it didn't work. How can I fix this problem?

This is my code. I tried to add it before and after reload the data.
螢幕快照 2019-07-30 下午6 12 23

After reloading
螢幕快照 2019-07-30 下午6 12 36

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.