Class: Scruffy::Components::Axes

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

Instance Attribute Summary

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 Method Details

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



6
7
8
9
10
11
12
13
14
# File 'lib/scruffy/components/axes.rb', line 6

def draw(svg, bounds, options={})
  stroke_width = options[:stroke_width]
  
  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: #{options[:theme].marker.to_s}; stroke-width: #{stroke_width};")
  
  x = -0.5
  svg.line(:x1 => x, :y1 => 0, :x2 => x, :y2 => bounds[:height], :style => "stroke: #{options[:theme].marker.to_s}; stroke-width: #{stroke_width};")
end