Class: Prawn::Graph::ChartComponents::SeriesRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/graph/chart_components/series_renderer.rb

Overview

The Prawn::Graph::ChartComponents::SeriesRenderer is used to plot indivdual Prawn::Graph::Series on a Prawn::Graph::ChartComponents::Canvas and its associated Prawn::Document.

Direct Known Subclasses

BarChartRenderer, LineChartRenderer

Instance Method Summary collapse

Constructor Details

#initialize(series, canvas, color = '000000') ⇒ SeriesRenderer

Returns a new instance of SeriesRenderer.

Parameters:

Raises:

  • (ArgumentError)

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/prawn/graph/chart_components/series_renderer.rb', line 12

def initialize(series, canvas, color = '000000')
  if series.is_a?(Array)
    raise ArgumentError.new("series must be a Prawn::Graph::Series") unless series.first.is_a?(Prawn::Graph::Series)
  else
    raise ArgumentError.new("series must be a Prawn::Graph::Series") unless series.is_a?(Prawn::Graph::Series)
  end
  raise ArgumentError.new("canvas must be a Prawn::Graph::ChartComponents::Canvas") unless canvas.is_a?(Prawn::Graph::ChartComponents::Canvas)

  @series = series
  @canvas = canvas
  @prawn = canvas.prawn
  @color = color

  @graph_area = @canvas.layout.graph_area

  @plot_area_width  = @graph_area.width - 25
  @plot_area_height = @graph_area.height - 20
end

Instance Method Details

#renderObject


31
32
33
# File 'lib/prawn/graph/chart_components/series_renderer.rb', line 31

def render
  render_chart
end