Re: Date Facet?

12 views
Skip to first unread message

David Huynh

unread,
Apr 18, 2008, 1:51:47 PM4/18/08
to da...@substance.coop, simile-...@googlegroups.com
First, add this code after you include exhibit-api.js

<script>
var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
Exhibit.Functions["month"] = {
f: function(args) {
var set = new Exhibit.Set();

args[0].forEachValue(function(v) {
var d = SimileAjax.DateTime.parseIso8601DateTime(v);
var m = d.getMonth();
set.add(monthNames[m]);
});

return new Exhibit.Expression._Collection(set, "text");
}
};
</script>

Then for the month facet, use this expression

ex:expression="month(.dateTime)"

Hope that helps!

Cheers,

David

David Carpenter wrote:
> Hello
>
> Discovered Exhibit the other day and I'm just sooo excited. This is
> great!
>
> I've got some data over at:
> http://www.nornir.co.uk/lamrt/data/lamrt.html
>
> and I'm very pleased with this!
>
> I have the date and time of incidents in what I think is the correct
> format, and I was wondering if there's a simple way to then just set up
> a 'month' facet.
>
> So we have mountain rescue incidents that have taken place over the year
> and I want to be able to filter them by month via a facet. I was just
> thinking that as we have the date info in there, there must be some way
> of pulling out just the month from this, but can I find out how? Nope!
>
> If you could help, that would be ace.
>
> All the best
> (apologies if I've sent this to the wrong place - I have tried searching
> for an answer, but couldn't find anything relevant.)
>
> David
>
>
>
>

Reply all
Reply to author
Forward
0 new messages