Javascript examples for Chart.js:Chart Configuration
Using chart.js version 1.0.2 and 2.0 together
<html> <head> <title>line chart with ChartJS</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// www. j a v a 2 s . c o m var Chartv2 = Chart.noConflict(); var data1a = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [ { label: "My First dataset", fillColor: "rgba(120,120,120,0.2)", strokeColor: "rgba(120,120,120,1)", pointColor: "rgba(120,120,120,1)", pointStrokeColor: "#fff", pointHighlightFill: "#fff", pointHighlightStroke: "rgba(120,120,120,1)", data: [65, 0, 80, 81, 56, 85, 40] } ] }; var data1b = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [ { label: "My First dataset", fillColor: "rgba(120,120,120,0.2)", strokeColor: "rgba(120,120,120,1)", pointColor: "rgba(120,120,120,1)", pointStrokeColor: "#fff", pointHighlightFill: "#fff", pointHighlightStroke: "rgba(120,120,120,1)", data: [65, 0, 80, 81, 56, 85, 40] } ] }; var config2a = { type: 'line', data: { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ label: "My First dataset", data: [65, 0, 80, 81, 56, 85, 40], fill: false }] } }; var config2b = { type: 'bar', data: { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ label: "My First dataset", data: [65, 0, 80, 81, 56, 85, 40], fill: false }] } }; var ctx1a = document.getElementById("myChart1A").getContext("2d"); new Chart(ctx1a).Line(data1a); var ctx1b = document.getElementById("myChart1B").getContext("2d"); new Chart(ctx1b).Bar(data1b); var ctx2a = document.getElementById("myChart2A").getContext("2d"); new Chartv2(ctx2a, config2a); var ctx2b = document.getElementById("myChart2B").getContext("2d"); new Chartv2(ctx2b, config2b); } </script> </head> <body> <script src="https://rawgit.com/nnnick/Chart.js/v1.0.2/Chart.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.0.0-beta/Chart.js"></script> <canvas id="myChart1A"></canvas> <canvas id="myChart1B"></canvas> <canvas id="myChart2A"></canvas> <canvas id="myChart2B"></canvas> </body> </html>