Class: Igs::BarChart

Inherits:
Object
  • Object
show all
Defined in:
lib/igs_bar_chart/bar_chart.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, width, height, target_element = 'body', data) ⇒ BarChart



4
5
6
7
8
9
10
11
12
# File 'lib/igs_bar_chart/bar_chart.rb', line 4

def initialize(title,width,height,target_element='body',data)
  @title = title
  @width = width
  @height = height
  @data = data.values
  @labels = data.keys
  @target_element = target_element
  @default_attribution=false
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



2
3
4
# File 'lib/igs_bar_chart/bar_chart.rb', line 2

def data
  @data
end

#sizeObject (readonly)

Returns the value of attribute size.



2
3
4
# File 'lib/igs_bar_chart/bar_chart.rb', line 2

def size
  @size
end

#target_elementObject (readonly)

Returns the value of attribute target_element.



2
3
4
# File 'lib/igs_bar_chart/bar_chart.rb', line 2

def target_element
  @target_element
end

#titleObject (readonly)

Returns the value of attribute title.



2
3
4
# File 'lib/igs_bar_chart/bar_chart.rb', line 2

def title
  @title
end

Instance Method Details

#height=(height) ⇒ Object



48
49
50
# File 'lib/igs_bar_chart/bar_chart.rb', line 48

def height=(height)
  @height = height
end

#labelsObject



22
23
24
# File 'lib/igs_bar_chart/bar_chart.rb', line 22

def labels
  return eval_erb('labels.html')
end

#renderObject



26
27
28
29
30
31
32
33
34
# File 'lib/igs_bar_chart/bar_chart.rb', line 26

def render
  rendering = "<style>\n"
  rendering+= self.style
  rendering+= "</style>\n"
  rendering+= self.script
  #rendering+= self.labels
  
  return rendering
end

#scriptObject



14
15
16
# File 'lib/igs_bar_chart/bar_chart.rb', line 14

def script
  return eval_erb('script.html')
end

#styleObject



18
19
20
# File 'lib/igs_bar_chart/bar_chart.rb', line 18

def style
  return eval_erb('style.css')
end

#to_sObject



36
37
38
# File 'lib/igs_bar_chart/bar_chart.rb', line 36

def to_s
  render
end

#width=(width) ⇒ Object



44
45
46
# File 'lib/igs_bar_chart/bar_chart.rb', line 44

def width=(width)
  @width = width
end