Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. var dataset = [
  2. [5, 20], [480, 90], [250, 50], [100, 33], [330, 95],
  3. [410, 12], [475, 44], [25, 67], [85, 21], [220, 88]
  4. ];
  5.  
  6. var visualizacion = {
  7. svgWidth: 500,
  8. svgHeight: 100,
  9. circle: "null",
  10. texto: "null",
  11. }
  12.  
  13.  
  14. var svg = d3.select("body").append("svg")
  15. .attr("width", visualizacion.svgWidth)
  16. .attr("height", visualizacion.svgHeight);
  17.  
  18.  
  19.  
  20. visualizacion.circle = svg.selectAll("circle")
  21. .data(dataset).enter()
  22. .append("circle");
  23.  
  24. visualizacion.circle
  25. .attr("cx", function(d)
  26. {return d[0];})
  27. .attr("cy", function(d)
  28. {return d[1];})
  29. .attr("r", function(d) {
  30. return Math.sqrt(visualizacion.svgHeight - d[1]);
  31. })
  32. .attr("fill", "green");
  33.  
  34. visualizacion.texto = svg.selectAll("text")
  35. .data(dataset).enter()
  36. .append("text");
  37.  
  38.  
  39. visualizacion.texto
  40. .text(function(d) {
  41. return d[0] + "," + d[1];
  42. })
  43. .attr("x", function(d) {
  44. return d[0];
  45. })
  46. .attr("y", function(d) {
  47. return d[1];
  48. })
  49. .attr("font-family", "sans-serif")
  50. .attr("font-size", "11px")
  51. .attr("fill", "red");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement