class Scruffy::Components::Grid
Attributes
markers[RW]
Public Instance Methods
draw(svg, bounds, options={})
click to toggle source
# File lib/scruffy/components/grid.rb, line 8 def draw(svg, bounds, options={}) markers = (options[:markers] || self.markers) || 5 stroke_width = options[:stroke_width] colour = options[:theme].grid || options[:theme].marker each_marker(markers, options[:min_value], options[:max_value], bounds[:height], options, :value_formatter) do |label, y| svg.line(:x1 => 0, :y1 => y, :x2 => bounds[:width], :y2 => y, :style => "stroke: #{colour.to_s}; stroke-width: #{stroke_width};") end #add a 0 line y = (options[:max_value] * bounds[:height])/(options[:max_value] - options[:min_value]) svg.line(:x1 => 0, :y1 => y, :x2 => bounds[:width], :y2 => y, :style => "stroke: #{colour.to_s}; stroke-width: #{stroke_width};") end