Giter Club home page Giter Club logo

pivot_table's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pivot_table's Issues

Note on Ruby 1.8.7 - working

Encouraged by the remark 'There are no dependencies and pivot will work on any version of Ruby.' I tried it with Ruby 1.8.7 and it works for me.

I got a warning in the prepare_grid method on the line:

@data_grid << column_headers.count.times.inject([]) { |col| col << nil }

which went away when I replaced it with

@data_grid << column_headers.count.times.inject([]) { }

without any negative effect so far.

Not Accumulation Data

Hi!
In the example you have exactly one object for each cell in the resulting pivot table.
But ususally real data contains multiple entries for each cell in a pivot table. So instead of finding and picking the first matching entry in the "source_data" (grid.rb line 78) shouldn't it extract an array with a select method (using the same block)?
Otherwise the user would be forced to accumulate the input data himself and the advantage of this gem is lost.
Greeting.
Jens

how to display in a html.erb template

Hi

thx for publishing your gem. how do I actually display the table in an html.erb? I can build it but displaying it? I noticed that the build command - this presumably goes into the controller. but what do I put in view template between these tags: <% %> to make the pivot table display?

rgds

Ben

g.build fails

HI

When I do g.build (in my controller) like your readme mentions I get following error comparison of String with nil failed. Do you have any idea what could be the problem? I am literally messing with this for hours.

def no_category
@Transactions = Transaction.all.limit(10)
g = grid(@Transactions, { :row_name => :naam_tegenpartij, :column_name => :landcode })
g.build
end

My module code looks like this:

module PivotTableBla
def grid(data, options = {})
grid = PivotTable::Grid.new do |g|
g.source_data = data
g.column_name = options[:column_name]
g.row_name = options[:row_name]
end
end
end

Format of source_data

I'm using the following to construct

data = ActiveRecord::Base.connection.execute("SELECT users.name as user_name, leave_types.name as leave_type_name, leave_balances.balance from leave_balances join users on leave_balances.user_id = users.id join leave_types on leave_balances.leave_type_id = leave_types.id")

grid = PivotTable::Grid.new do |g|
    g.source_data  = data
    g.column_name  = :leave_type_name
    g.row_name     = :user_name
    g.value_name   = :balance
end

This gives me a result like:

[{"user_name"=>"Manager", "leave_type_name"=>"Anltjsjsjs", "balance"=>1.0, 0=>"Manager", 1=>"Anltjsjsjs", 2=>1.0}, {"user_name"=>"Employee",.....

Which fails when I build the grid with errors like:
undefined method `user_name' for #Hash:0x00000103ad0b98

it looks like this should work with an array of hashes, do I need to reformat or select differently somehow?

Pretty Print

This is cool. Do you have a quick way to print a grid to the console?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.