i trying render graph csv file based on date using library d3.
i can display graph whole csv file (using example below) display data dates june instance.
the csv file followed:
date, close 15/06/15,200 15/06/15,250 10/06/15,300 05/06/15,500 25/05/15,200 20/05/15,100 ok parsing dates works , comparing dates matching format now. still, not make sense.
d3.csv("txt.csv", function(error, data) { data2 = data.filter(function(d) { return d.date <= timeformat(parsedate("10/06/15")) }); data2.foreach(function(d) { d.date = timeformat(parsedate(d.date)); d.close = +d.close; }); var timeformat = d3.time.format("%d/%m/%y"); var parsedate = d3.time.format("%d/%m/%y").parse; when console.log(data2); array means finding of lines, problem finds random lines csv not correspond @ <= condition.
p.s.: clarity simplified csv. real condition should pick 2 lines @ end of csv gets hundreds of lines rest of csv (but not of lines!!!!).
any idea what's happening?
there caveat when using d3.time.format(). in javascript, when new date(yyyy, mm, dd) created, numbers of months can 0 11. 0 based. in d3.time.format(), months not 0 based (going 1 12).
interpreting should 15/06/15 2015-06-14t23:00:00.000z...
that bit weird though. d3 format (like defined it) returns me 15/07/15 when following:
var somedate = new date(2015,06,15); var var timeformat = d3.time.format("%d/%m/%y"); console.log(timeformat(somedate)); so expect get. not printing 2015-06-15t00:00:00 or that...
and there 1 more thing dates in javascript. can read more here. however, bit of age , not explain why d3.time.format interpret totally different. perhaps post entire code? did notice error? or how did notice?
Comments
Post a Comment