Sha256: d9963a38d6150467cf7e2cce0919d49f715132378b0be2f62c07e7ee56f3e07d
Contents?: true
Size: 817 Bytes
Versions: 2
Compression:
Stored size: 817 Bytes
Contents
# = Line Chart # This line chart is constructed a Line mark. # The second line, inside the first one, is created using an anchor. $:.unshift(File.dirname(__FILE__)+"/../lib") require 'rubyvis' data = pv.range(0, 10, 0.1).map {|x| OpenStruct.new({:x=> x, :y=> Math.sin(x) + 2+rand()}) } #p data w = 400 h = 200 x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, w) y = pv.Scale.linear(data, lambda {|d| d.y}).range(0, h); #/* The root panel. */ vis = pv.Panel.new() .width(w) .height(h) .bottom(20) .left(20) .right(10) .top(5) #/* The area with top line. */ vis.add(pv.Line). data(data). 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) vis.render(); puts vis.to_svg
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubyvis-0.1.7 | examples/line.rb |
rubyvis-0.1.6 | examples/line.rb |