D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
biovisualize
Full window
Github gist
Parse dates with quarters (i.e., "Q4-2010")
<html> <head> <script src="https://d3js.org/d3.v3.min.js"></script> </head> <body> <script> var dates = ["Q4-2010", "Q1-2011", "Q2-2011", "Q3-2011", "Q4-2011", "Q1-2012", "Q2-2012", "Q3-2012","Q4-2012"]; var dateParsed = dates.map(function(d, i){ var splitted = d.split('-'); var quarterEndMonth = splitted[0].charAt(1) * 3; var quarterStartMonth = quarterEndMonth - 3; return [d3.time.format('%m %Y').parse(quarterStartMonth + ' ' + splitted[1]), d3.time.format('%m %Y').parse(quarterEndMonth + ' ' + splitted[1])]; }); console.log(JSON.stringify(dateParsed)); </script> </body> </html>
Modified
http://d3js.org/d3.v3.min.js
to a secure url
https://d3js.org/d3.v3.min.js