Skip to content

Instantly share code, notes, and snippets.

@rptoma
Last active March 26, 2018 20:24
Show Gist options
  • Select an option

  • Save rptoma/37cef9c394161dcd074e59a678a0e79c to your computer and use it in GitHub Desktop.

Select an option

Save rptoma/37cef9c394161dcd074e59a678a0e79c to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
import Charts
import PlaygroundSupport
func createChartData() -> BarChartData {
var entries = [BarChartDataEntry(x: 1, y: 1000000), BarChartDataEntry(x: 2, y: 1000100)]
// Uncomment this and the animation will work:
// entries = [BarChartDataEntry(x: 1, y: 1000000), BarChartDataEntry(x: 2, y: 10)]
let set = BarChartDataSet(values: entries, label: nil)
set.colors = [UIColor.red, UIColor.blue]
let data = BarChartData(dataSet: set)
return data
}
let view = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 500))
view.backgroundColor = UIColor.white
let barChartView = BarChartView(frame: CGRect(x: 0, y: 0, width: 300, height: 500))
barChartView.data = createChartData()
barChartView.animate(xAxisDuration: 1.5, yAxisDuration: 1.5)
view.addSubview(barChartView)
PlaygroundPage.current.liveView = view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment