ruby SVG::Graph module problem.

G

Guest

Hello there all,

As my "learn Ruby" project I am creating a replacement for mrtg-rrd.cgi
in ruby. (i.e. create TimeSeries graphs from RRD databases as SVG. Much
nicer than PNG graphs).

Using SVG::Graph and rrd-ruby (from
http://www.germane-software.com/software/SVG/SVG::Graph/ and
http://www.caddr.com/code/ruby-rrd-1.0.tar.gz respectively.)

So, starting with the SVG mod, I am working through the examples
included and all works as expected.

Except for anything including Time / Dates - SVG::Graph::TimeSeries and
SVG::Graph::Schedule.

Could this be a localisation issue? (I'm in the UK).
A bug in the module?

#======Code==========
#!/usr/bin/ruby
require 'SVG/Graph/TimeSeries'
# Data sets are x,y pairs
data1 = ["17/6/72", 11, "11/1/72", 7, "13/4/04 17:31", 11, "11/9/01", 9,
"11/9/85", 2, "1/9/88", 1, "15/1/95", 13]
data2 = ["1/8/73", 18, "1/2/77", 15, "1/10/98", 4, "1/5/02", 14,
"1/3/95", 6, "1/8/91", 12, "1/12/87", 6, "1/5/84", 17, "1/10/80", 12]
title = "This is the title"
graph = SVG::Graph::TimeSeries.new( {
:width => 640,
:height => 480,
:graph_title => title,
:show_graph_title => true,
:no_css => true,
:key => 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",
:show_y_title => true,
:y_title => "Ice Cream Cones",
:y_title_text_direction => :bt,
:stagger_x_labels => true,
:x_label_format => "%d/%m/%y",
})
graph.add_data({
:data => data1,
:title => "Projected",
})
graph.add_data({
:data => data2,
:title => "Actual",
})

print graph.burn()
#==========================

#========output============
c:/ruby/lib/ruby/1.8/date/format.rb:236:in `dup': can't dup Fixnum
(TypeError)
from c:/ruby/lib/ruby/1.8/date/format.rb:236:in `_parse'
from c:/ruby/lib/ruby/1.8/parsedate.rb:9:in `parsedate'
from
c:/ruby/lib/ruby/site_ruby/1.8/SVG/Graph/TimeSeries.rb:176:in
`min_x_value='
from c:/ruby/lib/ruby/site_ruby/1.8/SVG/Graph/Graph.rb:358:in
`send'
from c:/ruby/lib/ruby/site_ruby/1.8/SVG/Graph/Graph.rb:358:in
`init_with'
from c:/ruby/lib/ruby/site_ruby/1.8/SVG/Graph/Graph.rb:357:in
`each'
from c:/ruby/lib/ruby/site_ruby/1.8/SVG/Graph/Graph.rb:357:in
`init_with'
from c:/ruby/lib/ruby/site_ruby/1.8/SVG/Graph/Graph.rb:155:in
`initialize'
from svg_time_series.rb:7:in `new'
from svg_time_series.rb:7
==========================

Any hints / tips / suggestions?

I've tried contacting the module author with no success so I was
wondering if it was anything obvious to you hardened Ruby folk.

Please help me avoid using Perl!!

Many thanks in advance,

SM

PS. Same results using ruby 1.8.2 from the one-click installer on WinXP
and Fedora Core 4 - test2. Both systems localised to en_GB.

------------------------------------------------------------------------------------------
Equinox Converged Solutions
Tel: +44 (0)1252 405 600
http://www.equinoxsolutions.com
Equinox Converged Solutions is a trading name of Synetrix Holdings Limited.

IMPORTANT NOTICE:
This message is intended solely for the use of the Individual or organisation to whom it is addressed. It may contain privileged or confidential information. If you have received this message in error, please notify the originator immediately.
If you are not the intended recipient, you should not use, copy, alter, or disclose the contents of this message. All information or opinions expressed in this message and/or any attachments are those of the author and are not necessarily those of Synetrix Holdings Limited.
Synetrix Holdings Limited accepts no responsibility for loss or damage arising from its use, including damage from virus.
-------------------------------------------------------------------------------------------
 
G

Gavin Kistner

Could this be a localisation issue? (I'm in the UK).

Yes, I believe so. I see you have:
data1 = ["17/6/72", 11, "11/1/72", 7, "13/4/04 17:31", 11, "11/9/01",
9,
"11/9/85", 2, "1/9/88", 1, "15/1/95", 13]

and then I see errors during the parsing. It appears that you have your
dates in dd/mm/yy format; Parsedate.parsedate requires 'mm/dd/yy' when
only that information is supplied.

See the table on page 733 of Pickaxe 2, or
http://phrogz.net/ProgrammingRuby/lib_standard.html#ParseDate
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,732
Latest member
ArronPalin

Latest Threads

Top