lib/ruby_rich/bootstrap.rb
def create_grid(charts_num, names, cols = 2)

      raise "Then number of columns has to be an integer and not #{cols}" if 
        !cols.is_a? Integer

      # Not used yet... 
      # columns_width = (@max_width / cols).floor
      rows = 0

      if (charts_num <= cols)
        rows = 1
        grid = new_grid([charts_num, rows])
      else
        rows = (charts_num.to_f / cols).ceil
        grid = new_grid([rows, cols])
      end
      
      grid.each_with_counter do |cel, count|
        i = rows * count[0] + count[1]
        grid[*count] = (i < names.size)? names[i] : "__bootstrap_empty__"
      end
      
      add_grid(grid)

    end
#------------------------------------------------------------------------------------
# Creates a grid of the appropriate size for storing the specified number of charts
# and name them.  The grid will have cols columns and as many rows as necessary to 
# store all charts. The columns width will be as large as possible.
#------------------------------------------------------------------------------------
Creates a grid of the appropriate size for storing the specified number of charts
and name them.  The grid will have cols columns and as many rows as necessary to
store all charts. The columns width will be as large as possible.
Creates a grid of the appropriate size for storing the specified number of charts and name them . The grid will have cols columns and as many rows as necessary to store all charts . The columns width will be as large as possible .
def create_grid(charts_num, names, cols = 2)
      raise "Then number of columns has to be an integer and not #{cols}" if 
        !cols.is_a? Integer
      rows = 0
      if (charts_num <= cols)
        rows = 1
        grid = new_grid([charts_num, rows])
      else
        rows = (charts_num.to_f / cols).ceil
        grid = new_grid([rows, cols])
      end
      grid.each_with_counter do |cel, count|
        i = rows * count[0] + count[1]
        grid[*count] = (i < names.size)? names[i] : "__bootstrap_empty__"
      end
      add_grid(grid)
    end
def create_grid ( charts_num , names , cols = 2 ) raise "Then number of columns has to be an integer and not #{cols}" if ! cols . is_a? Integer rows = 0 if ( charts_num <= cols ) rows = 1 grid = new_grid ( [ charts_num , rows ] ) else rows = ( charts_num . to_f / cols ) . ceil grid = new_grid ( [ rows , cols ] ) end grid . each_with_counter do | cel , count | i = rows * count [ 0 ] + count [ 1 ] grid [ * count ] = ( i < names . size ) ? names [ i ] : "__bootstrap_empty__" end add_grid ( grid ) end
Creates a grid of the appropriate size for storing the specified number of charts
and name them.
Creates a grid of the appropriate size for storing the specified number of charts and name them .
# Not used yet...  # columns_width = (@max_width / cols).floor
charts_num
names
cols