Class: Scruffy::Components::ValueMarkers

Inherits:
Base
  • Object
show all
Includes:
Helpers::Marker
Defined in:
lib/scruffy/components/value_markers.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.



7
8
9
# File 'lib/scruffy/components/value_markers.rb', line 7

def markers
  @markers
end

Instance Method Details

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



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/scruffy/components/value_markers.rb', line 9

def draw(svg, bounds, options={})
  markers = (options[:markers] || self.markers) || 5
  
  each_marker(markers, options[:min_value], options[:max_value], bounds[:height], options, :value_formatter) do |label, y|
    svg.text( label, 
      :x => bounds[:width], 
      :y => (bounds[:height] - y), 
      'font-size' => relative(8),
      'font-family' => options[:theme].font_family,
      :fill => ((options.delete(:marker_color_override) || options[:theme].marker) || 'white').to_s,
      'text-anchor' => 'end')
  end
end