🎉 New! Integrate Beams with Chatkit for powerful push notifications—find out more

Extensible API for in-app chat


Build scalable realtime features


Programmatic push notifications



Read the docs to learn how to use our products


Explore our tutorials to build apps with Pusher products


Reach out to our support team for help and advice

Sign in
Sign up

Build a simple data visualization dashboard with Vue.js and Chart.js

  • Ethiel Adiassa

December 10th, 2018
You will need Node 8.9+ and the Vue CLI installed on your machine.


You all know that data has become an important app of every single app, and even of our lives. Right?! It’s not interesting to have data and not be able to visualize them in a proper way. That’s why in this tutorial we focus on building a simple but useful data visualization app using Vue.js and Chart.js


Here is the final result of our app: Nice isn’t it ?! 😁


In order to follow this tutorial, knowledge of JavaScript and Node.js is required. You should also have the following installed on your machine:

Create the project

In this tutorial, we’ll use the new Vue CLI to scaffold our project. It is such a great tool that enhances the developer productivity. Head over to your terminal and type this command to create your project: vue create your-project-name. Feel free to name your project as you want 🙃 . You will be prompted to pick a preset. You can either choose the default preset which comes with a basic Babel + ESLint setup, or select "Manually select features" to pick the features you need. For the sake of the tutorial, we’ll choose the default preset as it best fits our needs.

At the end of the process, you should be left with a fresh project. But it’s not all, we also have to install some dependencies required to make our app work well. So run this command in your terminal to download them:

yarn add vue-chartjs chart.js


npm install vue-chartjs chart.js --save

Build the app

Now create a Chart.js file and paste this code inside:

    import {
    } from 'vue-chartjs'

    export default {
        extends: Line,
        mixins: [mixins.reactiveProp],
        props: ['chartData', 'options'],
        data() {
            return {
                options: { //Chart.js options
                    scales: {
                        yAxes: [{
                            ticks: {
                                beginAtZero: true
                            gridLines: {
                                display: true
                        xAxes: [{
                            gridLines: {
                                display: false
                    legend: {
                        display: true
                    responsive: true,
                    maintainAspectRatio: false
        mounted() {
            this.renderChart(this.chartdata, this.options)


Let’s have a look at what’s happening here. In the code block above, we imported the Line Chart from vue-chartjs and the mixins module. Chart.js basically does not provide an option for an automatic update whenever a dataset changes but that can be done in vue-chartjs with the help of the following mixins:

  1. reactiveProp
  2. reactiveData

These mixins automatically create chartData as a prop or data and add a watcher. If data has changed, the chart will update. You can find more here.

Also, the this.renderChart() function inside the mounted hook function is responsible for rendering the chart. this.chartData is an object containing the dataset needed for the chart and we’ll get that by including it as a prop in the Visualisation.vue component we’ll create soon, this.options contains the options object that determines the appearance and configuration of the chart. Now create the Visualisation.vue file and paste this code inside:


              <chart :chart-data="datacollection"></chart>
    import Chart from "./../Chart.js";
    export default {
      components: {
      data() {
        return {
          datacollection: null
      mounted() {
      methods: {
        fillData() {
          this.datacollection = {
            labels: [
            datasets: [
                label: "GitHub Commits",
                backgroundColor: "#f87979",
                data: [70, 20, 12, 39, 100, 40, 95, 80, 80, 20, 12, 101]
                label: "Monthly incomes",
                backgroundColor: "#A5CC82",
                data: [205, 408, 188, 190, 58, 200, 190, 400, 164, 254, 290, 201]

In this component, we import our Chart.js file; the chart-data property of our chart component permits us to provide it with some data to render in the form of a chart.The datacollection object is populated with some mock data within the fillData method, and as soon as the component is mounted we execute it. It’s that simple 🙃 .

Now import your Visualisation.vue component inside the ../src/App.vue file and change the msg property to the following: Simple data visualisation with Vue.js and Chart.js or whatever you want, and comment the img line. After these changes your App.vue should look like the following:

      <div id="app">
        <!-- <img alt="Vue logo" src="./assets/logo.png"> -->
        <HelloWorld msg="Simple data visualisation with Vue.js and Chart.js"/>
    /* eslint-disable */
    import Visualisation from './components/Visualisation.vue';
    import HelloWorld from './components/HelloWorld.vue'

    export default {
      name: 'app',
      components: {

    #app {
      font-family: 'Avenir', Helvetica, Arial, sans-serif;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
      text-align: center;
      color: #2c3e50;
      margin-top: 60px;

Run the app

Now, you can run your app with the following command: yarn run serve or npm run serve

If you open your browser at the following location: localhost:8080 you’ll get a nice working data visualization app like mine:


I hope this tutorial has been useful to you and you’ll make use the knowledge you’ve acquired in an awesome app of yours. Feel free to grab the source code of the app here.

Clone the project repository
  • Data Visualization
  • JavaScript
  • Vue.js
  • no pusher tech


  • Channels
  • Chatkit
  • Beams

© 2020 Pusher Ltd. All rights reserved.

Pusher Limited is a company registered in England and Wales (No. 07489873) whose registered office is at 160 Old Street, London, EC1V 9BW.