Class: Charts::ManikinCountChart
Instance Attribute Summary
Attributes inherited from Chart
#data, #options, #prepared_data, #renderer
Instance Method Summary
collapse
Methods inherited from CountChart
#default_options, #draw, #draw_label_text, #draw_labels, #height, #label_count, #offset_x, #offset_y, #outer_item_height, #outer_item_width, #prepare_data, #validate_arguments, #width
Methods inherited from Chart
#create_options_methods, #default_options, #draw, #draw_background, #draw_title, #initialize, #initialize_instance_variables, #post_draw, #pre_draw, #prepare_data, #render, #validate_arguments, #validate_array_and_count
Constructor Details
This class inherits a constructor from Charts::Chart
Instance Method Details
#arms(x, y, style) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/charts/count_chart/manikin_count_chart.rb', line 22
def arms(x, y, style)
top = y + height_percent(40)
bottom = y + height_percent(70)
left_x = x - width_percent(25)
right_x = x + width_percent(25)
renderer.line left_x, top, left_x, bottom, style.merge(class: 'left-arm')
renderer.line right_x, top, right_x, bottom, style.merge(class: 'right-arm')
end
|
#body(x, y, style) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/charts/count_chart/manikin_count_chart.rb', line 15
def body(x, y, style)
top = y + height_percent(40)
bottom = y + height_percent(95)
renderer.line x, top, x, bottom, style.merge(stroke_width: width_percent(30), class: 'body')
end
|
#draw_item(x, y, color) ⇒ Object
2
3
4
5
6
|
# File 'lib/charts/count_chart/manikin_count_chart.rb', line 2
def draw_item(x, y, color)
head x + width_percent(50), y, style(color)
body x + width_percent(50), y, style(color)
arms x + width_percent(50), y, style(color)
end
|
#head(x, y, style) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/charts/count_chart/manikin_count_chart.rb', line 8
def head(x, y, style)
cy = y + height_percent(20)
radius = height_percent(10)
renderer.circle x, cy, radius, style.merge(class: 'head')
end
|
#height_percent(multiplicator) ⇒ Object
44
45
46
|
# File 'lib/charts/count_chart/manikin_count_chart.rb', line 44
def height_percent(multiplicator)
multiplicator * item_height / 100
end
|
#style(color) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/charts/count_chart/manikin_count_chart.rb', line 32
def style(color)
{
fill: color,
stroke: color,
stroke_width: width_percent(10)
}
end
|
#width_percent(multiplicator) ⇒ Object
40
41
42
|
# File 'lib/charts/count_chart/manikin_count_chart.rb', line 40
def width_percent(multiplicator)
multiplicator * item_width / 100
end
|