javascript - How to arrange dates in a drop-down list according their natural way using D3.js -


i have dataset dates in it. dates arranged randomly (march — febryary — january):

var uniquedates = ["2016-03-01", "2016-01-01", "2016-02-01"]; 

i need put these dates drop-down list according natural way (january — febryary — march). i'm using code below:

d3.select("select#dateselector")   .selectall("option")   .data(uniquedates)   .enter()   .append("option")   .text(function(d) {     return formatru(new date(d));   })   .attr("value", function(d) {     return d;   })   .property("selected", function(d) {     return == uniquedates.length - 1;   }); 

how can right sequence in drop-down list this:

<select id="dateselector">   <option value="2016-01-01">Январь 2016</option>   <option value="2016-02-01">Февраль 2016</option>   <option value="2016-03-01">Март 2016</option> </select> 

sort string representations of dates converting them date object:

uniquedates.sort(function(a, b){     return d3.ascending(new date(a), new date(b)); }); 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -