Skip to content

Instantly share code, notes, and snippets.

@A6Brgeuka
Created January 11, 2017 11:55
Show Gist options
  • Save A6Brgeuka/3eb30370fbebc7fd8f15c070612c60f4 to your computer and use it in GitHub Desktop.
Save A6Brgeuka/3eb30370fbebc7fd8f15c070612c60f4 to your computer and use it in GitHub Desktop.
fresh block
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
var test = d3.time.format.multi([
["%B %d", function(d) { console.log(7); return true}],
]);
var margin = {top: 250, right: 40, bottom: 250, left: 40},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var x = d3.time.scale()
.domain([new Date(2012, 8, 1), new Date(2013, 0, 1)])
.range([0, width]);
var xAxis = d3.svg.axis()
.scale(x)
.ticks(d3.time.days, 14)
.tickFormat(test);
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 + ")");
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment