Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # No errors. Works fine, output is correct.
- require 'rubyvis'
- dat = pv.range(0, 10, 0.1).map {|x|
- o = {:x=> x, :y=> Math.sin(x) + 2+rand()}
- STDERR.puts o.inspect
- o
- }
- STDERR.puts "size of dat: #{dat.size}"
- STDERR.puts "first x = #{dat.first[:x]}"
- STDERR.puts "first y = #{dat.first[:y]}"
- #dat.each do |d|
- # STDERR.puts [d.x,d.y].join("\t")
- #end
- #p data
- w = 400
- h = 200
- x = pv.Scale.linear(dat, lambda {|d| d[:x]}).range(0, w)
- y = pv.Scale.linear(dat, lambda {|d| d[:y]}).range(0, h)
- STDERR.puts "after scale"
- #/* The root panel. */
- vis = pv.Panel.new()
- .width(w)
- .height(h)
- .bottom(20)
- .left(20)
- .right(10)
- .top(5)
- STDERR.puts "a"
- vis.add(pv.Line).
- data(dat).
- line_width(5).
- left(lambda {|d| x.scale(d[:x])}).
- bottom(lambda {|d| y.scale(d[:y])}).
- anchor("bottom").add(pv.Line).
- stroke_style('red').
- line_width(1)
- STDERR.puts "b"
- vis
Add Comment
Please, Sign In to add comment