-
Notifications
You must be signed in to change notification settings - Fork 8
Getting started
Before creating your first iOS application with AnyChart library make sure that Cocoapods is installed on your computer.
Create a new Xcode project.
|
Choose "Single View App".
|
Fill product name, organization name, and organization identifier.
|
When you click Next, you'll be prompted for a location to save it. Also, you could enable "Create a Git repository".
Close all Xcode projects. Go to the project location in the terminal. Create a POD file in your project by executing the command:
pod init
Open the Podfile
in the project folder and type in pod 'AnyChartiOS', '~> 1.0.3'
in target section just like it is shown at the screenshot below to include the AnyChartiOS framework version 1.0.3. For using the latest version you can paste the name of the POD without specifying a certain version pod 'AnyChartiOS'
.
|
To install the AnyChartiOS
POD execute the following command (the first installation may take some time):
pod install
Now open the .xcworkspace
file from the project directory in Xcode.
|
Go to the "Main.storyboard" and set "AnyChartView" in custom class for your View.
|
Now click on the "Assistant editor" (two intersected circles at the top) and connect your AnyChartView to the ViewController. To do that, press and hold down the CTRL key while you drag your AnyChartView to the ViewController. Name it as "anyChartView".
|
Go to the ViewController and make sure you have import "AnyChartiOS" at the top of your ViewController.
|
Add code in the "viewDidLoad" method. For example, if you want to create a simple pie chart:
let chart = AnyChart.pie()
let data: Array<DataEntry> = [
ValueDataEntry(x: "Apples", value: 6371664),
ValueDataEntry(x: "Pears", value: 789622),
ValueDataEntry(x: "Bananas", value: 7216301),
ValueDataEntry(x: "Grapes", value: 1486621),
ValueDataEntry(x: "Oranges", value: 1200000)
]
chart.data(data: data)
chart.title(settings: "Fruits imported in 2015 (in kg)")
anyChartView.setChart(chart: chart)
|
Run your project.
|