Integration

Chart.js can be integrated with plain JavaScript or with different module loaders. The examples below show how to load Chart.js in different systems.

ES6 Modules

  1. import Chart from 'chart.js';
  2. var myChart = new Chart(ctx, {...});

Script Tag

  1. <script src="path/to/chartjs/dist/Chart.js"></script>
  2. <script>
  3. var myChart = new Chart(ctx, {...});
  4. </script>

Common JS

  1. var Chart = require('chart.js');
  2. var myChart = new Chart(ctx, {...});

Require JS

  1. require(['path/to/chartjs/dist/Chart.js'], function(Chart){
  2. var myChart = new Chart(ctx, {...});
  3. });
Important: RequireJS can not load CommonJS module as is, so be sure to require one of the built UMD files instead (i.e. dist/Chart.js, dist/Chart.min.js, etc.).