Module: GoogleChart::Axis

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

Overview

This module is used as a mixin for providing axis

Defined Under Namespace

Classes: Axis

Constant Summary

AXIS_TYPE_MAPPING =
{ :top => "t", :bottom => "x", :left => "y", :right => "r" }
ALIGNMENT_MAPPING =
{ :center => 0, :left => -1, :right => -1}

Instance Method Summary (collapse)

Instance Method Details

- (Object) axis(type, options = {}) {|axis| ... }

Yields:

  • (axis)

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/google_chart/modules/axis.rb', line 10

def axis(type, options={})
  @axes ||= []
  raise ArgumentError.new("Axis type must be :top, :bottom, :left or :right") unless AXIS_TYPE_MAPPING.keys.include?(type)
  axis = Axis.new
  axis.type = type

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

  validate_axis(axis)
  @axes << axis
end