Sha256: 6284a6a3b867f8811c50ed1502d0786faf80503ee4f7f5292bc207155aaa110e
Contents?: true
Size: 1.94 KB
Versions: 1
Compression:
Stored size: 1.94 KB
Contents
$:.unshift(File.dirname(__FILE__)+'/../lib/') require 'statsample' require 'tmpdir' require 'tempfile' require 'tempfile' require 'fileutils' require 'test/unit' begin require 'statsample/graph/svggraph' class StatsampleSvgGraphTestCase < Test::Unit::TestCase def initialize(*args) @image_path=Dir::tmpdir+"/images" FileUtils.mkdir(@image_path) if !File.exists? @image_path super end def test_histogram if Statsample.has_gsl? ar=(1..1000).to_a.collect {|a| rand(10) }.to_vector(:scale) h=ar.histogram([0,2,5,11]) file=Tempfile.new("svg_histogram_only.svg") graph = Statsample::Graph::SvgHistogram.new({}) graph.histogram=h file.puts(graph.burn) else puts "Statsample::Graph::SvgHistogram.new not tested (no ruby-gsl)" end end def test_vector file=@image_path+"/gdchart_bar.jpg" ar=[] (1..1000).each {|a| ar.push(rand(10)) } vector=ar.to_vector file=Tempfile.new("svggraph_default.svg").path vector.svggraph_frequencies(file) file=Tempfile.new("svggraph_bar.svg").path vector.svggraph_frequencies(file,800,600,SVG::Graph::Bar,:graph_title=>'Bar') assert(File.exists?(file)) file=Tempfile.new("svggraph_bar_horizontal.svg").path vector.svggraph_frequencies(file,800,600,SVG::Graph::BarHorizontalNoOp,:graph_title=>'Horizontal Bar') assert(File.exists?(file)) file=Tempfile.new("svggraph_pie.svg").path vector.svggraph_frequencies(file,800,600,SVG::Graph::PieNoOp,:graph_title=>'Pie') assert(File.exists?(file)) vector.type=:scale if Statsample.has_gsl? file=Tempfile.new("svg_histogram.svg").path hist=vector.svggraph_histogram(5) File.open(file,"wb") {|fp| fp.write(hist.burn) } assert(File.exists?(file)) else puts "Statsample::Vector#svggraph_histogram.new not tested (no ruby-gsl)" end end end rescue LoadError puts "You should install SVG::Graph" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
statsample-0.6.7 | test/test_svg_graph.rb |