We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here is my code.
// // ChartsViewController.swift // iOSChartsDemo //
import UIKit import Charts
class ChartsViewController: UIViewController {
@IBOutlet weak var lineChartView: LineChartView! @IBOutlet weak var pieChartView: PieChartView! var months: [String]! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0] setChart(dataPoints: months, values: unitsSold) } func setChart(dataPoints: [String], values: [Double]) { var dataEntries: [BarChartDataEntry] = [] var counter = 0.0 for i in 0..<dataPoints.count { counter += 1.0 let dataEntry = BarChartDataEntry(x: values[i], y: counter) dataEntries.append(dataEntry) } let chartDataSet = BarChartDataSet(values: dataEntries, label: "Units Sold") let chartData = BarChartData() chartData.addDataSet(chartDataSet) pieChartView.data = chartData var colors: [UIColor] = [] for _ in 0..<dataPoints.count { let red = Double(arc4random_uniform(256)) let green = Double(arc4random_uniform(256)) let blue = Double(arc4random_uniform(256)) let color = UIColor(red: CGFloat(red/255), green: CGFloat(green/255), blue: CGFloat(blue/255), alpha: 1) colors.append(color) } chartDataSet.colors = colors let lineDataSet = LineChartDataSet(values: dataEntries, label: "Units Sold") let lineData = LineChartData() lineData.addDataSet(lineDataSet) lineChartView.data = lineData }
}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Here is my code.
//
// ChartsViewController.swift
// iOSChartsDemo
//
import UIKit
import Charts
class ChartsViewController: UIViewController {
}
The text was updated successfully, but these errors were encountered: