2014-04-15 33 views
0

我試圖讓註釋顯示在一個線圖上。註釋在頁面加載時顯示,但如果我放大Dygraph或調整頁面大小,Dygraph不會重新繪製註釋。奇怪的是,所有註釋似乎都在初始加載時正確繪製。Dygraph解析錯誤時添加註釋日期

這裏是確切的錯誤:

[Error] TypeError: 'undefined' is not a function (evaluating 'a.search("-")') 
    dateParser (dygraph-combined.js, line 2) 
    setAnnotations (dygraph-combined.js, line 2) 
    setAnnotations (dygraph-combined.js, line 2) 
    (anonymous function) (viewsreport.aspx, line 408) 
    ready (dygraph-combined.js, line 2) 
    drawChart (viewsreport.aspx, line 407) 

我的註釋對象是這樣的:

[ 
Object 
series: "Sim. Views" 
shortText: "8 viewers:" 
text: "5 Lessons Learned from the Hybrid Research Project," 
x: Thu Sep 05 2013 17:18:00 GMT-0400 (EDT) 
__proto__: Object 
, 
Object 
series: "Sim. Views" 
shortText: "6 viewers:" 
text: "Abstract Algebra and Group Theory,204 Lit: Audiovisual Theory & Demonstration,203 Fine Arts: The Art of Video in the modern age,Introduction To IRIS MkII,Chem 103.1_002,100 Chem: Introduction to Chemistry Lab Management," 
x: Thu Sep 26 2013 10:01:00 GMT-0400 (EDT) 
__proto__: Object 
, 
Object 
series: "Sim. Views" 
shortText: "6 viewers:" 
text: "EDS 100,Engagement 2012,203 Fine Arts: The Art of Video in the modern age,Introduction To IRIS MkII,Chem 103.1_002,100 Chem: Introduction to Chemistry Lab Management," 
x: Thu Sep 26 2013 10:05:00 GMT-0400 (EDT) 
__proto__: Object 
, 
Object 
series: "Sim. Views" 
shortText: "6 viewers:" 
text: "FOR6005 _7/27/2012,EDS 100,Engagement 2012,203 Fine Arts: The Art of Video in the modern age,Chem 103.1_002,100 Chem: Introduction to Chemistry Lab Management," 
x: Thu Sep 26 2013 10:07:00 GMT-0400 (EDT) 
__proto__: Object 
, 
Object 
series: "Sim. Views" 
shortText: "5 viewers:" 
text: "Choose Your Own Adventure: Using Lecture Capture and Social Media to Customize Learning Experiences,101 Fine Arts: Wildlife in HD,Abstract Algebra and Group Theory,100 Chem: Introduction to Chemistry Lab Management,A Practical Response to Massive Open Online Courses - MOOCs," 
x: Wed Dec 11 2013 23:07:00 GMT-0500 (EST) 
__proto__: Object 
, 
Object 
series: "Sim. Views" 
shortText: "7 viewers:" 
text: "Molekülbau,Geh'n wir Eine rauchen?,Vorlesung 12. Quellencodieren und Entropie,Kommandosprachen,Eine Ausnahme - Film und Diskussion,Eichprinzip und Feynmanregeln,Eichprinzip und Feynmanregeln," 
x: Wed Dec 18 2013 11:51:00 GMT-0500 (EST) 
__proto__: Object 
, 
Object 
series: "Sim. Views" 
shortText: "5 viewers:" 
text: "100 Chem: Introduction to Chemistry Lab Management,pre-roll,Molekülbau,Kommandosprachen,Eine Ausnahme - Film und Diskussion," 
x: Wed Dec 18 2013 12:17:00 GMT-0500 (EST) 
__proto__: Object 
, 
Object 
series: "Sim. Views" 
shortText: "6 viewers:" 
text: "Chem 103.1_002,101 Chem: Let’s Drink to That: Chemistry Behind the Magic,Introduction To IRIS MkII,402 Chem: Chemistry for Medical Simulation,302 Chem: Chemistry and Biology - How they relate,100 Chem: Introduction to Chemistry Lab Management," 
x: Thu Jan 23 2014 14:01:00 GMT-0500 (EST) 
__proto__: Object 

我Dygraph是這樣的初始化:

var chart = new Dygraph(document.getElementById(timeLineDiv), data, {displayAnnotations: true}); 
      chart.ready(function() { 
       chart.setAnnotations(annotations); 
      }); 

對此有何想法?這看起來像一個錯誤?

回答

0

您應該將註釋的「x」值設置爲字符串,而不是Date對象。見http://dygraphs.com/annotations.html

+0

是的,這似乎工作。只做了一個toString(),它解決了這個問題,並且大部分都是正確的(註釋字母不能正確顯示,但這是另一個問題......)。 – omniron