Class: Geoptima::GruffChart
- Inherits:
-
Chart
- Object
- Chart
- Geoptima::GruffChart
show all
- Defined in:
- lib/geoptima/chart.rb
Constant Summary
Constants inherited
from Chart
Chart::DEFAULT_OPTIONS
Instance Attribute Summary
Attributes inherited from Chart
#chart_type, #options
Instance Method Summary
collapse
Methods inherited from Chart
available?, bar, draw_category_chart, draw_grouped_chart, draw_histogram_chart, draw_line_chart, engine, engine=, libs, line, make_chart
Constructor Details
#initialize(chart_type, options = {}) ⇒ GruffChart
Returns a new instance of GruffChart.
109
110
111
|
# File 'lib/geoptima/chart.rb', line 109
def initialize(chart_type,options={})
super(chart_type,options)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, &block) ⇒ Object
140
141
142
|
# File 'lib/geoptima/chart.rb', line 140
def method_missing(symbol,*args,&block)
chart.send symbol, *args, &block
end
|
Instance Method Details
#chart ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/geoptima/chart.rb', line 112
def chart
unless @chart
case chart_type.to_s
when 'line'
@chart = Gruff::Line.new(options[:width])
@chart.hide_dots = !options[:show_points]
@chart.hide_lines = !options[:show_lines]
when 'bar'
@chart = Gruff::Bar.new(options[:width])
when 'side_bar'
@chart = Gruff::SideBar.new(options[:width])
else
raise "Unsupported chart type: #{chart_type}"
end
@chart.title = options[:title]
@chart.margins = options[:margins]
@chart.legend_font_size = options[:font_size]
@chart.marker_font_size = options[:font_size]
@chart.title_font_size = options[:title_font_size] || 2 * options[:font_size]
end
@chart
end
|
#data(name, values) ⇒ Object
134
135
136
|
# File 'lib/geoptima/chart.rb', line 134
def data(name,values)
chart.data(name,values)
end
|
#labels=(label_map) ⇒ Object
137
138
139
|
# File 'lib/geoptima/chart.rb', line 137
def labels=(label_map)
chart.labels = label_map
end
|
#write(filename) ⇒ Object
143
144
145
|
# File 'lib/geoptima/chart.rb', line 143
def write(filename)
chart.write(filename)
end
|