Class: SVG::Graph::ErrBar
- Includes:
- REXML
- Defined in:
- lib/SVG/Graph/ErrBar.rb
Overview
Create presentation quality SVG bar graphs easily
Synopsis
require 'SVG/Graph/Bar'
fields = %w(Jan Feb Mar);
data_sales_02 = [12, 45, 21]
graph = SVG::Graph::Bar.new(
:height => 500,
:width => 300,
:fields => fields
)
graph.add_data(
:data => data_sales_02,
:title => 'Sales 2002'
)
print "Content-type: image/svg+xml\r\n\r\n"
print graph.burn
Description
This object aims to allow you to easily create high quality SVG[www.w3c.org/tr/svg bar graphs. You can either use the default style sheet or supply your own. Either way there are many options which can be configured to give you control over how the graph is generated - with or without a key, data elements at each point, title, subtitle etc.
Notes
The default stylesheet handles upto 12 data sets, if you use more you must create your own stylesheet and add the additional settings for the extra data sets. You will know if you go over 12 data sets as they will have no style and be in black.
Examples
See also
-
SVG::Graph::Graph
-
SVG::Graph::BarHorizontal
-
SVG::Graph::Line
-
SVG::Graph::Pie
-
SVG::Graph::Plot
-
SVG::Graph::TimeSeries
Instance Attribute Summary
Attributes inherited from BarBase
Attributes inherited from Graph
#add_popups, #font_size, #graph_subtitle, #graph_title, #height, #key, #key_font_size, #key_position, #min_scale_value, #no_css, #number_format, #popup_radius, #rotate_x_labels, #rotate_y_labels, #scale_divisions, #scale_integers, #show_data_values, #show_graph_subtitle, #show_graph_title, #show_x_guidelines, #show_x_labels, #show_x_title, #show_y_guidelines, #show_y_labels, #show_y_title, #stagger_x_labels, #stagger_y_labels, #step_include_first_x_label, #step_x_labels, #style_sheet, #subtitle_font_size, #title_font_size, #width, #x_label_font_size, #x_title, #x_title_font_size, #x_title_location, #y_label_font_size, #y_title, #y_title_font_size, #y_title_location, #y_title_text_direction
Instance Method Summary collapse
-
#initialize(config) ⇒ ErrBar
constructor
A new instance of ErrBar.
-
#set_defaults ⇒ Object
See Graph::initialize and BarBase::set_defaults.
Methods inherited from Graph
#add_data, #burn, #burn_svg_only, #clear_data
Constructor Details
#initialize(config) ⇒ ErrBar
Returns a new instance of ErrBar.
61 62 63 64 65 66 |
# File 'lib/SVG/Graph/ErrBar.rb', line 61 def initialize config raise "fields was not supplied or is empty" unless config[:errorBars] && config[:errorBars].kind_of?(Array) && config[:errorBars].length > 0 super end |
Instance Method Details
#set_defaults ⇒ Object
See Graph::initialize and BarBase::set_defaults
70 71 72 73 |
# File 'lib/SVG/Graph/ErrBar.rb', line 70 def set_defaults super self.top_align = self.top_font = 1 end |