Class | SVG::Graph::Schedule |
In: |
temp/Graph/Schedule.rb
|
Parent: | Graph |
require 'SVG/Graph/Schedule' # Data sets are label, start, end tripples. data1 = [ "Housesitting", "6/17/04", "6/19/04", "Summer Session", "6/15/04", "8/15/04", ] graph = SVG::Graph::Schedule.new( { :width => 640, :height => 480, :graph_title => title, :show_graph_title => true, :no_css => true, :scale_x_integers => true, :scale_y_integers => true, :min_x_value => 0, :min_y_value => 0, :show_data_labels => true, :show_x_guidelines => true, :show_x_title => true, :x_title => "Time", :stagger_x_labels => true, :stagger_y_labels => true, :x_label_format => "%m/%d/%y", }) graph.add_data({ :data => data1, :title => 'Data', }) print graph.burn()
Produces a graph of temporal scalar data.
www.germane-software/repositories/public/SVG/test/schedule.rb
The default stylesheet handles upto 10 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 10 data sets as they will have no style and be in black.
Note that multiple data sets within the same chart can differ in length, and that the data in the datasets needn‘t be in order; they will be ordered by the plot along the X-axis.
The dates must be parseable by ParseDate, but otherwise can be any order of magnitude (seconds within the hour, or years)
Sean E. Russell <serATgermaneHYPHENsoftwareDOTcom>
Copyright 2004 Sean E. Russell This software is available under the Ruby license
bar_gap | [RW] | |
min_x_value | [RW] | |
popup_format | [RW] | The formatting used for the popups. See x_label_format |
scale_x_divisions | [RW] | |
scale_x_integers | [RW] | |
timescale_divisions | [RW] |
Use this to set the spacing between dates on the axis. The value must be of
the form "\d+ ?(days|weeks|months|years|hours|minutes|seconds)?"
EG: graph.timescale_divisions = "2 weeks" will cause the chart to try to divide the X axis up into segments of two week periods. |
x_label_format | [RW] | The format string use do format the X axis labels. See Time::strformat |
Add data to the plot.
# A data set with 1 point: Lunch from 12:30 to 14:00 d1 = [ "Lunch", "12:30", "14:00" ] # A data set with 2 points: "Cats" runs from 5/11/03 to 7/15/04, and # "Henry V" runs from 6/12/03 to 8/20/03 d2 = [ "Cats", "5/11/03", "7/15/04", "Henry V", "6/12/03", "8/20/03" ] graph.add_data( :data => d1, :title => 'Meetings' ) graph.add_data( :data => d2, :title => 'Plays' )
Note that the data must be in time,value pairs, and that the date format may be any date that is parseable by ParseDate. Also note that, in this example, we‘re mixing scales; the data from d1 will probably not be discernable if both data sets are plotted on the same graph, since d1 is too granular.
In addition to the defaults set by Graph::initialize and Plot::set_defaults, sets: