Class: GerbilCharts::Models::GraphModel

Inherits:
Object
  • Object
show all
Defined in:
lib/gerbilcharts/models/graph_model.rb

Overview

GraphModel - Basic interface to a model in GerbilCharts

You can create your own model as long as all the methods here are implemented or you can use one of the predefined graph models.

Direct Known Subclasses

MonotonousGraphModel

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(n = "Untitled") ⇒ GraphModel

Returns a new instance of GraphModel.



20
21
22
23
# File 'lib/gerbilcharts/models/graph_model.rb', line 20

def initialize(n="Untitled")
  @name=n
  @transformer = nil
end

Instance Attribute Details

#altnameObject

alternate name



12
13
14
# File 'lib/gerbilcharts/models/graph_model.rb', line 12

def altname
  @altname
end

#hrefObject (readonly)

href for interactive use



13
14
15
# File 'lib/gerbilcharts/models/graph_model.rb', line 13

def href
  @href
end

#href_pivotObject

href for pivot box (used w/ time selector)



18
19
20
# File 'lib/gerbilcharts/models/graph_model.rb', line 18

def href_pivot
  @href_pivot
end

#nameObject

name of the model (eg, “backup_server”)



11
12
13
# File 'lib/gerbilcharts/models/graph_model.rb', line 11

def name
  @name
end

#transformerObject

value transformer (a lambda function)



17
18
19
# File 'lib/gerbilcharts/models/graph_model.rb', line 17

def transformer
  @transformer
end

#userdataObject (readonly)

any user object



14
15
16
# File 'lib/gerbilcharts/models/graph_model.rb', line 14

def userdata
  @userdata
end

#userlabel1Object (readonly)

map to tooltip 1



15
16
17
# File 'lib/gerbilcharts/models/graph_model.rb', line 15

def userlabel1
  @userlabel1
end

#userlabel2Object (readonly)

map to tooltip 2



16
17
18
# File 'lib/gerbilcharts/models/graph_model.rb', line 16

def userlabel2
  @userlabel2
end

Instance Method Details

#countObject



37
38
39
# File 'lib/gerbilcharts/models/graph_model.rb', line 37

def count
  0
end

#each_value_pair {|0, 0| ... } ⇒ Object

Yields:

  • (0, 0)


33
34
35
# File 'lib/gerbilcharts/models/graph_model.rb', line 33

def each_value_pair
  yield 0,0
end

#hasHref?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/gerbilcharts/models/graph_model.rb', line 54

def hasHref?
  return @href != nil
end

#hasHrefPivot?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/gerbilcharts/models/graph_model.rb', line 58

def hasHrefPivot?
  return @href_pivot != nil
end

#hasUserData?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/gerbilcharts/models/graph_model.rb', line 66

def hasUserData?
  return @userdata != nil
end

#hasUserTips?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/gerbilcharts/models/graph_model.rb', line 70

def hasUserTips?
  return @userlabel1 != nil
end

#is_timeseries?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/gerbilcharts/models/graph_model.rb', line 96

def is_timeseries?
  return false
end

#min_max_x {|0, 0| ... } ⇒ Object

Yields:

  • (0, 0)


25
26
27
# File 'lib/gerbilcharts/models/graph_model.rb', line 25

def min_max_x
  yield 0,0    
end

#min_max_y {|0, 0| ... } ⇒ Object

Yields:

  • (0, 0)


29
30
31
# File 'lib/gerbilcharts/models/graph_model.rb', line 29

def min_max_y
  yield 0,0
end

#recreateObject



88
89
90
# File 'lib/gerbilcharts/models/graph_model.rb', line 88

def recreate
  # no op (override this)
end

#setHref(h) ⇒ Object

clean up the href (todo: improve this)



42
43
44
45
# File 'lib/gerbilcharts/models/graph_model.rb', line 42

def setHref(h)
  h1=h.gsub("{","%7B")
  @href=h1.gsub("}","%7D")
end

#setHrefPivot(h) ⇒ Object

clean up the href (todo: improve this)



48
49
50
51
# File 'lib/gerbilcharts/models/graph_model.rb', line 48

def setHrefPivot(h)
  h1=h.gsub("{","%7B")
  @href_pivot=h1.gsub("}","%7D")
end

#setUserData(d) ⇒ Object



62
63
64
# File 'lib/gerbilcharts/models/graph_model.rb', line 62

def setUserData(d)
  @userdata=d
end

#setUserTip1(t) ⇒ Object



74
75
76
77
# File 'lib/gerbilcharts/models/graph_model.rb', line 74

def setUserTip1(t)
  @userlabel1=t
  @userlabel2="" if @userlabel2.nil?
end

#setUserTip2(t) ⇒ Object



79
80
81
82
# File 'lib/gerbilcharts/models/graph_model.rb', line 79

def setUserTip2(t)
  @userlabel2=t
  @userlabel1="" if @userlabel1.nil?
end

#updateOptions(opts) ⇒ Object



84
85
86
# File 'lib/gerbilcharts/models/graph_model.rb', line 84

def updateOptions(opts)
  @name = opts[:name] if opts[:name]
end