我正在尝试使用pgsql连接编写svg图。我在将数据写入svg时遇到问题。我已经使用了svggraph中的文档来获取时间序列图。
require 'svggraph'
graph = SVG::Graph::TimeSeries.new(
{
:width => 640,
:height => 480,
:graph_title => "Tweets per Day",
: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 => "Tweets",
:y_title_text_direction => :bt,
:stagger_x_labels => true,
:x_label_format => "%y-%m-%d",
})
graph.add_data({
:data => data1,
:title => 'Test'})
File.open('timeseriesgraph.svg','w'){File.write(graph.burn)}
目前它正在写一份空白文件。 (我在记事本++中检查过它。)
这是错误字符串。
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/svg-graph-2.0.1/lib/SVG/Graph/Plot.rb:250:in `<': comparison of String with 0 failed (ArgumentError)
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/svg-graph-2.0.1/lib/SVG/Graph/Plot.rb:250:in `min_y_range'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/svg-graph-2.0.1/lib/SVG/Graph/Plot.rb:256:in `y_range'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/svg-graph-2.0.1/lib/SVG/Graph/Plot.rb:272:in `get_y_values'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/svg-graph-2.0.1/lib/SVG/Graph/Graph.rb:410:in `calculate_left_margin'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/svg-graph-2.0.1/lib/SVG/Graph/Plot.rb:181:in `calculate_left_margin'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/svg-graph-2.0.1/lib/SVG/Graph/Graph.rb:951:in `calculate_graph_dimensions'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/svg-graph-2.0.1/lib/SVG/Graph/Graph.rb:203:in `burn'
from tweet_graph.rb:49:in `block in <main>'
from tweet_graph.rb:49:in `open'
from tweet_graph.rb:49:in `<main>