Sha256: 874b77c2b3034365a97cee322cb53a52d6388fddde5be1eec93a2b011769764d
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
module Seer require 'seer/chart' require 'seer/area_chart' require 'seer/bar_chart' require 'seer/column_chart' require 'seer/gauge' require 'seer/geomap' require 'seer/line_chart' require 'seer/pie_chart' VISUALIZERS = [:area_chart, :bar_chart, :column_chart, :gauge, :geomap, :line_chart, :pie_chart] def self.valid_hex_number?(val) #:nodoc: return false unless val.is_a?(String) && ! val.empty? ! (val =~ /^\#([0-9]|[a-f]|[A-F])+$/).nil? && val.length == 7 end def self.log(message) #:nodoc: RAILS_DEFAULT_LOGGER.info(message) end # gifted from ActionView::Helpers::JavaScriptHelper def self.options_for_javascript(options) '{' + options.map {|k, v| "#{k}:\"#{v}\""}.sort.join(', ') + '}' end def self.init_visualization %{ <script type="text/javascript"> var jsapi = (("https:" == document.location.protocol) ? "https://" : "http://"); document.write(unescape("%3Cscript src='" + jsapi + "www.google.com/jsapi' type='text/javascript'%3E%3C/script%3E")); </script> } end def self.visualize(data, args={}) raise ArgumentError, "Seer: Invalid visualizer: #{args[:as]}" unless args[:as] && VISUALIZERS.include?(args[:as]) raise ArgumentError, "Seer: No data provided!" unless data && ! data.empty? self.send(args[:as], data, args) end private def self.area_chart(data, args) AreaChart.render(data, args) end def self.bar_chart(data, args) BarChart.render(data, args) end def self.column_chart(data, args) ColumnChart.render(data, args) end def self.gauge(data, args) Gauge.render(data, args) end def self.geomap(data, args) Geomap.render(data, args) end def self.line_chart(data, args) LineChart.render(data, args) end def self.pie_chart(data, args) PieChart.render(data, args) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
glennr-seer-0.9.3 | lib/seer.rb |