]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Add in new chart samples
authorNick Downie <hello@nickdownie.com>
Sun, 29 Jun 2014 17:36:04 +0000 (18:36 +0100)
committerNick Downie <hello@nickdownie.com>
Sun, 29 Jun 2014 17:36:04 +0000 (18:36 +0100)
samples/bar.html
samples/doughnut.html
samples/line.html
samples/pie.html
samples/polar-area.html [new file with mode: 0644]
samples/radar.html

index bf150db8f572e7180ff36efb1b7ddfd9561b5330..5bf4b5bae3661b26f403b9a50503f995075a4761 100644 (file)
@@ -3,37 +3,43 @@
        <head>
                <title>Bar Chart</title>
                <script src="../Chart.js"></script>
-               <meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
-               <style>
-                       canvas{
-                       }
-               </style>
        </head>
        <body>
-               <canvas id="canvas" height="450" width="600"></canvas>
+               <div style="width: 50%">
+                       <canvas id="canvas" height="450" width="600"></canvas>
+               </div>
 
 
        <script>
+       var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
+
+       var barChartData = {
+               labels : ["January","February","March","April","May","June","July"],
+               datasets : [
+                       {
+                               fillColor : "rgba(220,220,220,0.5)",
+                               strokeColor : "rgba(220,220,220,0.8)",
+                               highlightFill: "rgba(220,220,220,0.75)",
+                               highlightStroke: "rgba(220,220,220,1)",
+                               data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
+                       },
+                       {
+                               fillColor : "rgba(151,187,205,0.5)",
+                               strokeColor : "rgba(151,187,205,0.8)",
+                               highlightFill : "rgba(151,187,205,0.75)",
+                               highlightStroke : "rgba(151,187,205,1)",
+                               data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
+                       }
+               ]
 
-               var barChartData = {
-                       labels : ["January","February","March","April","May","June","July"],
-                       datasets : [
-                               {
-                                       fillColor : "rgba(220,220,220,0.5)",
-                                       strokeColor : "rgba(220,220,220,1)",
-                                       data : [65,59,90,81,56,55,40]
-                               },
-                               {
-                                       fillColor : "rgba(151,187,205,0.5)",
-                                       strokeColor : "rgba(151,187,205,1)",
-                                       data : [28,48,40,19,96,27,100]
-                               }
-                       ]
-                       
-               }
+       }
+       window.onload = function(){
+               var ctx = document.getElementById("canvas").getContext("2d");
+               window.myBar = new Chart(ctx).Bar(barChartData, {
+                       responsive : true
+               });
+       }
 
-       var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Bar(barChartData);
-       
        </script>
        </body>
 </html>
index 83f4c9e7c229841b29597195f5fa70d2aafc68c1..fdf7539a893801e6aacc39bd8fe7e5bc06cb3258 100644 (file)
@@ -3,44 +3,65 @@
        <head>
                <title>Doughnut Chart</title>
                <script src="../Chart.js"></script>
-               <meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
                <style>
-                       canvas{
+                       body{
+                               padding: 0;
+                               margin: 0;
+                       }
+                       #canvas-holder{
+                               width:30%;
                        }
                </style>
        </head>
        <body>
-               <canvas id="canvas" height="450" width="450"></canvas>
+               <div id="canvas-holder">
+                       <canvas id="chart-area" width="500" height="500"/>
+               </div>
 
 
        <script>
 
                var doughnutData = [
                                {
-                                       value: 30,
-                                       color:"#F7464A"
+                                       value: 300,
+                                       color:"#F7464A",
+                                       highlight: "#FF5A5E",
+                                       label: "Red"
                                },
                                {
-                                       value : 50,
-                                       color : "#46BFBD"
+                                       value: 50,
+                                       color: "#46BFBD",
+                                       highlight: "#5AD3D1",
+                                       label: "Green"
                                },
                                {
-                                       value : 100,
-                                       color : "#FDB45C"
+                                       value: 100,
+                                       color: "#FDB45C",
+                                       highlight: "#FFC870",
+                                       label: "Yellow"
                                },
                                {
-                                       value : 40,
-                                       color : "#949FB1"
+                                       value: 40,
+                                       color: "#949FB1",
+                                       highlight: "#A8B3C5",
+                                       label: "Grey"
                                },
                                {
-                                       value : 120,
-                                       color : "#4D5360"
+                                       value: 120,
+                                       color: "#4D5360",
+                                       highlight: "#616774",
+                                       label: "Dark Grey"
                                }
-                       
+
                        ];
 
