Cezar Popescu
Cezar Popescu

Reputation: 1

Dygraph - Data not parsing

I'm using last dygraphs library with basic html provided in the example. As csv i've uploaded a custom one with data in format DD/MM/YYYY HH:MM:SS The graphs scales correctly but no plots are displayed. Also Chrome reports lots of

dygraphs: Couldn't parse 22/05/2014 21:00:45 as a date (dygraph-combined.js:2:8358)

Example available here http://atelierelealbe.eu/temp/datatemp.htm Any ideea of what am i doing wrong?

Upvotes: 0

Views: 2428

Answers (2)

ichi
ichi

Reputation: 181

I solved this problem by changing errorBars option to false (or you may delete errorBars option because default value of this variable is false).

Upvotes: 1

ezanker
ezanker

Reputation: 24738

I believe the automatic date parsing does not recognize that format for dates.

If you have control of the CSV, change the date format to yyyy/mm/dd

If not, use the xValueParser option and some javascript to parse the date.

See this documentation: http://dygraphs.com/data.html

If you decide to go with the parser, moment.js is a great library for date manipulation: http://momentjs.com/

    xValueFormatter: Dygraph.dateString_,
    xValueParser: function(x) { 
        var m = moment(x, "DD-MM-YYYY HH:mm:ss");
        return m.toDate().getTime();
    },
    xTicker: Dygraph.dateTicker

Working DEMO

Upvotes: 2

Related Questions