Class: DYI::Chart::Table
- Inherits:
-
Base
- Object
- Base
- DYI::Chart::Table
show all
- Defined in:
- lib/dyi/chart/table.rb
Overview
Constant Summary
Constants inherited
from Base
Base::DEFAULT_CHART_COLOR
Instance Attribute Summary collapse
Attributes inherited from Base
#canvas, #data
Instance Method Summary
collapse
Methods inherited from Base
#clear_real_size, #height, #height=, #initialize, #load_data, #puts_in_io, #save, #set_real_size, #string, #width, #width=
#opt_accessor, #opt_reader, #opt_writer
Instance Attribute Details
#data_canvas ⇒ Object
28
29
30
|
# File 'lib/dyi/chart/table.rb', line 28
def data_canvas
@data_canvas
end
|
#frame_canvas ⇒ Object
28
29
30
|
# File 'lib/dyi/chart/table.rb', line 28
def frame_canvas
@frame_canvas
end
|
Instance Method Details
#column_colors ⇒ Object
106
107
108
|
# File 'lib/dyi/chart/table.rb', line 106
def column_colors
@options[:column_colors]
end
|
#column_colors=(colors) ⇒ Object
110
111
112
113
114
115
116
117
|
# File 'lib/dyi/chart/table.rb', line 110
def column_colors=(colors)
if colors && !colors.empty?
@options[:column_colors] = colors
else
@options.delete(:column_colors)
end
colors
end
|
#column_width(index) ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/dyi/chart/table.rb', line 71
def column_width(index)
case column_widths
when Length then column_widths
when Array then column_widths[index]
else width / series.size
end
end
|
#column_widths ⇒ Object
56
57
58
|
# File 'lib/dyi/chart/table.rb', line 56
def column_widths
@options[:column_widths]
end
|
#column_widths=(widths) ⇒ Object
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/dyi/chart/table.rb', line 60
def column_widths=(widths)
if widths.kind_of?(Array)
@options[:column_widths] = widths.map {|width| Length.new_or_nil(width)}
elsif widths
@options[:column_widths] = Length.new(widths)
else
@options.delete(:column_widths)
end
point
end
|
#font ⇒ Object
30
31
32
|
# File 'lib/dyi/chart/table.rb', line 30
def font
@options[:font]
end
|
#font=(font) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/dyi/chart/table.rb', line 34
def font=(font)
if font && !font.empty?
@options[:font] = Font.new(font)
else
@options.delete(:font)
end
font
end
|
#horizontal_position(index) ⇒ Object
102
103
104
|
# File 'lib/dyi/chart/table.rb', line 102
def horizontal_position(index)
@options[:horizontal_positions] && @options[:horizontal_positions][index]
end
|
#horizontal_positions ⇒ Object
89
90
91
|
# File 'lib/dyi/chart/table.rb', line 89
def horizontal_positions
@options[:horizontal_positions]
end
|
#horizontal_positions=(positions) ⇒ Object
93
94
95
96
97
98
99
100
|
# File 'lib/dyi/chart/table.rb', line 93
def horizontal_positions=(positions)
if positions && !positions.empty?
@options[:horizontal_positions] = positions
else
@options.delete(:horizontal_positions)
end
positions
end
|
#row_height ⇒ Object
43
44
45
|
# File 'lib/dyi/chart/table.rb', line 43
def row_height
@options[:row_height] ||= (font && font.draw_size || Font::DEFAULT_SIZE) * 1.4
end
|
#row_height=(height) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/dyi/chart/table.rb', line 47
def row_height=(height)
if heights
@options[:row_height] = Length.new(height)
else
@options.delete(:row_height)
end
point
end
|
#table_height ⇒ Object
85
86
87
|
# File 'lib/dyi/chart/table.rb', line 85
def table_height
row_height * data[series.first].size
end
|
#table_width ⇒ Object
79
80
81
82
83
|
# File 'lib/dyi/chart/table.rb', line 79
def table_width
series.inject(Length.new(0)) do |width, i|
width + column_width(i)
end
end
|