D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
rasou2ba
Full window
Github gist
having circles and text show up together-call data twice
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } </style> </head> <body> <script> var svg = d3.select("body").append("svg") .attr("width", 1000) .attr("height", 1000) d3.json("data.json", function(error, json) { d3.select("svg").selectAll("circle") .data(json) .enter() .append("circle") .attr("cy", function (d) {return d.start}) .attr("cx", function(d) {return d.start}) .attr("r", 50) .attr("fill", "red") .style("stroke", "black") .style("stroke-width", 3)}); //call the data again and make a new svg d3.json("data.json", function(error, json) { d3.select("svg").selectAll("text") .data(json) .enter() .append("text") .text(function(d) {return "circle" + " " + d.name}) .attr("y", function (d) {return d.start}) .attr("x", function (d) {return d.stop-40}) .style("font-size", 10) .style("font-family", "monospace"); }) </script> </body>
https://d3js.org/d3.v4.min.js