Class: Scruffy::Components::DataMarkers

Inherits:
Base
  • Object
show all
Defined in:
lib/scruffy/components/data_markers.rb

Instance Attribute Summary

Attributes inherited from Base

#id, #options, #position, #size, #visible

Instance Method Summary collapse

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
20
21
# File 'lib/scruffy/components/data_markers.rb', line 6

def draw(svg, bounds, options={})
  unless options[:point_markers].nil?
    point_distance = bounds[:width] / (options[:point_markers].size - 1).to_f
    
    (0...options[:point_markers].size).map do |idx| 
      x_coord = point_distance * idx
      svg.text(options[:point_markers][idx],
        :x => x_coord,
        :y => bounds[:height], 
        'font-size' => relative(90),
        'font-family' => options[:theme].font_family,
        :fill => (options[:theme].marker || 'white').to_s, 
        'text-anchor' => 'middle') unless options[:point_markers][idx].nil?
    end
  end
end