Creating Interactive Charts in AngularJS

Data in the form of rows and columns is boring, and it’s difficult to derive insights from it in that form. Add interactive charts to it, and you make it easier for everybody to make sense of it. You start seeing patterns that were impossible to spot by looking at raw data alone. But how do you add interactive charts to your website?

Well, that’s what this tutorial will teach you. In this post I will walk you through the process of creating interactive charts in one of the most popular JavaScript frameworks – AngularJS. We will be implementing charts via FusionCharts’ JavaScript charts package. And to make our job easier, we will make use of its AngularJS charts plugin.

AngularJS makes it quite easy to create modern web apps (after the initial learning curve, of course!). And FusionCharts’ AngularJS charts plugin will let us create interactive charts with just a single directive.

With the introduction out of the way, let’s get started with the tutorial! You can also check the demo first.

View Demo

I have divided this tutorial into 4 steps:

  1. Set the dependencies
  2. Inject ng-fusioncharts module
  3. Define controller for the app
  4. Render the FusionCharts view

Step 1: Set the Dependencies

These are the three JavaScript files that we need to include:

Here’s how your HTML will look like after this step:




Step 2: Inject ng-fusioncharts Module

Next step is to include ng-fusioncharts as a dependency in our app. Below is the code to achieve that:

var app = angular.module('DemoApp', ['ng-fusioncharts']);

Step 3: Define Controller for the App

In the controller for the app, we augment the controller scope with Fusioncharts’ chart definition:

app.controller('DemoController', function($scope) {
    //chart definition
    $scope.dataSource =  '{"chart":
            "caption":"Sales - 2014 v 2015",
            "baseFont":"Helvetica Neue,Arial",
            {"seriesname":"Bakersfield Central",
            {"seriesname":"Los Angeles Topanga",

Step 4: Render the FusionCharts View

Now add the following markup to your HTML to render FusionCharts:

If you have followed above steps properly and not messed up anywhere, you should see a working chart like this:

About the Guest author:

Rohit Boggarapu
Rohit Boggarapu is currently a software engineer at Adobe. He loves developing cool things and writing for the web. When not writing code, you will find him either practicing Yoga, or talking about it. He is always up for a quick chat on Twitter.

8 thoughts to “Creating Interactive Charts in AngularJS”

  1. Very nice post here thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information’s.

Leave a Reply

Your email address will not be published.