Class: Scruffy::Components::Axes
- 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
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 15 16 17 18 19 |
# File 'lib/scruffy/components/axes.rb', line 6 def draw(svg, bounds, ={}) stroke_width = [:stroke_width] colour = [:theme].grid || [:theme].marker unless [:show_x] == false y = ([:max_value] * bounds[:height])/([:max_value] - [:min_value]) svg.line(:x1 => 0, :y1 => y, :x2 => bounds[:width], :y2 => y, :style => "stroke: #{colour.to_s}; stroke-width: #{stroke_width};") end unless [:show_y] == false x = -0.5 svg.line(:x1 => x, :y1 => 0, :x2 => x, :y2 => bounds[:height], :style => "stroke: #{colour.to_s}; stroke-width: #{stroke_width};") end end |