Sha256: 608a7278cc7319f71cee68818053e314e65a0c1458ba1a2cbf27b683b7b2e0c2
Contents?: true
Size: 974 Bytes
Versions: 2
Compression:
Stored size: 974 Bytes
Contents
module QueryReport module Chart class CustomChart attr_reader :title, :type, :options, :data_table, :row def initialize(type, title, query, options={}) @type = type @title = title @query = query @options = options @row = [] @data_table = GoogleVisualr::DataTable.new end def add_column(title) @data_table.new_column('string', title) @row << title.humanize end def add(column_title, &block) val = block.call(@query) @data_table.new_column(val.kind_of?(String) ? 'string' : 'number', column_title) @row << val end def prepare data_table.add_row(@row) opts = {:width => 500, :height => 240, :title => @title}.merge(options) chart_type = "#{type}_chart".classify chart_type = "GoogleVisualr::Interactive::#{chart_type}".constantize chart_type.new(data_table, opts) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
query_report-0.0.2 | lib/query_report/chart/custom_chart.rb |
query_report-0.0.1 | lib/query_report/chart/custom_chart.rb |