D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
mbostock
Full window
Github gist
Subsecond Ticks
Fixing a
bug with tick identity
in the axis component.
<!DOCTYPE html> <meta charset="utf-8"> <style> .axis text { font: 10px sans-serif; } .axis .title { font-weight: bold; text-anchor: end; } .axis path, .axis line { fill: none; stroke: #000; shape-rendering: crispEdges; } .x.axis path { display: none; } .line { fill: none; stroke: steelblue; stroke-width: 1.5px; } </style> <body> <script src="//d3js.org/d3.v3.min.js"></script> <script> var margin = {top: 20.5, right: 30, bottom: 30, left: 40.5}, width = 960 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; var x = d3.time.scale() .range([0, width]); var y = d3.scale.linear() .range([height, 0]); var xAxis = d3.svg.axis() .scale(x) .orient("bottom"); var yAxis = d3.svg.axis() .scale(y) .orient("left"); var line = d3.svg.line() .x(function(d) { return x(d.time); }) .y(function(d) { return y(d.value); }); 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 + ")"); d3.tsv("data.tsv", type, function(error, data) { x.domain(d3.extent(data, function(d) { return d.time; })); y.domain(d3.extent(data, function(d) { return d.value; })); svg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis); svg.append("g") .attr("class", "y axis") .call(yAxis) .append("text") .attr("class", "title") .attr("transform", "rotate(-90)") .attr("y", 6) .attr("dy", ".71em") .text("Value"); svg.append("path") .datum(data) .attr("class", "line") .attr("d", line); }); function type(d) { d.time = new Date(+d.time * 1000); d.value = +d.value; return d; } </script>
https://d3js.org/d3.v3.min.js