Creating an Analytical Dashboard Using React and GraphQL

Analytical dashboards are reporting tools that help organizations study historical data to understand trends and foresee outcomes. Analytical dashboards are created using advanced features, like drill-down, given that they plot a large amount of data. The advanced features are also needed because users may want to filter the data for the simplest as well as the most complicated queries.

There are a number of options for analytics tools available, which can be easily plugged in to get data directly from your website or app. However, nothing understands your data and the results you are looking for better than you. Most analytical tools are also known to not meet all of their users’ requirements.

What does one do then? How about creating your own analytics dashboard that perfectly fits all your requirements?

The FusionCharts team has created an analytical dashboard that lets you study the number of users who accessed GitHub in each month of 2017. It also lets you see the number of users filtered according to programming languages. This post will introduce you to this dashboard and its technical implementation so that you can create one of your own.

The GitHub Users Dashboard

The dashboard gives a monthly distribution of the number of users to have accessed GitHub. You can use the radio buttons given below the chart to see the number of users every month according to the programming language.

This dashboard is created using the FusionCharts Suite XT charting library, React, and GraphQL.

FusionCharts Suite XT

FusionCharts Suite XT is a JavaScript-based charting library made up of 90+ standard, advanced, as well as domain-specific charts and 1000+ maps for all continents, major countries, and all US states. The GitHub Users dashboard is created using a simple column 2D chart from FusionCharts Suite XT. Click here to know more about the charts and features that are a part of this library.


React is the framework of choice when you want to build websites and applications that are rich in UI.

FusionCharts Suite XT comes with a React-FusionCharts component that lets you add interactive JavaScript charts, widgets, and maps to your web and mobile-based applications using only a single React component.
Click here to read more about rendering charts using the React-FusionCharts component.


A query language, GraphQL is used to query the API and get just the required results. An advantage of using GraphQL to query your data is the predictability of the results—the user gets just what they are looking for, not a thing more, not a thing less. GraphQL works with your code and data, without a backing from a specific storage engine or even a database.

GraphQL also scores well in terms of speed and stability. GraphQL-based applications control the data they retrieve, which makes them faster and more stable than applications that don’t use GraphQL.

In the GitHub Users dashboard, data for the number of users to access GitHub is obtained using the GitHub API. GraphQL is used to query the data retrieved from the GitHub API and filter it according to the results needed.

Technical Implementation of the GitHub Users Dashboard

We’ll now take a look at how this dashboard was created.

Step 1: Setting up the Environment
Before we begin developing the GitHub Users dashboard, follow the steps given below to set up the development environment:

Step 1.1
To install React CLI on your system, open the cmd shell and execute the command given below:
npm install -g react-cli react

Step 1.2
To install the create-react-app modules for React globally, execute the command given below on the command line:
npm install -g create-react-app

Step 1.3.1
From the cmd shell, navigate to the directory where you want to save your project.

Step 1.3.2
To create the project skeleton, execute the following command on the command line:
create-react-app my-app

Step 1.4
To install FusionCharts on your system, execute the command given below:
npm install fusioncharts --save

Step 1.5
To install the React-FusionCharts plugin, execute the command given below:
npm install react-fusioncharts --save

Step 2: Importing the library files and passing them as dependencies

To import the FusionCharts library files, add the following code in your app.js file:

To pass these files as dependencies, use the code snippet given below:

Step 3: Building data using the Fetch API

To define a method that will fetch the data from GitHub using the GraphQL query language, use the code snippet given below:

Click here to read more about the JavaScript Fetch API.

Step 4: Creating the chart’s data source

Now that we have our data, we need to restructure it according to the format prescribed by FusionCharts.

To create the chart’s data source, we will define a method that will return the complete data source for rendering the chart using the code given below:

Step 5: Creating the React component

To split the UI into independent, reusable pieces and render our chart, we will call the component function inside the react class using the code given below:

Next, to load the chart data from the methods defined above, we will call the componentDidMount() method from the component life cycle using the code given below:

Click here to know more about the componentDidMount() method:

Finally, to render the chart, we will create the chart container inside the render() method using the <div> element as shown in the code below:

Step 6: Creating the radio buttons

We’ll now create the radio buttons that will be used to filter the data and view the number of all users as well as the number of users according to the programming language.

To create the radio buttons, use the code snippet given below:

The above code will render simple radio buttons. You can customize the radio buttons’ cosmetics according to your requirements using an external CSS file.

Step 7: Configuring the radio buttons

In this step, we will configure the functionality of the radio buttons (created in the above step) by defining a function that will fetch the chart data for individual as well as all programming languages using GraphQL and render the chart in the browser using React.

To do this, we will use the code snippet given below:

And that’s it! We’re done with creating the dashboard.

Step 8: Deploying the project

To deploy the GitHub Users dashboard, all you have to do is go the React CLI and type npm start.

Doing this will start the server. If everything has been done as explained in the steps above, then this is how your dashboard will render. You can try the live example here.


If you see any errors in your code, you can download the complete source code for the GitHub Users dashboard from here.

Please note that you need to install the dependencies using npm install.

Leave a Comment