Codepedia
.info
Home
About
Demos
Tools
SVG Wave Generator
Colors
Edit This Code :
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script> </head> <body> <button id="btnPieChart">Create Pie Chart</button> <br> <div id=”wrapper”> <canvas id="myChart" width="200" height="200"></canvas> </div> <script> $(document).ready(function(){ $("#btnPieChart").on('click',function(e){ e.preventDefault(); var data = [{ value: 300, color: "#F7464A", highlight: "#FF5A5E", label: "Red" }, { value: 50, color: "#46BFBD", highlight: "#5AD3D1", label: "Green" }, { value: 100, color: "#FDB45C", highlight: "#FFC870", label: "Yellow" }]; // Get context with jQuery - using jQuery's .get() method. var ctx = $("#myChart").get(0).getContext("2d"); // This will get the first returned node in the jQuery collection. var myPieChart = new Chart(ctx).Pie(data); }); }); </script> </body> </html>
➤ Run / View
Result :