|
3 | 3 | <head>
|
4 | 4 | <title>Radar Chart</title>
|
5 | 5 | <script src="../Chart.js"></script>
|
6 |
| - <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
| 6 | + <meta name = "viewport" content = "initial-scale = 1, user-scalable = no"> |
| 7 | + <style> |
| 8 | + canvas{ |
| 9 | + } |
| 10 | + </style> |
7 | 11 | </head>
|
8 | 12 | <body>
|
9 | 13 | <div style="width:30%">
|
10 | 14 | <canvas id="canvas" height="450" width="450"></canvas>
|
11 | 15 | </div>
|
12 |
| - <button id="randomizeData">Randomize Data</button> |
13 | 16 |
|
14 | 17 |
|
15 | 18 | <script>
|
16 |
| - |
17 |
| - var randomScalingFactor = function(){ return Math.round(Math.random()*100)}; |
18 |
| - var randomColorFactor = function(){ return Math.round(Math.random()*255)}; |
19 |
| - |
20 | 19 | var radarChartData = {
|
21 | 20 | labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
|
22 | 21 | datasets: [
|
|
28 | 27 | pointStrokeColor: "#fff",
|
29 | 28 | pointHighlightFill: "#fff",
|
30 | 29 | pointHighlightStroke: "rgba(220,220,220,1)",
|
31 |
| - data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()] |
| 30 | + data: [65,59,90,81,56,55,40] |
32 | 31 | },
|
33 | 32 | {
|
34 | 33 | label: "My Second dataset",
|
|
38 | 37 | pointStrokeColor: "#fff",
|
39 | 38 | pointHighlightFill: "#fff",
|
40 | 39 | pointHighlightStroke: "rgba(151,187,205,1)",
|
41 |
| - data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()] |
| 40 | + data: [28,48,40,19,96,27,100] |
42 | 41 | }
|
43 | 42 | ]
|
44 | 43 | };
|
|
49 | 48 | });
|
50 | 49 | }
|
51 | 50 |
|
52 |
| - $('#randomizeData').click(function(){ |
53 |
| - radarChartData.datasets[0].fillColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.3)'; |
54 |
| - radarChartData.datasets[0].data = [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]; |
55 |
| - |
56 |
| - radarChartData.datasets[1].fillColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.3)'; |
57 |
| - radarChartData.datasets[1].data = [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]; |
58 |
| - |
59 |
| - window.myRadar.update(); |
60 |
| - }); |
61 |
| - |
62 | 51 | </script>
|
63 | 52 | </body>
|
64 | 53 | </html>
|
0 commit comments