Class: DataPoint
- Inherits:
-
Object
- Object
- DataPoint
- Defined in:
- lib/SVG/Graph/DataPoint.rb
Overview
Allows to customize datapoint shapes
Constant Summary collapse
- OVERLAY =
"OVERLAY"
- DEFAULT_SHAPE =
lambda{|x,y,line| ["circle", { "cx" => x, "cy" => y, "r" => "2.5", "class" => "dataPoint#{line}" }] }
- CRITERIA =
[]
Class Method Summary collapse
-
.configure_shape_criteria(*matchers) ⇒ Object
matchers are class scope.
- .reset_shape_criteria ⇒ Object
Instance Method Summary collapse
-
#initialize(x, y, line) ⇒ DataPoint
constructor
creates a new DataPoint.
-
#shape(description = nil) ⇒ Array<Array>
See example.
Constructor Details
#initialize(x, y, line) ⇒ DataPoint
creates a new DataPoint
41 42 43 44 45 |
# File 'lib/SVG/Graph/DataPoint.rb', line 41 def initialize(x, y, line) @x = x @y = y @line = line end |
Class Method Details
Instance Method Details
#shape(description = nil) ⇒ Array<Array>
Returns see example.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/SVG/Graph/DataPoint.rb', line 56 def shape(description=nil) # select all criteria with size 2, and collect rendered lambdas in an array shapes = CRITERIA.select {|criteria| criteria.size == 2 }.collect {|regexp, proc| proc.call(@x, @y, @line) if description =~ regexp }.compact # if above did not render anything use the defalt shape shapes = [DEFAULT_SHAPE.call(@x, @y, @line)] if shapes.empty? = CRITERIA.select { |criteria| criteria.last == OVERLAY }.collect { |regexp, proc| proc.call(@x, @y, @line) if description =~ regexp }.compact return shapes + end |