Class: GnuplotRenderer::PlotHelper::Plotter
- Inherits:
-
Object
- Object
- GnuplotRenderer::PlotHelper::Plotter
- Defined in:
- lib/gitstats/renderer/gnuplot.rb
Instance Attribute Summary collapse
-
#plot ⇒ Object
readonly
Returns the value of attribute plot.
Instance Method Summary collapse
- #add_boxes(args = {}) {|x, l, y| ... } ⇒ Object
- #add_steps(args = {}) {|x, l, y| ... } ⇒ Object
-
#initialize(helper) ⇒ Plotter
constructor
A new instance of Plotter.
- #run ⇒ Object
Constructor Details
#initialize(helper) ⇒ Plotter
Returns a new instance of Plotter.
6 7 8 9 |
# File 'lib/gitstats/renderer/gnuplot.rb', line 6 def initialize(helper) @helper = helper @plot = nil end |
Instance Attribute Details
#plot ⇒ Object (readonly)
Returns the value of attribute plot.
4 5 6 |
# File 'lib/gitstats/renderer/gnuplot.rb', line 4 def plot @plot end |
Instance Method Details
#add_boxes(args = {}) {|x, l, y| ... } ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gitstats/renderer/gnuplot.rb', line 29 def add_boxes(args = {}) args = { :setrange => true, :limitlabels => true, :labelcount => 15 }.merge(args) x = Array.new l = Array.new y = Array.new yield x, l, y limitlabels(l, args[:labelcount]) if args[:limitlabels] @plot.xrange "[\"#{x.first - 1}\":\"#{x.last + 1}\"]" if args[:setrange] @plot.data << Gnuplot::DataSet.new([x, l, y]) do |ds| ds.using = '1:3:(0.5):xtic(2)' ds.with = 'boxes fs solid' ds.notitle end end |
#add_steps(args = {}) {|x, l, y| ... } ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/gitstats/renderer/gnuplot.rb', line 53 def add_steps(args = {}) args = { :setrange => true, :limitlabels => true, :labelcount => 15, :firstlabel => '""' }.merge(args) x = Array.new l = Array.new y = Array.new yield x, l, y limitlabels(l, args[:labelcount]) if args[:limitlabels] @plot.xrange "[\"#{x.first - 1}\":\"#{x.last + 1}\"]" if args[:setrange] unless args[:firstlabel].nil? x.insert(0, x.first - 1) l.insert(0, args[:firstlabel]) y.insert(0, 0) end @plot.data << Gnuplot::DataSet.new([x, l, y]) do |ds| ds.using = '1:3:xtic(2)' ds.with = 'steps' ds.notitle end end |
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gitstats/renderer/gnuplot.rb', line 11 def run Gnuplot.open do |gp| Gnuplot::Plot.new(gp) do |plot| @plot = plot plot.terminal 'png transparent size 640,240' plot.size '1.0,1.0' plot.output File.join(@helper.outdir, File.basename(@helper.filename, '.plot') + '.png') plot.nokey plot.xtics 'rotate' plot.ytics 'autofreq' plot.grid 'y' yield self end end end |