David, thanks for the reply.  That's probably a better solution, but I'm not sure how feasible it would be to use with my data (or, I'm not so sure I could figure out how to do it in a reasonable amount of time..).  I also should have been clearer about the data being used.  It's not really an ActiveRecord object in the ORM sense; it's really the result of any query, usually with calculations like fail rate, statistical tests, etc. I'll give it some thought though..

Regards,
Bryan

On 10/18/06, David Turnbull <[EMAIL PROTECTED]> wrote:
Sounds like you're trying to build a class to vend a pivot table based on what it's fed.  I'd suggest instead making your existing data models look like a pivot table.  Once that is working, you should see all the patterns you need to refactor it into something reusable like an acts_as_pivot_table.  For the sparse data, ignore it.  Build a wrapper to make it look full if you need.

-david


On Oct 18, 2006, at 1:30 PM, Bryan Donovan wrote:

Hi,
I'm working on a class that I'll use in some rails applications that are used to display data in cross-tabulation format (or as it's called in Excel, a "pivot table").  Right now I'm taking an ActiveRecord object, specifying what fields should go where in the crosstab, and then generating a big nested hash (which I call a "tree", but not sure if that's the right terminology).  This isn't too difficult if I always know how many levels the tree will have, etc., but I want this to be flexible enough to handle any reasonable number of levels.  I've also generated crosstab datasets with SQL directly, but it gets a bit hard to follow and in my current situation, the query runs slowly.  This is a bit difficult to explain, so I've put up a web page with an example hash and the desired output here:

http://bryandonovan.com/pastes/crosstab.html



_______________________________________________
PDXRuby mailing list
[email protected]
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby


_______________________________________________
PDXRuby mailing list
[email protected]
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby

Reply via email to