couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carl Bourne <>
Subject Summary view for Pie Charting
Date Thu, 20 Sep 2012 00:06:29 GMT

I'm trying to build a summary view for a pie chart based on a document count within date ranges
as shown below. 

The map function is basically working, except I need to get the "emit(XX-Days, 1);" part to
write a variable label in the place of the XX-Days. e.g. 30-Days,60-Days,90-Days. However,
I can't seem to work out a way to do this. 

Any suggestions would be much appreciated.

Map Function:

    var now = new Date((new Date()).getTime());
    var thirty_days_from_now = new Date((new Date()).getTime() + 30*24*60*60*1000);
    var sixty_days_from_now = new Date((new Date()).getTime() + 60*24*60*60*1000);
    var ninty_days_from_now = new Date((new Date()).getTime() + 90*24*60*60*1000);
    var expire = Date.parse(

    var exps = [thirty_days_from_now, sixty_days_from_now, ninty_days_from_now];

for (r in exps){
   if (expire >= now && expire <= (exps[r])){
   emit(XX-Days, 1);

Reduce Function:




View raw message