Class: Scruffy::Components::VGrid

Inherits:
Base
  • Object
show all
Includes:
Helpers::Marker
Defined in:
lib/scruffy/components/grid.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#id, #options, #position, #size, #visible

Instance Method Summary collapse

Methods included from Helpers::Marker

#each_marker

Methods inherited from Base

#initialize, #process, #render

Constructor Details

This class inherits a constructor from Scruffy::Components::Base

Instance Attribute Details

#markersObject

Returns the value of attribute markers.



20
21
22
# File 'lib/scruffy/components/grid.rb', line 20

def markers
  @markers
end

Instance Method Details

#draw(svg, bounds, options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/scruffy/components/grid.rb', line 24

def draw(svg, bounds, options={})
  markers = (options[:key_markers] || self.markers) || 5
  
  stroke_width = options[:stroke_width]
  
  each_marker(markers, options[:min_key], options[:max_key], bounds[:width], options, :key_formatter) do |label, x|
    svg.line(:x1 => x, :y1 => 0, :x2 => x, :y2 => bounds[:height], :style => "stroke: #{options[:theme].marker.to_s}; stroke-width: #{stroke_width};")
  end
end