Class: GoogleChart::VennDiagram

Inherits:
Base
  • Object
show all
Includes:
Color, DataArray, Fills, Legend
Defined in:
lib/google_chart/venn_diagram.rb

Constant Summary

Constant Summary

Constants included from Fills

Fills::FILL_KINDS, Fills::FILL_TYPES, Fills::FILL_TYPES_SOLID, Fills::FILL_TYPE_CODES

Instance Attribute Summary

Attributes inherited from Base

#encoding, #height, #title, #title_color, #title_font_size, #width

Instance Method Summary collapse

Methods included from DataArray

included

Methods included from Fills

#fill

Methods included from Legend

included

Methods inherited from Base

inherited, #query_params, #size, #size=, #to_url

Constructor Details

#initialize(options = {}) ⇒ VennDiagram



11
12
13
14
15
16
# File 'lib/google_chart/venn_diagram.rb', line 11

def initialize(options={})
  @chart_type="v"
  @show_legend = false
  @intersections = []
  super(options)
end

Instance Method Details

#data(legend, data, color = nil) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
# File 'lib/google_chart/venn_diagram.rb', line 27

def data(legend, data, color = nil)
  raise ArgumentError.new("data should be an integer value") unless data.is_a?(Integer)
  raise ArgumentError.new("you can only insert upto 3 data points") if @data.size == 3
  @data << data
  legend(legend)
  color(color)
end

#intersections(*values) ⇒ Object

Specify the intersections of the circles in the Venn Diagram. See the Rdoc for class for sample

Raises:

  • (ArgumentError)


19
20
21
22
23
24
25
# File 'lib/google_chart/venn_diagram.rb', line 19

def intersections(*values)
  raise ArgumentError.new("Please intialise the data first before adding intersections") if @data.empty?
  raise ArgumentError.new("You can have at most three intersections") if values.size > 4
  raise ArgumentError.new("You cannot have more intersections than data points") if values.size > (@data.size + 1)
  raise ArgumentError.new("all values must be integers") unless values.all? { |v| v.is_a?(Integer) }
  @intersections = values
end