an alternative approach would be to use exhibit's callback-on-data- load to explicitly add a "year" property to every item. Then you could use a plain year facet.
Sent from my iPhone On Apr 8, 2009, at 8:39 AM, C Anthony Lewis <[email protected]> wrote: > Hello, > > > > As ever, thanks for a great set of tools and helpful list. > > > > I’m (again) having difficulty manipulating dates in Exhibit. I follo > wed the code at > http://groups.google.com/group/simile-widgets/browse_thread/thread/78063be86c4d2ca4 > > and got a facet (I hope that’s the correct term) working that displ > ays months of the year, so I thought I’d be clever and do the same f > or years… of course I don’t really know what I’m doing so it > didn’t work! > > > > To extract the year from a date I used: > > var yearNames = [ "2007", "2008", "2009", "2010", "2011" ]; > Exhibit.Functions["year"] = { > f: function(args) { > var set = new Exhibit.Set(); > > args[0].forEachValue(function(v) { > var d = > SimileAjax.DateTime.parseIso8601DateTime(v); > var y = d.getFullYear(); > set.add(yearNames[y]); > }); > > return new Exhibit.Expression._Collection(set, > "number"); > } > }; > > > and then had the following: > > <div ex:role="facet" ex:expression="year(.startdate)" > ex:fixedOrder="2007;2008;2009;2010;2011" ex:facetLabel="Year"></div> > > > But to no avail… all I’m getting is “undefined” for all the > items in my Exhibit. > > > > I’m wondering if this is totally the wrong way to go about it as may > be I would need to have an infinite list of years for this to work? > > > > Thanks for any assistance, > > > > Anthony > > > > > > C. Anthony Lewis > > Petroleum & Environmental Geochemistry Group, > > School of Earth, Ocean and Environmental Sciences, > > University of Plymouth, > > Plymouth, Devon PL4 8AA, U.K. > > > > tel: +44 (0)1752 584554 > > email: [email protected] > > web: http://www.pegg.org.uk > > http://www.plymouth.ac.uk/chemistry > > > > > > > ecause you are subscribed to the Google Groups "SIMILE Widgets" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/simile-widgets?hl=en > -~----------~----~----~----~------~----~------~--~--- > > ml> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SIMILE Widgets" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/simile-widgets?hl=en -~----------~----~----~----~------~----~------~--~---
