incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabor Ratky <rg...@rgabostyle.com>
Subject Re: how to sum values of a view in a date range?
Date Fri, 10 Jun 2011 07:14:31 GMT
We built charts on top of our aggregate / reduced views using Highcharts [1] and using a _list
that rendered the keys and values as a series of two-element arrays [['2011-03-01', 476.23],
['2011-03-02', 425.12], ...]. We drive the whole thing with Kanso [2] and pull the data down
asynchronously from the client-side and pluck it into Highcharts with almost no changes. It
has worked for us extremely well, Highcharts is extremely customizable and has a well designed
API whereas Kanso is ever-improving, continuously maintained and well thought out.

Gabor

[1] http://www.highcharts.com
[2] http://kansojs.org

On Thursday, June 9, 2011 at 7:25 PM, Ryan Ramage wrote:

> As a side note, pairing the _stats function with jstat
> [http://www.jstat.org/] is a nice and easy way to graph min, max,
> average and std.
> 
> Here is an example:
> http://pastebin.com/3yU3Ncy8
> 
> On Thu, Jun 9, 2011 at 11:12 AM, Robert Newson <robert.newson@gmail.com (mailto:robert.newson@gmail.com)>
wrote:
> > Average isn't going to be possible without introducing compound
> > rounding errors (which, in my opinion, render the results useless).
> > 
> > The suggestion to use _stats sounded right to me. That will give you
> > both the count of items and the sum of those items, perform the final
> > (single) division in the client to avoid compound rounding errors.
> > 
> > B.
> > 
> > On 9 June 2011 18:04, Sean Copenhaver <sean.copenhaver@gmail.com (mailto:sean.copenhaver@gmail.com)>
wrote:
> > > Yowza, I missed a lot in this thread. Yeah I thought you needed sum, but I
> > > provided a lot of examples of querying with some test data on your
> > > stackoverflow question. I hope that helps. It would actually be nice to see
> > > a built in _avg reduce function though.
> > > 
> > > 
> > > On Thu, Jun 9, 2011 at 12:39 PM, Robert Newson <robert.newson@gmail.com
(mailto:robert.newson@gmail.com)>wrote:
> > > 
> > > > One minor point, your documents won't sort correctly (and therefore
> > > > your sums will be wrong). A string of this form "[2011, 6, 7, 10, 55]"
> > > > will not sort the same as the array you intended [2011, 6, 7, 10, 55].
> > > > 
> > > > B.
> > > > 
> > > > On 9 June 2011 17:36, Fabio Di Bernardini <fdb@altraqua.com (mailto:fdb@altraqua.com)>
wrote:
> > > > > I need to make a chart with hourly sum of values restricted to March.
So
> > > > I
> > > > > don't need one number with the sum of whole March month.
> > > > > 
> > > > > 
> > > > > 2011/6/9 David Hardtke <david@cloudant.com (mailto:david@cloudant.com)>
> > > > > 
> > > > > > Hi Fabio,
> > > > > > 
> > > > > > This should work. You can use the _sum builtin as reduce:
> > > > > > 
> > > > > > "reduce":"_sum"
> > > > > > 
> > > > > > You then need to query your view with the proper group level
and a
> > > > startkey
> > > > > > and endkey:
> > > > > > 
> > > > > > GET
> > > > db/_design/power/_view/watt?group_level=2&startkey=[2011,3]&endkey=[2011,4]&inclusive_end=false
> > > > > > 
> > > > > > That gives you the sum for the month of March.
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > On 06/09/11 09:06, Fabio Di Bernardini wrote:
> > > > > > 
> > > > > > > Il 09/06/2011 17:18, Fabio Di Bernardini ha scritto:
> > > > > > > 
> > > > > > > > If I have a map function emitting a timestamp as key
ad a number as
> > > > > > > > document, how to get sum of values selecting a date
range?
> > > > > > > 
> > > > > > > More datails here:
> > > > http://stackoverflow.com/questions/6294794/how-to-sum-values-of-a-view-in-a-date-range-using-couchdb
> > > 
> > > 
> > > 
> > > --
> > > “The limits of language are the limits of one's world. “ -Ludwig von
> > > Wittgenstein
> 
> 
> 
> -- 
> Twitter: @eckoit
> http://eckoit.com - Keep what you hear.
> http://opendoorstories.com - Create Experiences


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message