Created
May 23, 2012 00:43
-
-
Save lgrammel/2772585 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
How will I select tag 2013 and stateuts from below:
Andhra Pradesh Assault on women with intent to outrage her Modest <2013>6930 Arunachal Pradesh Assault on women with intent to outrage her Modest <2013>93 Assam Assault on women with intent to outrage her Modest <2013>2409