-       var myDoughnut = new Chart(document.getElementById("canvas").getContext("2d")).Doughnut(doughnutData);
-       
+                       window.onload = function(){
+                               var ctx = document.getElementById("chart-area").getContext("2d");
+                               window.myDoughnut = new Chart(ctx).Doughnut(doughnutData, {responsive : true});
+                       };
+
+
+
        </script>
        </body>
 </html>
index 4c6734452ceab0a2628119928cffbfa1aaa17062..ccd0dad9653bef4b0a35cc222b7bd18274900381 100644 (file)
@@ -3,41 +3,52 @@
        <head>
                <title>Line Chart</title>
                <script src="../Chart.js"></script>
-               <meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
-               <style>
-                       canvas{
-                       }
-               </style>
        </head>
        <body>
-               <canvas id="canvas" height="450" width="600"></canvas>
+               <div style="width:30%">
+                       <div>
+                               <canvas id="canvas" height="450" width="600"></canvas>
+                       </div>
+               </div>
 
 
        <script>
-
+               var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
                var lineChartData = {
                        labels : ["January","February","March","April","May","June","July"],
                        datasets : [
                                {
-                                       fillColor : "rgba(220,220,220,0.5)",
+                                       label: "My First dataset",
+                                       fillColor : "rgba(220,220,220,0.2)",
                                        strokeColor : "rgba(220,220,220,1)",
                                        pointColor : "rgba(220,220,220,1)",
                                        pointStrokeColor : "#fff",
-                                       data : [65,59,90,81,56,55,40]
+                                       pointHighlightFill : "#fff",
+                                       pointHighlightStroke : "rgba(220,220,220,1)",
+                                       data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
                                },
                                {
-                                       fillColor : "rgba(151,187,205,0.5)",
+                                       label: "My Second dataset",
+                                       fillColor : "rgba(151,187,205,0.2)",
                                        strokeColor : "rgba(151,187,205,1)",
                                        pointColor : "rgba(151,187,205,1)",
                                        pointStrokeColor : "#fff",
-                                       data : [28,48,40,19,96,27,100]
+                                       pointHighlightFill : "#fff",
+                                       pointHighlightStroke : "rgba(151,187,205,1)",
+                                       data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
                                }
                        ]
-                       
+
                }
 
-       var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Line(lineChartData);
-       
+       window.onload = function(){
+               var ctx = document.getElementById("canvas").getContext("2d");
+               window.myLine = new Chart(ctx).Line(lineChartData, {
+                       responsive: true
+               });
+       }
+
+
        </script>
        </body>
 </html>
index e3bbbaed3f7e19572f6b34fffc5cba7f4c10139f..255a499761889567d7dcaeec0aee987f86a95355 100644 (file)
@@ -1,38 +1,58 @@
 <!doctype html>
 <html>
        <head>
-               <title>Radar Chart</title>
+               <title>Pie Chart</title>
                <script src="../Chart.js"></script>
-               <meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
-               <style>
-                       canvas{
-                       }
-               </style>
        </head>
        <body>
-               <canvas id="canvas" height="450" width="450"></canvas>
+               <div id="canvas-holder">
+                       <canvas id="chart-area" width="300" height="300"/>
+               </div>
 
 
        <script>
 
                var pieData = [
                                {
-                                       value: 30,
-                                       color:"#F38630"
+                                       value: 300,
+                                       color:"#F7464A",
+                                       highlight: "#FF5A5E",
+                                       label: "Red"
                                },
                                {
-                                       value : 50,
-                                       color : "#E0E4CC"
+                                       value: 50,
+                                       color: "#46BFBD",
+                                       highlight: "#5AD3D1",
+                                       label: "Green"
                                },
                                {
-                                       value : 100,
-                                       color : "#69D2E7"
+                                       value: 100,
+                                       color: "#FDB45C",
+                                       highlight: "#FFC870",
+                                       label: "Yellow"
+                               },
+                               {
+                                       value: 40,
+                                       color: "#949FB1",
+                                       highlight: "#A8B3C5",
+                                       label: "Grey"
+                               },
+                               {
+                                       value: 120,
+                                       color: "#4D5360",
+                                       highlight: "#616774",
+                                       label: "Dark Grey"
                                }
-                       
+
                        ];
 
-       var myPie = new Chart(document.getElementById("canvas").getContext("2d")).Pie(pieData);
-       
+                       window.onload = function(){
+                               var ctx = document.getElementById("chart-area").getContext("2d");
+                               window.myPie = new Chart(ctx).Pie(pieData);
+                       };
+
+
+
        </script>
        </body>
 </html>
diff --git a/samples/polar-area.html b/samples/polar-area.html
new file mode 100644 (file)
index 0000000..d3d3f01
--- /dev/null
@@ -0,0 +1,60 @@
+<!doctype html>
+<html>
+       <head>
+               <title>Polar Area Chart</title>
+               <script src="../Chart.js"></script>
+       </head>
+       <body>
+               <div id="canvas-holder" style="width:30%">
+                       <canvas id="chart-area" width="300" height="300"/>
+               </div>
+
+
+       <script>
+
+               var polarData = [
+                               {
+                                       value: 300,
+                                       color:"#F7464A",
+                                       highlight: "#FF5A5E",
+                                       label: "Red"
+                               },
+                               {
+                                       value: 50,
+                                       color: "#46BFBD",
+                                       highlight: "#5AD3D1",
+                                       label: "Green"
+                               },
+                               {
+                                       value: 100,
+                                       color: "#FDB45C",
+                                       highlight: "#FFC870",
+                                       label: "Yellow"
+                               },
+                               {
+                                       value: 40,
+                                       color: "#949FB1",
+                                       highlight: "#A8B3C5",
+                                       label: "Grey"
+                               },
+                               {
+                                       value: 120,
+                                       color: "#4D5360",
+                                       highlight: "#616774",
+                                       label: "Dark Grey"
+                               }
+
+                       ];
+
+                       window.onload = function(){
+                               var ctx = document.getElementById("chart-area").getContext("2d");
+                               window.myPolarArea = new Chart(ctx).PolarArea(polarData, {
+                                       responsive:true
+                               });
+                       };
+
+
+
+       </script>
+       </body>
+</html>
index 0ffdad91ce9ceab4d41423adef7754350349edfc..6a04f879c09089bd325f8f138f347d73471f7ed5 100644 (file)
                </style>
        </head>
        <body>
-               <canvas id="canvas" height="450" width="450"></canvas>
+               <div style="width:30%">
+                       <canvas id="canvas" height="450" width="450"></canvas>
+               </div>
 
 
        <script>
+       var radarChartData = {
+               labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
+               datasets: [
+                       {
+                               label: "My First dataset",
+                               fillColor: "rgba(220,220,220,0.2)",
+                               strokeColor: "rgba(220,220,220,1)",
+                               pointColor: "rgba(220,220,220,1)",
+                               pointStrokeColor: "#fff",
+                               pointHighlightFill: "#fff",
+                               pointHighlightStroke: "rgba(220,220,220,1)",
+                               data: [65,59,90,81,56,55,40]
+                       },
+                       {
+                               label: "My Second dataset",
+                               fillColor: "rgba(151,187,205,0.2)",
+                               strokeColor: "rgba(151,187,205,1)",
+                               pointColor: "rgba(151,187,205,1)",
+                               pointStrokeColor: "#fff",
+                               pointHighlightFill: "#fff",
+                               pointHighlightStroke: "rgba(151,187,205,1)",
+                               data: [28,48,40,19,96,27,100]
+                       }
+               ]
+       };
 
-               var radarChartData = {
-                       labels : ["Eating","Drinking","Sleeping","Designing","Coding","Partying","Running"],
-                       datasets : [
-                               {
-                                       fillColor : "rgba(220,220,220,0.5)",
-                                       strokeColor : "rgba(220,220,220,1)",
-                                       pointColor : "rgba(220,220,220,1)",
-                                       pointStrokeColor : "#fff",
-                                       data : [65,59,90,81,56,55,40]
-                               },
-                               {
-                                       fillColor : "rgba(151,187,205,0.5)",
-                                       strokeColor : "rgba(151,187,205,1)",
-                                       pointColor : "rgba(151,187,205,1)",
-                                       pointStrokeColor : "#fff",
-                                       data : [28,48,40,19,96,27,100]
-                               }
-                       ]
-                       
-               }
+       window.onload = function(){
+               window.myRadar = new Chart(document.getElementById("canvas").getContext("2d")).Radar(radarChartData, {
+                       responsive: true
+               });
+       }
 
-       var myRadar = new Chart(document.getElementById("canvas").getContext("2d")).Radar(radarChartData,{scaleShowLabels : false, pointLabelFontSize : 10});
-       
        </script>
        </body>
 </html>