Module: Prawn::Graph::Extension

Defined in:
lib/prawn/graph/extension.rb

Instance Method Summary collapse

Instance Method Details

#graph(series, options = {}, &block) ⇒ Object Also known as: chart

Plots one or more Prawn::Graph::Series on a chart. Expects an array-like object of Prawn::Graph::Series objects and some options for positioning the sizing the rendered graph

Parameters:

  • series (Array)

    of Prawn::Graph::Series objects

  • options (Hash) (defaults to: {})

    of options, which can be: `:width` - The overall width of the graph to be drawn. `<Integer>` `:height` - The overall height of the graph to be drawn. `<Integer>` `:at` - The point from where the graph will be drawn. `[<Integer>x, <Integer>y]` `:title` - The title for this chart. Must be a string. `<String>` `:series_key` - Should we render the key to series in this chart? `<Boolean>` `:theme ` - An instance of the theme to be used for styling this graph. `<Prawn::Graph::Theme>`


18
19
20
21
22
# File 'lib/prawn/graph/extension.rb', line 18

def graph(series, options = {}, &block)
  canvas = Prawn::Graph::ChartComponents::Canvas.new(series, self, options, &block)
  canvas.draw
  {warnings: [], width: self.bounds.width, height: self.bounds.height}
end