Class: Charts::BarChart::Bar
- Inherits:
-
Object
- Object
- Charts::BarChart::Bar
show all
- Defined in:
- lib/charts/bar_chart/bar/bar.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(chart, data_value, set_nr, bar_nr_in_set) ⇒ Bar
Returns a new instance of Bar.
4
5
6
7
8
9
|
# File 'lib/charts/bar_chart/bar/bar.rb', line 4
def initialize(chart, data_value, set_nr, bar_nr_in_set)
@chart = chart
@data_value = data_value
@set_nr = set_nr
@bar_nr_in_set = bar_nr_in_set
end
|
Instance Attribute Details
#bar_nr_in_set ⇒ Object
Returns the value of attribute bar_nr_in_set.
2
3
4
|
# File 'lib/charts/bar_chart/bar/bar.rb', line 2
def bar_nr_in_set
@bar_nr_in_set
end
|
#chart ⇒ Object
Returns the value of attribute chart.
2
3
4
|
# File 'lib/charts/bar_chart/bar/bar.rb', line 2
def chart
@chart
end
|
#data_value ⇒ Object
Returns the value of attribute data_value.
2
3
4
|
# File 'lib/charts/bar_chart/bar/bar.rb', line 2
def data_value
@data_value
end
|
#set_nr ⇒ Object
Returns the value of attribute set_nr.
2
3
4
|
# File 'lib/charts/bar_chart/bar/bar.rb', line 2
def set_nr
@set_nr
end
|
Instance Method Details
#bar_number_in_chart ⇒ Object
31
32
33
|
# File 'lib/charts/bar_chart/bar/bar.rb', line 31
def bar_number_in_chart
set_nr + bar_nr_in_set * chart.set_count
end
|
#draw ⇒ Object
11
12
13
|
# File 'lib/charts/bar_chart/bar/bar.rb', line 11
def draw
chart.renderer.rect x, y, width, height, fill: chart.colors[set_nr], class: 'bar'
end
|
#height ⇒ Object
27
28
29
|
# File 'lib/charts/bar_chart/bar/bar.rb', line 27
def height
raise NotImplementedError
end
|
#width ⇒ Object
23
24
25
|
# File 'lib/charts/bar_chart/bar/bar.rb', line 23
def width
raise NotImplementedError
end
|
#x ⇒ Object
15
16
17
|
# File 'lib/charts/bar_chart/bar/bar.rb', line 15
def x
raise NotImplementedError
end
|
#y ⇒ Object
19
20
21
|
# File 'lib/charts/bar_chart/bar/bar.rb', line 19
def y
raise NotImplementedError
end
|