Created
April 1, 2014 09:57
-
-
Save ABrouwer/9911221 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| d3.json('https://astportfoliodata.firebaseio.com/.json', function(data) { | |
| console.log(data); //Log output to console | |
| //Width and height | |
| var w = 500; | |
| var h = 100; | |
| //Create SVG element | |
| var svg = d3.select("body") | |
| .append("svg") | |
| .attr("width", w) | |
| .attr("height", h); | |
| svg.selectAll("circle") | |
| .data(dataset) | |
| .enter() | |
| .append("circle") | |
| .attr("cx", function(data) { | |
| return data[0]; | |
| }) | |
| .attr("cy", function(data) { | |
| return data[1]; | |
| }) | |
| .attr("r", function(data) { | |
| return Math.sqrt(h - data[1]); | |
| }); | |
| //Create labels | |
| svg.selectAll("text") | |
| .data(dataset) | |
| .enter() | |
| .append("text") | |
| .text(function(data) { | |
| return data[0] + "," + data[1]; | |
| }) | |
| .attr("x", function(data) { | |
| return data[0]; | |
| }) | |
| .attr("y", function(data) { | |
| return data[1]; | |
| }) | |
| .attr("font-family", "sans-serif") | |
| .attr("font-size", "11px") | |
| .attr("fill", "red"); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment