Module: Highcharts::Charting
- Defined in:
- lib/highcharts.rb
Instance Attribute Summary collapse
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#color ⇒ Object
Returns the value of attribute color.
-
#drilldown ⇒ Object
Returns the value of attribute drilldown.
-
#end ⇒ Object
Returns the value of attribute end.
-
#maximum ⇒ Object
Returns the value of attribute maximum.
-
#minimum ⇒ Object
Returns the value of attribute minimum.
-
#series ⇒ Object
Returns the value of attribute series.
-
#sla ⇒ Object
Returns the value of attribute sla.
-
#start ⇒ Object
Returns the value of attribute start.
-
#style ⇒ Object
Returns the value of attribute style.
-
#subtitle ⇒ Object
Returns the value of attribute subtitle.
-
#title ⇒ Object
Returns the value of attribute title.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Class Method Summary collapse
Instance Method Summary collapse
- #create_array_of_dates ⇒ Object
- #humanize_categories ⇒ Object
- #initialize(user_supplied_hash = {}) ⇒ Object
- #to_hc ⇒ Object
Instance Attribute Details
#categories ⇒ Object
Returns the value of attribute categories.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def categories @categories end |
#color ⇒ Object
Returns the value of attribute color.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def color @color end |
#drilldown ⇒ Object
Returns the value of attribute drilldown.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def drilldown @drilldown end |
#end ⇒ Object
Returns the value of attribute end.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def end @end end |
#maximum ⇒ Object
Returns the value of attribute maximum.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def maximum @maximum end |
#minimum ⇒ Object
Returns the value of attribute minimum.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def minimum @minimum end |
#series ⇒ Object
Returns the value of attribute series.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def series @series end |
#sla ⇒ Object
Returns the value of attribute sla.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def sla @sla end |
#start ⇒ Object
Returns the value of attribute start.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def start @start end |
#style ⇒ Object
Returns the value of attribute style.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def style @style end |
#subtitle ⇒ Object
Returns the value of attribute subtitle.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def subtitle @subtitle end |
#title ⇒ Object
Returns the value of attribute title.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def title @title end |
#x ⇒ Object
Returns the value of attribute x.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
9 10 11 |
# File 'lib/highcharts.rb', line 9 def y @y end |
Class Method Details
.style_choices ⇒ Object
28 29 30 |
# File 'lib/highcharts.rb', line 28 def self.style_choices return [ "line", "spline", "area", "areaspline", "column", "bar", "pie", "scatter" ] end |
.x_choices ⇒ Object
24 25 26 |
# File 'lib/highcharts.rb', line 24 def self.x_choices return [ "year", "month", "week", "day", "hour", "minute", "second" ] end |
Instance Method Details
#create_array_of_dates ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/highcharts.rb', line 43 def create_array_of_dates all_dates = IceCube::Schedule.new(Time.parse(@start), :end_time => Time.parse(@end)) rule = case @x when "month" IceCube::Rule.monthly when "week" IceCube::Rule.weekly when "day" IceCube::Rule.daily when "hour" IceCube::Rule.hourly when "minute" IceCube::Rule.minutely when "second" IceCube::Rule.secondly end all_dates.add_recurrence_rule rule @categories = all_dates.all_occurrences end |
#humanize_categories ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/highcharts.rb', line 65 def humanize_categories label = case @x when "month" "%m-%Y" when "week", "day" "%m-%d" when "hour" "%I%p" when "minute" "%I:%M%p" when "second" "%I:%M:%S%p" end temp_categories = [] @categories.each do |date| temp_categories << date.strftime(label) end @categories = temp_categories end |
#initialize(user_supplied_hash = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/highcharts.rb', line 11 def initialize(user_supplied_hash={}) standard_hash = { title:"", subtitle:"", drilldown:"", start:"", end:"", style:"", x:"", y:"", maximum:"", minimum:"", sla:0, series:[], categories:[], color:"" } user_supplied_hash = standard_hash.merge(user_supplied_hash) user_supplied_hash.each do |key,value| self.instance_variable_set("@#{key}", value) self.class.send(:define_method, key, proc{self.instance_variable_get("@#{key}")}) self.class.send(:define_method, "#{key}=", proc{|x| self.instance_variable_set("@#{key}", x)}) end end |
#to_hc ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/highcharts.rb', line 32 def to_hc hc_hash = {} self.instance_variables.each do |variable| v = variable.to_s[1,variable.length] hc_hash.store(v,self.send(v)) end return hc_hash end |