D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
timelyportfolio
Full window
Github gist
forked from Mike Bostock to begin d3 replacement for PerformanceSummary
<!DOCTYPE html> <meta charset="utf-8"> <style> body { font: 10px sans-serif; } .axis path { display: none; } .axis line { shape-rendering: crispEdges; stroke: #000; } .axis .minor line { stroke: #777; stroke-dasharray: 2,2; } </style> <body> <script src="https://d3js.org/d3.v3.min.js"></script> <script> var margin = {top: 20, right: 0, bottom: 20, left: 0}, width = 960 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; var formatNumber = d3.format(".1f"); var y = d3.scale.linear() .domain([0, 2e6]) .range([height, 0]); var x = d3.time.scale() .domain([new Date(2010, 7, 1), new Date(2012, 7, 1)]) .range([0, width]); var xAxis = d3.svg.axis() .scale(x) .ticks(d3.time.years) .orient("bottom"); var yAxis = d3.svg.axis() .scale(y) .tickSize(width) .tickFormat(formatCurrency) .orient("right"); 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); var gy = svg.append("g") .attr("class", "y axis") .call(yAxis); gy.selectAll("g").filter(function(d) { return d; }) .classed("minor", true); gy.selectAll("text") .attr("x", 4) .attr("dy", -4); function formatCurrency(d) { var s = formatNumber(d / 1e6); return d === y.domain()[1] ? "$" + s + " million" : s; } </script>
Modified
http://d3js.org/d3.v3.min.js
to a secure url
https://d3js.org/d3.v3.min.js