Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Burgerlijke staat</title>
  4. <meta charset="utf-8">
  5. <link rel="stylesheet" href="css/style.css">
  6. </head>
  7.  
  8. <body>
  9. <h1>Burgerlijke staat in 1950 en 2010</h1>
  10. <h2>De verhoudingen onder Nederlandse inwoners</h2>
  11.  
  12. <button class="button1" id="button1">1950</button>
  13. <button class="button2" id="button2">2010</button>
  14. <button id="button3">Toon alles</button>
  15.  
  16. <ul></ul>
  17.  
  18. <script src="lib/d3.min.js"></script>
  19. <script src="lib/jquery.js"></script>
  20.  
  21. <script>
  22. d3.csv('Data_bevolking.csv', function(d) {
  23. for (var i = 0; i < d.length; i = i + 1) {
  24. var aantal = d[i].aantal;
  25. var jaartal = d[i].Jaartal;
  26. var staat = d[i].staat
  27. var cls = d[i].cls;
  28. var text = '<div id ="' + cls + '" name ="' + cls + '" class="'+ cls + '" style="width:0;">' + aantal + " - " + staat + '</div>';
  29.  
  30. $("ul").append(text);
  31.  
  32. $("button").click(function() {
  33. $("div").each(function(i, el) {
  34. var aantal = d[i].aantal;
  35. var width = (aantal / 6500) + 'px';
  36. var id = d[i].id;
  37. var cls = d[i].cls;
  38. var testval = id % 2;
  39. $(el).animate({'width' : width}, 1000);
  40. })
  41. });
  42.  
  43. data1 = d3.selectAll(".tien");
  44. data2 = d3.selectAll(".vijftig");
  45.  
  46. $("#button1").click(function() {
  47. data1.style({'display' : 'none'});
  48. data2.style({'display' : 'block'});
  49. });
  50.  
  51. $("#button2").click(function() {
  52. data1.style({'display' : 'block'});
  53. data2.style({'display' : 'none'});
  54. });
  55.  
  56. $("#button3").click(function() {
  57. data1.style({'display' : 'block'});
  58. data2.style({'display' : 'block'});
  59. });
  60. }});
  61.  
  62. </script>
  63. </body>
  64. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement