From f4980c2574cab4488bf00d3f3f66c6faf6589187 Mon Sep 17 00:00:00 2001 From: Yuri Pirola Date: Fri, 3 Jan 2014 06:15:38 +0100 Subject: [PATCH] Enlarge the x scale in order to visualize all the labels of the features (see issue danmaclean/bioruby-svgenes#4). --- lib/bio/graphics/page.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/bio/graphics/page.rb b/lib/bio/graphics/page.rb index 9153f46..93b1148 100644 --- a/lib/bio/graphics/page.rb +++ b/lib/bio/graphics/page.rb @@ -227,6 +227,18 @@ def get_limits @scale_stop = highest if highest > @scale_stop @nt_per_px_x = (@scale_stop - @scale_start).to_f / @width.to_f end + begin + old_nt_per_px_x = @nt_per_px_x + @tracks.each do |track| + highest = track.features.map { |feat| + feat_end = feat.end + feat_end += (8 * @nt_per_px_x * feat.id.to_s.length).to_i if feat.id + feat_end + }.max + @scale_stop = highest if highest > @scale_stop + @nt_per_px_x = (@scale_stop - @scale_start).to_f / @width.to_f + end + end while (@nt_per_px_x - old_nt_per_px_x).abs > 1 end #Adds scale bar to the list of objects to be rendered in the final