Class: GoogleChart::VennDiagram

Inherits:
Base
  • Object
show all
Defined in:
lib/google_chart/venn_diagram.rb

Overview

Generates a Venn Diagram.

Supply three vd.data statements of label, size, color for circles A, B, C. Then, intersections with four values:

  • the first value specifies the area of A intersecting B

  • the second value specifies the area of B intersecting C

  • the third value specifies the area of C intersecting A

  • the fourth value specifies the area of A intersecting B intersecting C

    vd = GoogleChart::VennDiagram.new("320x200", 'Venn Diagram') 
    vd.data "Blue", 100, '0000ff'
    vd.data "Green", 80, '00ff00'
    vd.data "Red",   60, 'ff0000'
    vd.intersections 30,30,30,10
    puts vd.to_url
    

Constant Summary

Constants inherited from Base

Base::BASE_URL, Base::COMPLEX_ENCODING_ALPHABET, Base::DEFAULT_LINE_STYLE, Base::SHAPE_MARKERS, Base::SIMPLE_ENCODING

Instance Attribute Summary

Attributes inherited from Base

#chart_size, #chart_title, #chart_type, #data_encoding, #params, #show_legend, #title_color, #title_font_size

Instance Method Summary collapse

Methods inherited from Base

#axis, #data, #fill, #fill_area, #grid, #max_value, #range_marker, #shape_marker, #to_escaped_url, #to_url

Constructor Details

#initialize(chart_size = '300x200', chart_title = nil) {|_self| ... } ⇒ VennDiagram

Initializes the Venn Diagram with a chart_size (in WIDTHxHEIGHT format) and a chart_title

Yields:

  • (_self)

Yield Parameters:



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

def initialize(chart_size='300x200', chart_title=nil) # :yield: self
    super(chart_size, chart_title)
    self.chart_type = :v
    @intersections = []
    yield self if block_given? 
end

Instance Method Details

#intersections(*values) ⇒ Object

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



32
33
34
# File 'lib/google_chart/venn_diagram.rb', line 32

def intersections(*values)            
  @intersections = values
end

#process_dataObject



27
28
29
# File 'lib/google_chart/venn_diagram.rb', line 27

def process_data          
  encode_data(@data + @intersections)
end