Advertisement
dhshin

practice_19_javascript

Jun 26th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let students = [
  2.   {"name": "Jane", "score": 80},
  3.   {"name": "John", "score": 90},
  4.   {"name": "Bob", "score": 60}
  5. ];
  6.  
  7. let minScore = 0;
  8. let maxScore = 100;
  9. let barWidth = 50;
  10. let maxHeight = 200;
  11. let margin = 10;
  12.  
  13. let svg = document.getElementById("chart");
  14. let spec = "http://www.w3.org/2000/svg";
  15.  
  16. students.forEach(function(student, i) {
  17.   let rect = document.createElementNS(spec, "rect");
  18.  
  19.   rect.setAttribute("width", 50);
  20.   rect.setAttribute("height", 60);
  21.   rect.setAttribute("x", 30);
  22.   rect.setAttribute("y", 50);
  23.   rect.style.fill = "steelblue";  
  24.  
  25.   svg.appendChild(rect);
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement