Class: DYI::Chart::LineChart
Overview
Constant Summary
collapse
- CHART_TYPES =
[:line, :area, :bar, :stackedbar]
- DEFAULT_MARKERS =
[:circle, :square, :triangle, :pentagon, :rhombus, :inverted_triangle]
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=, #load_data, #puts_in_io, #save, #set_real_size, #string, #width, #width=
#opt_accessor, #opt_reader, #opt_writer
Constructor Details
#initialize(*args) ⇒ LineChart
Returns a new instance of LineChart.
177
178
179
180
|
# File 'lib/dyi/chart/line_chart.rb', line 177
def initialize(*args)
super
init_container
end
|
Instance Attribute Details
#axis_back_canvas ⇒ Object
36
37
38
|
# File 'lib/dyi/chart/line_chart.rb', line 36
def axis_back_canvas
@axis_back_canvas
end
|
#axis_front_canvas ⇒ Object
36
37
38
|
# File 'lib/dyi/chart/line_chart.rb', line 36
def axis_front_canvas
@axis_front_canvas
end
|
#back_canvas ⇒ Object
40
41
42
|
# File 'lib/dyi/chart/line_chart.rb', line 40
def back_canvas
@back_canvas
end
|
#chart_back_canvas ⇒ Object
36
37
38
|
# File 'lib/dyi/chart/line_chart.rb', line 36
def chart_back_canvas
@chart_back_canvas
end
|
#chart_front_canvas ⇒ Object
36
37
38
|
# File 'lib/dyi/chart/line_chart.rb', line 36
def chart_front_canvas
@chart_front_canvas
end
|
#chart_region ⇒ Object
38
39
40
|
# File 'lib/dyi/chart/line_chart.rb', line 38
def chart_region
@chart_region
end
|
#data_label_canvas ⇒ Object
40
41
42
|
# File 'lib/dyi/chart/line_chart.rb', line 40
def data_label_canvas
@data_label_canvas
end
|
#guid_front_canvas ⇒ Object
38
39
40
|
# File 'lib/dyi/chart/line_chart.rb', line 38
def guid_front_canvas
@guid_front_canvas
end
|
#legend_canvas ⇒ Object
36
37
38
|
# File 'lib/dyi/chart/line_chart.rb', line 36
def legend_canvas
@legend_canvas
end
|
#scale_canvas ⇒ Object
36
37
38
|
# File 'lib/dyi/chart/line_chart.rb', line 36
def scale_canvas
@scale_canvas
end
|
#x_scale_canvas ⇒ Object
38
39
40
|
# File 'lib/dyi/chart/line_chart.rb', line 38
def x_scale_canvas
@x_scale_canvas
end
|
#y_scale_canvas ⇒ Object
38
39
40
|
# File 'lib/dyi/chart/line_chart.rb', line 38
def y_scale_canvas
@y_scale_canvas
end
|
Instance Method Details
#__org_chart_type__ ⇒ Object
106
|
# File 'lib/dyi/chart/line_chart.rb', line 106
alias __org_chart_type__ chart_type
|
#area_chart_brush(color) ⇒ Object
172
173
174
|
# File 'lib/dyi/chart/line_chart.rb', line 172
def area_chart_brush(color)
Drawing::Brush.new(:color => color)
end
|
#back_translate_value ⇒ Object
#bar_chart_brush(color, bar_width = nil) ⇒ Object
163
164
165
166
167
168
169
170
|
# File 'lib/dyi/chart/line_chart.rb', line 163
def bar_chart_brush(color, bar_width=nil)
if represent_3d?
bar_width ||= chart_width * bar_width_ratio / data.records_size
Drawing::CylinderBrush.new(:color => color, :ry => bar_width * (back_translate_value[:dy] * bar_width_ratio).quo(back_translate_value[:dx] * 2))
else
Drawing::Brush.new(:color => color)
end
end
|
#chart_height ⇒ Object
151
152
153
|
# File 'lib/dyi/chart/line_chart.rb', line 151
def chart_height
height - margin_top - margin_bottom
end
|
#chart_type(index = nil) ⇒ Object
108
109
110
111
112
113
114
|
# File 'lib/dyi/chart/line_chart.rb', line 108
def chart_type(index = nil)
if index
(chart_types && chart_types[index]) || __org_chart_type__
else
__org_chart_type__
end
end
|
#chart_width ⇒ Object
147
148
149
|
# File 'lib/dyi/chart/line_chart.rb', line 147
def chart_width
width - margin_left - margin_right
end
|
#dropshadow_blur_std ⇒ Object
127
128
129
|
# File 'lib/dyi/chart/line_chart.rb', line 127
def dropshadow_blur_std
dropshadow_settings[:blur_std] || 4
end
|
#dropshadow_dx ⇒ Object
131
132
133
|
# File 'lib/dyi/chart/line_chart.rb', line 131
def dropshadow_dx
dropshadow_settings[:dx] || back_translate_value[:dx] / 2
end
|
#dropshadow_dy ⇒ Object
135
136
137
|
# File 'lib/dyi/chart/line_chart.rb', line 135
def dropshadow_dy
dropshadow_settings[:dy] || back_translate_value[:dy] / 2
end
|
#line_chart_pen(color) ⇒ Object
155
156
157
158
159
160
161
|
# File 'lib/dyi/chart/line_chart.rb', line 155
def line_chart_pen(color)
if represent_3d?
Drawing::CubicPen.new({:color => color, :width => line_width}.merge(s_3d_pen_options))
else
Drawing::Pen.new(:color => color, :width => line_width, :stroke_linecap => 'square')
end
end
|
#margin_bottom ⇒ Object
98
99
100
|
# File 'lib/dyi/chart/line_chart.rb', line 98
def margin_bottom
chart_margins[:bottom] || Length.new(32)
end
|
#margin_left ⇒ Object
102
103
104
|
# File 'lib/dyi/chart/line_chart.rb', line 102
def margin_left
chart_margins[:left] || Length.new(64)
end
|
#margin_right ⇒ Object
94
95
96
|
# File 'lib/dyi/chart/line_chart.rb', line 94
def margin_right
chart_margins[:right] || Length.new(64)
end
|
#margin_top ⇒ Object
90
91
92
|
# File 'lib/dyi/chart/line_chart.rb', line 90
def margin_top
chart_margins[:top] || Length.new(16)
end
|
#s_3d_pen_options ⇒ Object
116
117
118
|
# File 'lib/dyi/chart/line_chart.rb', line 116
def s_3d_pen_options
{:background_opacity => 0.3}.merge(_3d_settings)
end
|
#use_y_second_axis?(index = nil) ⇒ Boolean
139
140
141
142
143
144
145
|
# File 'lib/dyi/chart/line_chart.rb', line 139
def use_y_second_axis?(index = nil)
if index
use_y_second_axises && use_y_second_axises[index]
else
use_y_second_axises && use_y_second_axises.any?
end
end
|