ChartJS to create doughnut chart - Javascript Chart.js

Javascript examples for Chart.js:Doughnut Chart

Description

ChartJS to create doughnut chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>ChartJS Line Chart</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.js"></script> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){//  w  w w.j  a va2s.  c om
$(function() {
    drawChart();
});
function drawChart() {
    var ctx = document.getElementById("currenciesTag").getContext("2d");
    console.log(ctx);
    new Chart(ctx, {
        type: 'doughnut',
        data: {
            labels: ['Label1', 'Label2'],
            datasets: [{
                backgroundColor: ['#000000', '#000000'],
                borderColor: 'rgb(255, 99, 132)',
                data: [1, 2],
            }]
        },
        options: {}
    });
}
    }

      </script> 
   </head> 
   <body>  
      <canvas id="currenciesTag" width="600" height="400"></canvas>   
   </body>
</html>

Related Tutorials