Module: GoogleChart::Markers

Included in:
BarChart, LineChart, LineXYChart, RadarChart, ScatterPlot, SparklineChart
Defined in:
lib/google_chart/modules/markers.rb

Overview

This module is used as a mixin for providing shape markers, and horizontal and vertical range markers

Defined Under Namespace

Classes: RangeMarker, ShapeMarker

Constant Summary

ORIENTATION =
{:horizontal => "r", :vertical => "R" }
SHAPES =
{
   :arrow                => "a",
   :cross                => "c",
   :diamond              => "d",
   :circle               => "o",
   :square               => "s",
   :text                 => "t",
   :vertical_line_top    => "v",
   :vertical_line_bottom => "V",
   :horizontal_line      => "h",
   :x                    => "x"
}
PRIORITY =
{ :high => 1, :low => -1 }

Instance Method Summary collapse

Instance Method Details

#range_marker(orientation, options = {}) {|marker| ... } ⇒ Object

Yields:

  • (marker)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/google_chart/modules/markers.rb', line 41

def range_marker(orientation, options={})
  @markers ||= []
  marker = RangeMarker.new
  marker.orientation = orientation

  options.each { |k,v| marker.send("#{k}=",v) }
  yield marker if block_given?

  validate_range_marker(marker)

  values = [:orientation, :color, :start, :end].collect { |m| marker.send(m) }
  values[0] = ORIENTATION[marker.orientation]
  values.insert 2, "0"
  @markers << values.join(",")
end

#shape_marker(shape, options = {}) {|marker| ... } ⇒ Object

Yields:

  • (marker)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/google_chart/modules/markers.rb', line 25

def shape_marker(shape, options={})
  @markers ||= []
  marker = ShapeMarker.new
  marker.shape = shape

  options.each { |k,v| marker.send("#{k}=",v) }
  yield marker if block_given?

  validate_shape_marker(marker)
  values = [:shape, :color, :data_set, :data_point, :size, :priority].collect { |m| marker.send(m) }.compact
  values[0] = SHAPES[marker.shape]
  values[0] += (marker.text.gsub(" ","+")) if marker.shape == :text
  values[5] = PRIORITY[marker.priority] if values[5]
  @markers << values.join(",")
end