javascript - D3 having problems sorting a data set -


i read in following data set id reversed 2014 first

year,a,b,c,d,e 2017,.496488,.084909,1.354420,.133384,.405901 2016,.908474,.129965,2.371645,.184770,.708384 2015,.806038,.079820,2.129474,.184854,.681016 2014,.913967,.130637,2.113391,.152658,.749717

var datafile = ".\\temp\\yeardata.csv"; d3.csv(datafile, type, function(error, data) {   if (error) throw error;  //data.sort(function(a, b) { return  b.year; }); //data.sort(function(a, b){ return d3.ascending(a[0], b[0]); }) 

i tried using these 2 lines sort year no luck ideas doing wrong? //data.sort(function(a, b) { return b.year; }); //data.sort(function(a, b){ return d3.ascending(a[0], b[0]); })

to more specific these don't cause errors graph doesn't change looks this:

enter image description here

you on right track, need pass years d3.ascending. try using like:

data.sort(function(a, b){ return d3.ascending(a.year, b.year); }) 

Comments

Popular posts from this blog

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

asp.net - Problems sending emails from forum -