Skip to content

Instantly share code, notes, and snippets.

@ESeufert
Created May 2, 2014 09:11
Show Gist options
  • Save ESeufert/c5a2cd425e05974ca6a7 to your computer and use it in GitHub Desktop.
Save ESeufert/c5a2cd425e05974ca6a7 to your computer and use it in GitHub Desktop.
//size the visible area of the graph using the margin values
var width = 500, height = 500;
var margin = {top: 30, right: 10, bottom: 40, left: 60},
width = width - margin.left - margin.right,
height = height - margin.top - margin.bottom;
var minDate = (data[0].date),
maxDate = data[data.length-1].date;
minObjectValue = getMinObjectValue(data, 'DAU');
maxObjectValue = getMaxObjectValue(data, 'DAU');
//create the graph object
var vis= d3.select("#metrics").append("svg")
.data(data)
.attr("class", "metrics-container")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var y = d3.scale.linear()
.domain([ minObjectValue - (.1 * minObjectValue) , maxObjectValue + (.1 * maxObjectValue)])
.range([height, 0]),
x = d3.time.scale()
.domain([minDate, maxDate])
.range([0, width]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment