I have imported the ChartsDemo swift file library which is given by danielGindi in github to my objective c file.Now i want to check the charts by providing input values.Am new to chart Concepts.Thanks in Advance!!!
Asked
Active
Viewed 886 times
-1
-
1At least provide the link to the library, and some sample code you've tried. – zc246 Dec 24 '15 at 13:18
2 Answers
1
You could follow some tutorials about iOS chart library. For example this one: http://www.appcoda.com/ios-charts-api-tutorial/
In few word you should: 1. Associate your view with chart class; 2. Create an outlet; 3. Prepare data; 4. Assigned data with data property.
Example code with random data below:
class ViewController: UIViewController, ChartViewDelegate {
@IBOutlet weak var chartView: LineChartView!
override func viewDidLoad() {
super.viewDidLoad()
//set x values
let count = 10
var xVals: [String]! = []
for (var i = 0; i < count; i++)
{
xVals.append("\(i)")
}
//set y values
let range = 5.0
var yVals: [ChartDataEntry] = []
for (var i = 0; i < count; i++)
{
let val = drand48() * range + 35
yVals.append(ChartDataEntry(value: val, xIndex: i))
}
let set1 = LineChartDataSet(yVals: yVals, label: "DataSet 1"
// set Data
var dataSets: [LineChartDataSet] = []
dataSets.append(set1)
let chartData = LineChartData(xVals: xVals, dataSets: dataSets)
chartView.data = chartData
}
}

Anton Vlasov
- 1,372
- 1
- 10
- 18
0
I assume this is the library you are referring to (https://github.com/danielgindi/ios-charts). In the folder for the project the author has given a sample project which shows how to use Swift file in the Objective-c file for this library, you can check that out.Tell if more information is required. Cheers.

LearneriOS
- 309
- 6
- 18
-
Thanks...but I want to know how to provide input for chart....after importing chart and I run means just it shows white screen....I I'll upvote if u provide explanation.... – RAGHUNATH Dec 24 '15 at 19:16
-
This is t link: https://github.com/danielgindi/ios-charts .how to give the input and how it works...anybody tell me overall idea...am a newbie to charts... – RAGHUNATH Dec 25 '15 at 06:11