"How to Use Chart.js"
Bootstrap 4.1.1 Snippet by mdwaris198

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!--https://tobiasahlin.com/blog/chartjs-charts-to-get-you-started/#3-pie-chart--> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script> <br> <br> <div class="container"> <div class="row"> <div class="col-md-6"> <canvas id="bar-chart" width="800" height="450"></canvas> </div> <div class="col-md-6"> <canvas id="pie-chart" width="800" height="450"></canvas> </div> </div> </div> <script> // Bar chart new Chart(document.getElementById("bar-chart"), { type: 'bar', data: { labels: ["Africa", "Asia", "Europe", "Latin America", "North America"], datasets: [ { label: "Population (millions)", backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"], data: [2478,5267,734,784,433] } ] }, options: { legend: { display: false }, title: { display: true, text: 'Predicted world population (millions) in 2050' } } }); new Chart(document.getElementById("pie-chart"), { type: 'pie', data: { labels: ["Africa", "Asia", "Europe", "Latin America", "North America"], datasets: [{ label: "Population (millions)", backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"], data: [2478,5267,734,784,433] }] }, options: { title: { display: true, text: 'Predicted world population (millions) in 2050' } } }); </script>

Related: See More


Questions / Comments: