Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Radar Chart</title>
  5. <script src="../Chart.js"></script>
  6. <meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
  7. <style>
  8. canvas{
  9. }
  10. </style>
  11. </head>
  12. <body>
  13. <div style="width:30%;">
  14. <canvas id="canvas" height="300" width="300"></canvas>
  15. <div>
  16. <input id="eating" onblur="update()" type="text"></input>
  17. <input id="drinking" onblur="update()" type="text"></input>
  18. <input id="sleeping" onblur="update()" type="text"></input>
  19. <input id="designing" onblur="update()" type="text"></input>
  20. <input id="coding" onblur="update()" type="text"></input>
  21. <input id="cycling" onblur="update()" type="text"></input>
  22. </div>
  23. </div>
  24. <script>
  25. var radarChartData = {
  26. labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling"],
  27. datasets: [
  28. {
  29. label: "My First dataset",
  30. fillColor: "rgba(220,220,220,0.2)",
  31. strokeColor: "rgba(220,220,220,1)",
  32. pointColor: "rgba(220,220,220,1)",
  33. pointStrokeColor: "#fff",
  34. pointHighlightFill: "#fff",
  35. pointHighlightStroke: "rgba(220,220,220,1)",
  36. data: [0,0,0,0,0,0]
  37. }
  38. ]
  39. };
  40.  
  41. window.onload = function(){
  42. window.myRadar = new Chart(document.getElementById("canvas").getContext("2d")).Radar(radarChartData, {
  43. responsive: true
  44. });
  45. }
  46.  
  47. function update() {
  48. console.log(window.myRadar);
  49. window.myRadar.datasets[0].points[0].value = document.getElementById('eating').value;
  50. window.myRadar.datasets[0].points[1].value = document.getElementById('drinking').value;
  51. window.myRadar.datasets[0].points[2].value = document.getElementById('sleeping').value;
  52. window.myRadar.datasets[0].points[3].value = document.getElementById('designing').value;
  53. window.myRadar.datasets[0].points[4].value = document.getElementById('coding').value;
  54. window.myRadar.datasets[0].points[5].value = document.getElementById('cycling').value;
  55. window.myRadar.update();
  56. }
  57.  
  58. </script>
  59. </body>
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement