Class: Plasticine::Builder::Column
- Inherits:
-
Base
- Object
- Base
- Plasticine::Builder::Column
show all
- Defined in:
- lib/plasticine/builder/column.rb
Instance Attribute Summary
Attributes inherited from Base
#visual
Instance Method Summary
collapse
Methods inherited from Base
#chart_style=, #id, #l, #period, #set_period_from_data, #t, #title, #to_json
Constructor Details
#initialize(id, options = {}) ⇒ Column
Returns a new instance of Column.
2
3
4
5
6
7
|
# File 'lib/plasticine/builder/column.rb', line 2
def initialize(id, options={})
super
@visual.merge! columns: [], nature: 'column', axis_x_format: :string, axis_y_format: :number, axis_y_tick_count: 10, quarter_start_month: 1
@columns = {}
end
|
Instance Method Details
#add_column(x, y, options = {}) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/plasticine/builder/column.rb', line 9
def add_column(x, y, options={})
options.reverse_merge! tooltip: nil
@columns[x] = [] if not @columns[x]
@columns[x] << { tooltip: options[:tooltip], y: y }
end
|
17
18
19
|
# File 'lib/plasticine/builder/column.rb', line 17
def axis_x_format=(format)
@visual[:axis_x_format] = format
end
|
21
22
23
|
# File 'lib/plasticine/builder/column.rb', line 21
def axis_y_format=(format)
@visual[:axis_y_format] = format
end
|
#axis_y_tick_count=(tick_count) ⇒ Object
25
26
27
|
# File 'lib/plasticine/builder/column.rb', line 25
def axis_y_tick_count=(tick_count)
@visual[:axis_y_tick_count] = tick_count
end
|
#close_visual ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/plasticine/builder/column.rb', line 34
def close_visual
super
@columns.each do |x, data|
@visual[:columns] << { x_value: x, y_values: data.map{ |d| d[:y] }, tooltip: data[0][:tooltip] }
end
end
|
#quarter_start_month=(month) ⇒ Object
29
30
31
|
# File 'lib/plasticine/builder/column.rb', line 29
def quarter_start_month=(month)
@visual[:quarter_start_month] = month
end
|