Create Stunning Charts In Your iOS Apps

creating interactive charts in ios

It’s 2018, and the world’s now certifiably mobile-first.

Around 56% of us access the internet on smartphones. Last we checked, iTunes had over 2 million apps. And interestingly, after gaming, the most popular category is business – an area ripe for data analyses and insightful visualizations.

Whether you’re targeting individuals or organizations, whether you’re making a weather app, a stock market monitoring tool, or a powerful tool for monitoring on-floor performance, chances are you could use a chart. To stand out in the crowd, you need apps that aren’t just useful, but also beautiful – (and brownie points, if it does both expertly).

And if you’re not sold on the power of visualization in iOS, take a look at this incredible responsive visualization of all the data in Wikipedia.

FusionCharts makes interactive charting easy, customizable, and exciting – with these steps, you can build visuals that’ll fit seamlessly into your next iOS app. This tutorial showcases how you can create interactive charts for iOS applications using FusionCharts.


Before we start the step-by-step procedure to create interactive charts in iPhone or iPad apps, make sure that you have the following components downloaded in the local machine:

  • FusionCharts XT [Download Link]
  • Xcode [Download Link]
  • Step 1: Create a Project in XCode

    Once you have Xcode installed on your system, open it and create a new xcode project with ‘Single View App’ template.

    Step 2: Create a HTML File to Show the Chart

    Navigate to project navigator sidebar in Xcode project, and create an empty html file as chart.html.

    In the HTML file, include chart instance which will render the chart in our app inside WKWebView which we will learn to create later. First, we will include the core packages in our HTML file and then create chart instance.

    Include the FusionCharts Core Package JS Files
    Given below is the code to include the FusionCharts core package JS files (fusioncharts.js and fusioncharts.charts.js) in the HTML code:

    Note: Please copy the files downloaded to project folder. Make sure that path specified in chart.html for FusionCharts core package JS files is accessible to the application. Also include these files in Build Phases -> Copy Bundle Resources.

    Create chart instance
    Chart instance include parameters like chart type, dimensions, chart container ID, data format and data source for the chart which is used to render the chart. Given below is the code for creating the chart instance:

    Given below is the complete HTML code of  chart.html:

    Step 3: Import WebKit and Create WKWebView

    Now that you have the chart instance ready, let’s move on to view the application and create webview which will render the HTML file.

    To use WebKit import it by running the following command at the top of ViewController.swift:
    import WebKit

    While creating the web view, store it as a property for later reference. Add the property of web view to ViewController class. Refer to the following command:
    var webView: WKWebView!

    Now, we will add loadView( ) before viewDidLoad(). Refer to the following command:

    Include override keyword for loadView() to load the layout from the storyboard.

    To load the chart in webView, insert the code given below to refer the HTML file ( chart.html) created in the viewDidLoad() method:

    Given below is the complete code for webView( ):

    Step 4: Build Project and Render the Chart (Simulator)

    The final chart looks like as shown in the image below:

    If you have a developer mode apple device, you can also check out output on your device. You can download the source code from GitHub repo.

    • Joel Sene April 23, 2018, 8:39 pm

      Awesome tutorial and library. I`ve been using it for a school project where I have to show a Bar Chart and a Spreadsheet like report, where it explains the data shown in the Chart.
      But I`ve been having some trouble to show the webView inside a containerView and not as the whole view.

      Could you help me with that?

      • Jonathan May 7, 2018, 1:06 pm

        Definitely Joel. Please drop an email to [email protected] mentioning the issue you are facing. We’ll try our best to make it work for you.


    Leave a Comment