Last active
March 26, 2018 20:24
-
-
Save rptoma/37cef9c394161dcd074e59a678a0e79c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: 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