Hi,

Have you tried by replacing line:
set.add(yearNames[y]);
by
set.add(y);

This might solve your trouble.
Michiel

On 9 apr, 15:28, C Anthony Lewis <[email protected]> wrote:
> David,
>
> Many thanks for the speedy response.
>
> If I understand correctly, you’re suggesting that a “year” property can be 
> added on the fly from the original property as the data loads. I fear this is 
> a little beyond my current skills so I’m wondering if you can suggest an 
> existing Exhibit that I can look at.
>
> Does this mean that it’s not possible to do it the way I was attempting?
>
> All the best and thanks for any further assistance,
>
> Anthony
>
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of David Karger
> Sent: 08 April 2009 13:44
> To: [email protected]
> Subject: Re: Manipulating dates in Exhibit
>
> 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]<mailto:[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 followed the 
> code 
> athttp://groups.google.com/group/simile-widgets/browse_thread/thread/78...and 
> got a facet (I hope that’s the correct term) working that displays months of 
> the year, so I thought I’d be clever and do the same for 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 maybe 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]<mailto:[email protected]>
> web:http://www.pegg.org.uk<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]<mailto:[email protected]>
> To unsubscribe from this group, send email to 
> [email protected]<mailto:[email protected]>
> For more options, visit this group 
> athttp://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
-~----------~----~----~----~------~----~------~--~---

Reply via email to