Skip to content

Instantly share code, notes, and snippets.

@curran
Last active November 22, 2016 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curran/62329a53e3becf3cbe329d9070ecf590 to your computer and use it in GitHub Desktop.
Save curran/62329a53e3becf3cbe329d9070ecf590 to your computer and use it in GitHub Desktop.
Spans Example
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
.entry {
font-size: 4em;
line-height: 120px;
margin-top: 30px;
margin-left: 20px;
}
.entry-name {
font-weight: bold;
}
.entry-value {
font-style: italic;
}
</style>
</head>
<body>
<script>
var data = [
{ name: "Isaac Newton", value: "Scientist"},
{ name: "Leonardo DiCaprio", value: "Actor"},
{ name: "Leonardo DaVinci", value: "Awesomeness"},
];
var entry = d3.select("body")
.selectAll("div")
.data(data)
.enter().append("div")
.attr("class", "entry");
entry.append("span")
.attr("class", "entry-name")
.text(function (d){ return d.name; });
entry.append("span")
.text(" : ");
entry.append("span")
.attr("class", "entry-value")
.text(function (d){ return d.value; });
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment