Class: Charts::BarChart::VerticalBar

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

Instance Attribute Summary

Attributes inherited from Bar

#bar_nr_in_set, #chart, #data_value, #set_nr

Instance Method Summary collapse

Methods inherited from Bar

#bar_number_in_chart, #draw, #initialize

Constructor Details

This class inherits a constructor from Charts::BarChart::Bar

Instance Method Details

#heightObject



30
31
32
# File 'lib/charts/bar_chart/bar/vertical_bar.rb', line 30

def height
  chart.inner_height * (data_value - chart.base_line).abs
end

#widthObject



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

def width
  chart.bar_inner_width.floor.to_i
end

#xObject



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

def x
  (x_margin + x_offset).floor.to_i
end

#x_marginObject



6
7
8
# File 'lib/charts/bar_chart/bar/vertical_bar.rb', line 6

def x_margin
  chart.outer_margin + chart.bar_margin + chart.group_margin * bar_nr_in_set
end

#x_offsetObject



10
11
12
# File 'lib/charts/bar_chart/bar/vertical_bar.rb', line 10

def x_offset
  chart.bar_outer_width * bar_number_in_chart
end

#yObject



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

def y
  y_margin + y_offset
end

#y_marginObject



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

def y_margin
  chart.outer_margin
end

#y_offsetObject



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

def y_offset
  chart.inner_height * [(1 - data_value), (1 - chart.base_line)].min
end