timeglider / jquery_widget

Timeglider's JS Widget component. See README for details.
193 stars 41 forks source link

Finding timespan visible in browser. #10

Closed rdpalmer closed 12 years ago

rdpalmer commented 13 years ago

I'd like to be able to retrieve the time span visible in the browser widget to use as a filter for another facet; but there doesn't seem to be any method to retrieve this information?. I'll trying hacking something into the code unless someone can tell me the right way to do it!.

timeglider commented 13 years ago

There's no method for getting this yet, but clearly it's needed. What format would you want it in? What I've used before (in the Flash implementation) is getting the "starts" date/time and the "ends" date/time so that your return object would look like this {"starts":"2011-04-01 12:00:00", "ends":"2013-02-04 12:00:00"}

Thoughts? Meanwhile, I'll see if I can find the likely vein for this stuff in the code.

rdpalmer commented 13 years ago

That would be perfect. Just been reading through the code and found the ticks/time calculations buried deep in TimelineView, not sure how to pass that up through the widget API though.

rumit91 commented 12 years ago

I would also love to see this functionality. I need to combine a map with a timeline in a format that's similar to http://timemap.googlecode.com/svn/tags/2.0/examples/basic_googlev3.html. I would like to be able to dictate what appears on the map based on what appears on the timeline.

jeremyboggs commented 12 years ago

Just another vote in favor of adding this. I think a 'starts' and 'ends' time would be really helpful. Also would be nice if those values could be updated by specific user events (e.g. zooming in or out, changing width of the browser for a fluid-width timeline, etc.) I would imagine querying data based on the date range visible, and updating the query if a users scrolled the timeline or zoomed in/out.

timeglider commented 12 years ago

There's now a (pub-sub, using the $.publish method) published event that comes out of the Mediator:

$.publish("mediator.scopeChange");

You can also use a new method called getScope (called on the .data() instance of the widget) to get this object, perhaps when you subscribe to the scopeChange event, or at any other time. It returns this object:

{ "spp":seconds per pixel "width":container width "focusDateSec":(TG_Date) seconds-date of the focus/center of timeline "timelines":an array of active timelines "timelineBounds":{"first":earliest event in active timelines, "last":latest event in active timelines} "container": jQuery object of the whole container }

We're going to add to this object an array of the visible (in-scope) events.

Please note: "seconds" in the Timeglider context are not Unix-era seconds (i.e. since 1970), but are "common era seconds" — since Year 1. So you may need to adjust current dates by adding the baseline seconds at 1970 to the returned numbers above.