Class: Scruffy::Components::VGrid
- Includes:
- Helpers::Marker
- Defined in:
- lib/scruffy/components/grid.rb
Instance Attribute Summary collapse
-
#markers ⇒ Object
Returns the value of attribute markers.
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 Attribute Details
#markers ⇒ Object
Returns the value of attribute markers.
25 26 27 |
# File 'lib/scruffy/components/grid.rb', line 25 def markers @markers end |
Instance Method Details
#draw(svg, bounds, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/scruffy/components/grid.rb', line 29 def draw(svg, bounds, ={}) if [:graph].point_markers #get vertical grid lines up with points if there are labels for them point_distance = bounds[:width] / ([:graph].point_markers.size).to_f stroke_width = [:stroke_width] (0...[:graph].point_markers.size).map do |idx| x = point_distance * idx + point_distance/2 svg.line(:x1 => x, :y1 => 0, :x2 => x, :y2 => bounds[:height], :style => "stroke: #{[:theme].marker.to_s}; stroke-width: #{stroke_width};") end #add the far right and far left lines svg.line(:x1 => 0, :y1 => 0, :x2 => 0, :y2 => bounds[:height], :style => "stroke: #{[:theme].marker.to_s}; stroke-width: #{stroke_width};") svg.line(:x1 => bounds[:width], :y1 => 0, :x2 => bounds[:width], :y2 => bounds[:height], :style => "stroke: #{[:theme].marker.to_s}; stroke-width: #{stroke_width};") else markers = ([:key_markers] || self.markers) || 5 #options[:point_markers].size# stroke_width = [:stroke_width] each_marker(markers, [:min_key], [:max_key], bounds[:width], , :key_formatter) do |label, x| svg.line(:x1 => x, :y1 => 0, :x2 => x, :y2 => bounds[:height], :style => "stroke: #{[:theme].marker.to_s}; stroke-width: #{stroke_width};") end end end |