Class: Scruffy::Layers::SparklineBar

Inherits:
Base
  • Object
show all
Defined in:
lib/scruffy/layers/sparkline_bar.rb

Overview

Experimental, do not use.

Instance Attribute Summary

Attributes inherited from Base

#color, #complexity, #height, #max_value, #min_value, #opacity, #options, #points, #preferred_color, #relevant_data, #title, #width

Instance Method Summary collapse

Methods inherited from Base

#bottom_key, #bottom_value, #initialize, #legend_data, #relevant_data?, #render, #sum_values, #top_key, #top_value

Constructor Details

This class inherits a constructor from Scruffy::Layers::Base

Instance Method Details

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



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/scruffy/layers/sparkline_bar.rb', line 6

def draw(svg, coords, options = {})
  zero_point = @height / 2.0

  coords.each do |coord|
    x, y, bar_height = (coord.first-(@bar_width * 0.5)), coord.last, (height - coord.last)

    bar_color = (y > zero_point) ? 'black' : 'red'
    bar_height = (bar_height - zero_point)
    
    #y = (bar_height < 0) ? 

    # svg.rect( :x => x, :y => zero_point, :width => @bar_width, :height => , 
    #           :fill => bar_color, :stroke => 'none', 'style' => "opacity: #{opacity}" )
  end
end