Skip to content

Instantly share code, notes, and snippets.

@mrahtz
Last active August 29, 2015 14:20
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 mrahtz/9138dbf18cc18eadeefb to your computer and use it in GitHub Desktop.
Save mrahtz/9138dbf18cc18eadeefb to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.axis path,
.axis line {
fill: none;
stroke-width: 1px;
stroke: black;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var margin = {top: 80, right: 80, bottom: 80, left: 80},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var parse = d3.time.format("%b %Y").parse;
var xScale = d3.scale.linear().range([0, width]),
yScale = d3.scale.linear().range([height, 0]),
xAxis = d3.svg.axis().scale(xScale).ticks(0),
yAxis = d3.svg.axis().scale(yScale).ticks(0);
// Add an SVG element with the desired dimensions and margin.
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
// Add the x-axis.
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
// Add the y-axis.
svg.append("g")
.attr("class", "y axis")
.attr("transform", "translate(" + width + ",0)")
.call(yAxis);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment