-
-
Save MatthewBarker/7757b2691f191b2b381353d90a677b20 to your computer and use it in GitHub Desktop.
D3.xml Example
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>D3.xml Example</title> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script> | |
<style type="text/css"> | |
.chart div { | |
font: 10px sans-serif; | |
background-color: steelblue; | |
text-align: right; | |
padding: 3px; | |
margin: 1px; | |
color: white; | |
} | |
</style | |
</head> | |
<body> | |
<div id="chart" class="chart"> | |
</div> | |
<script> | |
d3.xml("values.xml", "application/xml", function(xml) { | |
d3.select("#chart") | |
.selectAll("div") | |
.data(xml.documentElement.getElementsByTagName("value")) | |
.enter().append("div") | |
.style("width", function(d) { return d.textContent * 10 + "px"; }) | |
.text(function(d) { return d.textContent; }); | |
}); | |
</script> | |
</body> | |
</html> |
This file contains 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
<?xml version="1.0" encoding="UTF-8" ?> | |
<data> | |
<value>71</value> | |
<value>12</value> | |
<value>44</value> | |
<value>88</value> | |
</data> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment