Class: Charts::BarChart::Bar

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

Direct Known Subclasses

HorizontalBar, VerticalBar

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_setObject (readonly)

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

#chartObject (readonly)

Returns the value of attribute chart.



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

def chart
  @chart
end

#data_valueObject (readonly)

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_nrObject (readonly)

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_chartObject



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

#drawObject



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

#heightObject

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/charts/bar_chart/bar/bar.rb', line 27

def height
  raise NotImplementedError
end

#widthObject

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/charts/bar_chart/bar/bar.rb', line 23

def width
  raise NotImplementedError
end

#xObject

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/charts/bar_chart/bar/bar.rb', line 15

def x
  raise NotImplementedError
end

#yObject

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/charts/bar_chart/bar/bar.rb', line 19

def y
  raise NotImplementedError
end