Class: Chart::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/chart/base.rb

Direct Known Subclasses

Bar, GroupedBar, Line, Pie

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Initialize a new chart object. Specify the chart attributes by providing a hash.



90
91
92
93
94
# File 'lib/chart/base.rb', line 90

def initialize(options={})
  defaults!
  options.each {|name, value| send("#{name}=", value)}
  instantiate
end

Instance Attribute Details

#angleObject

Set the angle



77
78
79
# File 'lib/chart/base.rb', line 77

def angle
  @angle
end

#colorsObject

Set bar colors



47
48
49
# File 'lib/chart/base.rb', line 47

def colors
  @colors
end

#dataObject

Set the chart data



38
39
40
# File 'lib/chart/base.rb', line 38

def data
  @data
end

#extra_fieldsObject

Set extra fields for labels



80
81
82
# File 'lib/chart/base.rb', line 80

def extra_fields
  @extra_fields
end

#heightObject

Set the chart height



29
30
31
# File 'lib/chart/base.rb', line 29

def height
  @height
end

#insideObject

Display label value inside bars (true|false)



83
84
85
# File 'lib/chart/base.rb', line 83

def inside
  @inside
end

#label_formatObject

Set label format



62
63
64
# File 'lib/chart/base.rb', line 62

def label_format
  @label_format
end

#labelsObject

Labels attribute reader



108
109
110
# File 'lib/chart/base.rb', line 108

def labels
  @labels
end

#legendObject

Legend attribute reader



113
114
115
# File 'lib/chart/base.rb', line 113

def legend
  @legend
end

#line_widthObject

Set line width



71
72
73
# File 'lib/chart/base.rb', line 71

def line_width
  @line_width
end

#marginsObject

Set the chart left-top margins



44
45
46
# File 'lib/chart/base.rb', line 44

def margins
  @margins
end

#multicolorObject

Set if bar is multicolor



50
51
52
# File 'lib/chart/base.rb', line 50

def multicolor
  @multicolor
end

#objectObject

The ChartDirector object



86
87
88
# File 'lib/chart/base.rb', line 86

def object
  @object
end

#plot_areaObject

Set the plot area



41
42
43
# File 'lib/chart/base.rb', line 41

def plot_area
  @plot_area
end

#plot_top_marginObject

Set plot top margin



53
54
55
# File 'lib/chart/base.rb', line 53

def plot_top_margin
  @plot_top_margin
end

#positionObject

Set position



56
57
58
# File 'lib/chart/base.rb', line 56

def position
  @position
end

#radiusObject

Set radius



59
60
61
# File 'lib/chart/base.rb', line 59

def radius
  @radius
end

#styleObject

Set style



65
66
67
# File 'lib/chart/base.rb', line 65

def style
  @style
end

#symbolsObject

Set line symbols



74
75
76
# File 'lib/chart/base.rb', line 74

def symbols
  @symbols
end

#widthObject

Set width



26
27
28
# File 'lib/chart/base.rb', line 26

def width
  @width
end

Instance Method Details

#helperObject

Wrapper to the ActionView helpers



103
104
105
# File 'lib/chart/base.rb', line 103

def helper
  Helper.instance
end

#write(path) ⇒ Object

Save the chart image to the specified path



97
98
99
100
# File 'lib/chart/base.rb', line 97

def write(path)
  generate
  @object.makeChart(path)
end