Module: Highcharts::Charting

Defined in:
lib/highcharts.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#categoriesObject

Returns the value of attribute categories.



9
10
11
# File 'lib/highcharts.rb', line 9

def categories
  @categories
end

#colorObject

Returns the value of attribute color.



9
10
11
# File 'lib/highcharts.rb', line 9

def color
  @color
end

#drilldownObject

Returns the value of attribute drilldown.



9
10
11
# File 'lib/highcharts.rb', line 9

def drilldown
  @drilldown
end

#endObject

Returns the value of attribute end.



9
10
11
# File 'lib/highcharts.rb', line 9

def end
  @end
end

#maximumObject

Returns the value of attribute maximum.



9
10
11
# File 'lib/highcharts.rb', line 9

def maximum
  @maximum
end

#minimumObject

Returns the value of attribute minimum.



9
10
11
# File 'lib/highcharts.rb', line 9

def minimum
  @minimum
end

#seriesObject

Returns the value of attribute series.



9
10
11
# File 'lib/highcharts.rb', line 9

def series
  @series
end

#slaObject

Returns the value of attribute sla.



9
10
11
# File 'lib/highcharts.rb', line 9

def sla
  @sla
end

#startObject

Returns the value of attribute start.



9
10
11
# File 'lib/highcharts.rb', line 9

def start
  @start
end

#styleObject

Returns the value of attribute style.



9
10
11
# File 'lib/highcharts.rb', line 9

def style
  @style
end

#subtitleObject

Returns the value of attribute subtitle.



9
10
11
# File 'lib/highcharts.rb', line 9

def subtitle
  @subtitle
end

#titleObject

Returns the value of attribute title.



9
10
11
# File 'lib/highcharts.rb', line 9

def title
  @title
end

#xObject

Returns the value of attribute x.



9
10
11
# File 'lib/highcharts.rb', line 9

def x
  @x
end

#yObject

Returns the value of attribute y.



9
10
11
# File 'lib/highcharts.rb', line 9

def y
  @y
end

Class Method Details

.style_choicesObject



28
29
30
# File 'lib/highcharts.rb', line 28

def self.style_choices
  return [ "line", "spline", "area", "areaspline", "column", "bar", "pie", "scatter" ]
end

.x_choicesObject



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_datesObject



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_categoriesObject



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_hcObject



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