Class: RubyvisCharts::AbstractChart

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyvis_charts/abstract_chart.rb

Direct Known Subclasses

AbstractTimelineChart, DonutChart

Defined Under Namespace

Modules: DefaultArguments

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values:, width: DefaultArguments::WIDTH, height: DefaultArguments::HEIGHT, padding: DefaultArguments::PADDING) ⇒ AbstractChart

Returns a new instance of AbstractChart.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubyvis_charts/abstract_chart.rb', line 15

def initialize(
  values:,
  width: DefaultArguments::WIDTH,
  height: DefaultArguments::HEIGHT,
  padding: DefaultArguments::PADDING
)
  @values = values
  @width = width
  @height = height
  @padding = padding

  @inner_box_width = width - padding.left - padding.right
  @inner_box_height = height - padding.top - padding.bottom

  initialize_parent_layer!
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



11
12
13
# File 'lib/rubyvis_charts/abstract_chart.rb', line 11

def height
  @height
end

#inner_box_heightObject (readonly)

Returns the value of attribute inner_box_height.



11
12
13
# File 'lib/rubyvis_charts/abstract_chart.rb', line 11

def inner_box_height
  @inner_box_height
end

#inner_box_widthObject (readonly)

Returns the value of attribute inner_box_width.



11
12
13
# File 'lib/rubyvis_charts/abstract_chart.rb', line 11

def inner_box_width
  @inner_box_width
end

#paddingObject (readonly)

Returns the value of attribute padding.



11
12
13
# File 'lib/rubyvis_charts/abstract_chart.rb', line 11

def padding
  @padding
end

#parent_layerObject (readonly)

Returns the value of attribute parent_layer.



11
12
13
# File 'lib/rubyvis_charts/abstract_chart.rb', line 11

def parent_layer
  @parent_layer
end

#valuesObject (readonly)

Returns the value of attribute values.



11
12
13
# File 'lib/rubyvis_charts/abstract_chart.rb', line 11

def values
  @values
end

#widthObject (readonly)

Returns the value of attribute width.



11
12
13
# File 'lib/rubyvis_charts/abstract_chart.rb', line 11

def width
  @width
end

Instance Method Details

#renderObject



32
33
34
35
# File 'lib/rubyvis_charts/abstract_chart.rb', line 32

def render
  @parent_layer.render
  @parent_layer.to_svg
end