class GerbilCharts::Surfaces::Grid

Grid - grid overlay

Draws both x and y grids

Attributes

tick_count[R]

Public Class Methods

new(opts={}) click to toggle source
# File lib/gerbilcharts/surfaces/grid.rb, line 9
def initialize(opts={})
  super(opts)
      @tick_count = 5
end

Public Instance Methods

int_render(g) click to toggle source
# File lib/gerbilcharts/surfaces/grid.rb, line 14
    def int_render(g)
          ry = grid_range_y
          rx = grid_range_x

          # horizontal grid lines
          g.newwin('hgrid', {:class => "gridlineh"} ) do |g|
                          ry.each_label do |val,label|
                                  yp = scale_y val,ry
                                  g.line(@bounds.left,yp,@bounds.right,yp)
                          end
          end 

          # horiz subticks
#         g.newwin('hgridsub', {:class => "gridlinesub"} ) do |g|
#                         ry.each_tick(@tick_count)  do |val|
#                                 yp = scale_y val,ry
#                                 g.line(@bounds.left,yp,@bounds.right,yp)
#                         end
#         end

        
      scaling_x  = parent.get_global_option(:scaling_x,:auto)
      rwx = parent.modelgroup.effective_range_x(scaling_x)
          if scaling_x.is_a? Array
                rx = GerbilCharts::Models::RoundTimeRange.new(rwx)
      end

          # vertical subticks
          g.newwin('vgrid', {:class => "gridlinev"} ) do |g|
                          rx.each_label do |val,label|
                                  xp = scale_x val,rwx
                                  g.line(xp,@bounds.top,xp,@bounds.bottom)
                          end
          end


#         g.newwin('vgridsub', {:class => "gridlinesub"} ) do |g|
#                         rx.each_tick(0) do |val|
#                                 xp = scale_x val,rwx
#                                 g.line(xp,@bounds.top,xp,@bounds.bottom)
#                         end
#         end


    end

Protected Instance Methods

grid_range_x() click to toggle source
# File lib/gerbilcharts/surfaces/grid.rb, line 62
def grid_range_x
   return parent.modelgroup.effective_round_range_x
end
grid_range_y() click to toggle source
# File lib/gerbilcharts/surfaces/grid.rb, line 66
def grid_range_y
   return parent.modelgroup.effective_round_range_y0
end