集成

Chart.js可以与JavaScript集成或与不同的模块加载器集成。 下面的例子显示了如何在不同的方式中加载Chart.js。

ES6 Modules

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

Script 标签

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

Common JS

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

Require JS

require(['path/to/chartjs/dist/Chart.js'], function(Chart){
    var myChart = new Chart(ctx, {...});
});

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.).

results matching ""

    No results matching ""