Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

79 lines (67 sloc) 2.954 kB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.time.js"></script>
<link type="text/css" rel="stylesheet" href="prettify.css">
<script type="text/javascript" src="prettify.js"></script>
<link type="text/css" rel="stylesheet" href="style.css">
<title></title>
</head>
<body onload="prettyPrint()">
<div style="height:300px; width:750px; margin-left:auto; margin-right:auto; margin-top:1em" id="chart">
</div>
<pre style="font-size:0.7em" class="prettyprint">
xAxis = d3.svg.axis().scale(time_scale)
yAxis = d3.svg.axis().scale(value_scale).orient("left")
svg.append("svg:g")
.attr("class", "xaxis")
.attr("transform","translate(0,280)")
.call(xAxis)
svg.append("svg:g")
.attr("class", "yaxis")
.attr("transform", "translate(30,0)")
.call(yAxis)
</pre>
</div>
<script>
d3.json(
'http://localhost:8000/data/meetup_history.json',
function(data){
time_scale = d3.time.scale()
.domain([
new Date(d3.min(data, function(d){return d.time})),
new Date(d3.max(data, function(d){return d.time}))
])
.range([30,730])
value_scale = d3.scale.linear()
.domain([0, d3.max(data, function(d){return d.yes_rsvp_count})])
.range([280, 20])
xAxis = d3.svg.axis().scale(time_scale)
yAxis = d3.svg.axis().scale(value_scale).orient("left")
svg = d3.select("#chart")
.append("svg");
svg.selectAll("circle")
.data(data)
.enter()
.append("circle")
.attr("class","brill")
.attr("cx", function(d){return time_scale( new Date(d.time) )})
.attr("cy", function(d){return value_scale(d.yes_rsvp_count);})
.attr("r", 6)
.style("fill","red")
.style("fill-opacity", 0.8)
.style("stroke", "black");
svg.append("svg:g")
.attr("class", "xaxis")
.attr("transform","translate(0,280)")
.call(xAxis)
svg.append("svg:g")
.attr("class", "yaxis")
.attr("transform", "translate(30,0)")
.call(yAxis)
}
)
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.