添加带日期的注释时,Dygraph解析错误

时间:2014-04-15 15:15:26

标签: javascript dygraphs

我试图在折线图上显示注释。注释确实显示在页面加载上,但如果我放大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);
             });

对此有何想法?这看起来像个错误吗?

1 个答案:

答案 0 :(得分:0)

你应该设置" x"注释的值,而不是Date对象。请参阅http://dygraphs.com/annotations.html