Chartjs-Draw chart.js created by ckeditor plugin

0๐Ÿ‘

โœ…

I just add these lines to head and solve my problem:

<link rel="stylesheet" href="ckeditor/plugins/chart/lib/chart.css">
<script src="ckeditor/plugins/chart/chart.min.js"></script>
<script src="ckeditor/plugins/chart/widget2chart.js"></script>

1๐Ÿ‘

You can use canvas for your chart container

<canvas id="chartjs" width='300' height='300'></canvas>

And then run this javascript, passing your parameters as follows:

var ctx = document.getElementById("chartjs");

var myChart = new Chart(ctx, {
    type: 'doughnut',
    data: {
        labels: ["A", "B"],
        datasets: [{
            data: [70, 50],
            backgroundColor: ['red', 'pink']
        }]
    },
});

See working example here

Leave a comment