Sha256: 07a5f1a61f2f78298481c892976cf8e3320020ac4b7b3303707548ab26a926e7

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

class RailsDataExplorer
  class DataType

    # @param[Hash, optional] constraints
    #  * :dimensions_count - how many data_series are there?
    def available_chart_types(constraints={})
      r = all_available_chart_types
      if(c = constraints.delete(:dimensions_count))
        r = r.find_all { |chart_type|
          (
            chart_type[:dimensions_count_min].nil? ||
            (chart_type[:dimensions_count_min] <= c)
          ) && (
            chart_type[:dimensions_count_max].nil? ||
            (chart_type[:dimensions_count_max] >= c)
          )
        }
      end
      if(c = constraints.delete(:chart_roles))
        # c = { ChartClass => [:x, :y], ... }
        r = r.find_all { |chart_type|
          c[chart_type[:chart_class]].nil? ||
          (c[chart_type[:chart_class]] & chart_type[:chart_roles]).any?
        }
      end
      # check for any unhandled options
      if constraints.any?
        raise "Unhandled constraints: #{ constraints.inspect }"
      end
      r
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails-data-explorer-0.2.3 lib/rails-data-explorer/data_type.rb
rails-data-explorer-0.2.2 lib/rails-data-explorer/data_type.rb
rails-data-explorer-0.2.1 lib/rails-data-explorer/data_type.rb
rails-data-explorer-0.2.0 lib/rails-data-explorer/data_type.rb
rails-data-explorer-0.1.0 lib/rails-data-explorer/data_type.rb
rails-data-explorer-0.0.1 lib/rails-data-explorer/data_type.rb