D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
patiencehaggin
Full window
Github gist
Class 11 dispatch exercise
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> .axis path, .axis line { stroke: #ccc; } .axis line { stroke-dasharray: 2; } .axis text { fill: #ccc; } .state text { font-weight: 600; } </style> </head> <body> <script> var width = 250; var height = 200; var margin = {top: 20, right: 30, bottom: 20, left: 30}; var xScale = d3.scaleLinear().range([0, width]); var yScale = d3.scaleLinear().range([height, 0]); var xAxis = d3.axisBottom() .scale(xScale) .ticks(5) .tickFormat(d => "'" + new String(d).slice(2)) .tickSizeInner(-height) .tickSizeOuter(0) .tickPadding(6); var yAxis = d3.axisLeft() .scale(yScale) .ticks(5) .tickFormat(d => d + '%') .tickSizeInner(-width) .tickSizeOuter(0) .tickPadding(6); var line = d3.line() .x(d => xScale(d.year)) .y(d => yScale(d.value)); var red = '#d8472b'; d3.json('data.json', function(err, data) { }); </script> </body>
https://d3js.org/d3.v4.min.js