[Simile-Widgets] Re: Weird Error While Manually Adding Event
Hi Mike, I was using Timeline off simile-widgets.org. (http://simile.mit.edu/ timeline/api/timeline-api.js) I tried the code on the Cubism example. Worked. Back to my code I replaced the Timeline link to the same in the example (http://api.simile-widgets.org/timeline/2.3.1/timeline-api.js) Now it works. Still not sure why but it works! Thanks for your help. On Aug 4, 8:53 pm, Michael Nosal mno...@mitre.org wrote: Hmmm, I just tried it against Timeline 2.3.0, and it works as advertised. What version of Timeline are you using? Are you hosting it locally or off simile-widgets.org? In the JS console in your browser, try creating an event and see what it says. That's all that the Event constructor really needs for an instant event. You can see for yourself if you visit simile-widgets.org and go to one of the example timelines. Paste this code into the console and hit enter and you should see the new event appear on the timeline. function addBreakpoint() { var evt = new Timeline.DefaultEventSource.Event ({ start: new Date(May 03 2003 00:00:00 GMT-0600), instant : true, text : An event, description : A description, }); tl.getBand(0).getEventSource().add(evt); tl.paint();} addBreakpoint(); --Mike On Aug 4, 2011, at 4:54 AM, Froggy wrote: Thanks for pointing that out. I applied your exact recommendation but I still get the same error message. On Aug 3, 10:50 pm, Michael Nosal mno...@mitre.org wrote: The error message suggests that something that should be a Date object, actually isn't (there is no method 'getTime') In your addBreakpoint function, you pass an object to the Timeline.DefaultEventSource.Event constructor. In this object, the value you have for start is a String, when it should be a Date. Normally, calling eventSource.loadJSON() would convert the start/end strings in your JSON to date objects for you before constructing a new Timeline.DefaultEventSource.Event. So you just need to convert start to a Date: function addBreakpoint() { var evt = new Timeline.DefaultEventSource.Event ({ start: new Date(Aug 03 2011 00:00:00 GMT-0600), instant : true, text : An event, description : A description}); This should work fine. --Mike On Aug 3, 2011, at 12:06 PM, Froggy wrote: Hi Everyone, Just started using Timeline and having a problem I just can't find information about. I am trying to add events manually that the user selects and display them dynamically, not sure I got the grasp of everything. I get the following error in Chrome's Developer Tools: Uncaught TypeError: Object #Object has no method 'getTime' bundle.js:4492 Here is the code I have: ... //Add Event function addBreakpoint() { var date = document.getElementById(eventDatepicker).value; var evt = new Timeline.DefaultEventSource.Event ({ start: Aug 03 2011 00:00:00 GMT-0600, //Hardcoded for the time being using Timeline default date instant : true, text : An event, description : A description, }); eventSource.add(evt); tl.paint(); } Thanks in advance for any help you can provide! -- You received this message because you are subscribed to the Google Groups SIMILE Widgets group. To post to this group, send email to simile-widgets@googlegroups.com. To unsubscribe from this group, send email to simile-widgets+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/simile-widgets?hl=en. -- You received this message because you are subscribed to the Google Groups SIMILE Widgets group. To post to this group, send email to simile-widgets@googlegroups.com. To unsubscribe from this group, send email to simile-widgets+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/simile-widgets?hl=en.
Re: [Simile-Widgets] Re: Weird Error While Manually Adding Event
That's because the simile.mit.edu version of Timeline is out of date. The method signature to the Event constructor changed from: Timeline.DefaultEventSource.Event = function( start, end, latestStart, earliestEnd, { to Timeline.DefaultEventSource.Event = function(args) { Using an object this way makes it much easier to use - you don't need to remember the order of arguments, and can leave off unused arguments without having to pass nulls, and you can easily extend it with new arguments without needing to change lots of code. --Mike On Aug 5, 2011, at 4:04 AM, Froggy wrote: Back to my code I replaced the Timeline link to the same in the example (http://api.simile-widgets.org/timeline/2.3.1/timeline-api.js) Now it works. Still not sure why but it works! -- You received this message because you are subscribed to the Google Groups SIMILE Widgets group. To post to this group, send email to simile-widgets@googlegroups.com. To unsubscribe from this group, send email to simile-widgets+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/simile-widgets?hl=en.
[Simile-Widgets] Re: Weird Error While Manually Adding Event
Thanks for pointing that out. I applied your exact recommendation but I still get the same error message. On Aug 3, 10:50 pm, Michael Nosal mno...@mitre.org wrote: The error message suggests that something that should be a Date object, actually isn't (there is no method 'getTime') In your addBreakpoint function, you pass an object to the Timeline.DefaultEventSource.Event constructor. In this object, the value you have for start is a String, when it should be a Date. Normally, calling eventSource.loadJSON() would convert the start/end strings in your JSON to date objects for you before constructing a new Timeline.DefaultEventSource.Event. So you just need to convert start to a Date: function addBreakpoint() { var evt = new Timeline.DefaultEventSource.Event ({ start: new Date(Aug 03 2011 00:00:00 GMT-0600), instant : true, text : An event, description : A description}); This should work fine. --Mike On Aug 3, 2011, at 12:06 PM, Froggy wrote: Hi Everyone, Just started using Timeline and having a problem I just can't find information about. I am trying to add events manually that the user selects and display them dynamically, not sure I got the grasp of everything. I get the following error in Chrome's Developer Tools: Uncaught TypeError: Object #Object has no method 'getTime' bundle.js:4492 Here is the code I have: ... //Add Event function addBreakpoint() { var date = document.getElementById(eventDatepicker).value; var evt = new Timeline.DefaultEventSource.Event ({ start: Aug 03 2011 00:00:00 GMT-0600, //Hardcoded for the time being using Timeline default date instant : true, text : An event, description : A description, }); eventSource.add(evt); tl.paint(); } Thanks in advance for any help you can provide! -- You received this message because you are subscribed to the Google Groups SIMILE Widgets group. To post to this group, send email to simile-widgets@googlegroups.com. To unsubscribe from this group, send email to simile-widgets+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/simile-widgets?hl=en.
Re: [Simile-Widgets] Re: Weird Error While Manually Adding Event
Hmmm, I just tried it against Timeline 2.3.0, and it works as advertised. What version of Timeline are you using? Are you hosting it locally or off simile-widgets.org? In the JS console in your browser, try creating an event and see what it says. That's all that the Event constructor really needs for an instant event. You can see for yourself if you visit simile-widgets.org and go to one of the example timelines. Paste this code into the console and hit enter and you should see the new event appear on the timeline. function addBreakpoint() { var evt = new Timeline.DefaultEventSource.Event ({ start: new Date(May 03 2003 00:00:00 GMT-0600), instant : true, text : An event, description : A description, }); tl.getBand(0).getEventSource().add(evt); tl.paint(); } addBreakpoint(); --Mike On Aug 4, 2011, at 4:54 AM, Froggy wrote: Thanks for pointing that out. I applied your exact recommendation but I still get the same error message. On Aug 3, 10:50 pm, Michael Nosal mno...@mitre.org wrote: The error message suggests that something that should be a Date object, actually isn't (there is no method 'getTime') In your addBreakpoint function, you pass an object to the Timeline.DefaultEventSource.Event constructor. In this object, the value you have for start is a String, when it should be a Date. Normally, calling eventSource.loadJSON() would convert the start/end strings in your JSON to date objects for you before constructing a new Timeline.DefaultEventSource.Event. So you just need to convert start to a Date: function addBreakpoint() { var evt = new Timeline.DefaultEventSource.Event ({ start: new Date(Aug 03 2011 00:00:00 GMT-0600), instant : true, text : An event, description : A description}); This should work fine. --Mike On Aug 3, 2011, at 12:06 PM, Froggy wrote: Hi Everyone, Just started using Timeline and having a problem I just can't find information about. I am trying to add events manually that the user selects and display them dynamically, not sure I got the grasp of everything. I get the following error in Chrome's Developer Tools: Uncaught TypeError: Object #Object has no method 'getTime' bundle.js:4492 Here is the code I have: ... //Add Event function addBreakpoint() { var date = document.getElementById(eventDatepicker).value; var evt = new Timeline.DefaultEventSource.Event ({ start: Aug 03 2011 00:00:00 GMT-0600, //Hardcoded for the time being using Timeline default date instant : true, text : An event, description : A description, }); eventSource.add(evt); tl.paint(); } Thanks in advance for any help you can provide! -- You received this message because you are subscribed to the Google Groups SIMILE Widgets group. To post to this group, send email to simile-widgets@googlegroups.com. To unsubscribe from this group, send email to simile-widgets+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/simile-widgets?hl=en. -- You received this message because you are subscribed to the Google Groups SIMILE Widgets group. To post to this group, send email to simile-widgets@googlegroups.com. To unsubscribe from this group, send email to simile-widgets+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/simile-widgets?hl=en.