Skip to content

Instantly share code, notes, and snippets.

@jhaubrich
Created August 2, 2012 15:38
Show Gist options
  • Save jhaubrich/3238011 to your computer and use it in GitHub Desktop.
Save jhaubrich/3238011 to your computer and use it in GitHub Desktop.
Thinking Without Joins
<html>
<head>
<title>not a line chart</title>
</head>
<body>
<script src="http://d3js.org/d3.v2.js"></script>
<script>
var data =
[
{
"key":"brw-a",
"values":[
["2012-07-11T00:00:00", 0.0 ],
["2012-07-11T23:59:59", 0.0 ],
["2012-07-05T06:31:47", 0.0 ],
["2012-07-05T23:59:59", 0.0 ]
]
},
{
"key":"brw-c",
"values":[
["2012-07-11T00:00:00", 1.0 ],
["2012-07-07T00:00:00", 2.0 ],
["2012-07-05T23:59:59", 4.0 ]
]
}
]
var body = d3.select("body")
for (i=0; i < data.length; i++) {
var key = data[i].key
var values = data[i].values
body.append("h3")
.text(key)
for (j=0; j < values.length; j++) {
body.append("p")
.text(values[j][0] + " -- " + values[j][1])
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment