Module: Squid::Interface

Defined in:
lib/squid.rb

Overview

Provides the `chart` method to use in Prawn::Document

Instance Method Summary collapse

Instance Method Details

#chart(data = {}, settings = {}) ⇒ Object

Plots a graph the current document.

Parameters:

  • data (Hash<#to_s, [Hash<#to_s, Numeric>]>) (defaults to: {})

    the series to plot in the graph. Each key is the name of the series, and each value contains the values for the series. Values are also a hash, where each key is a category, and each value the numerical value for that category.

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

    the option to customize the graph.

Options Hash (settings):

  • :baseline (Boolean) — default: true

    whether to plot the baseline.

  • :border (Boolean) — default: false

    whether to plot the border.

  • :chart (Boolean) — default: true

    whether to plot the chart.

  • :colors (Array<String>) — default: true

    the color of each series.

  • :every (Integer) — default: 1

    how often to plot the categories.

  • :format (Symbol) — default: :integer

    the format of axis values.

  • :height (Numeric) — default: 250

    the full height of the graph.

  • :labels (Boolean) — default: false

    whether to plot value labels.

  • :legend (<Boolean, Hash>) — default: true

    whether to plot the legend. If a Hash is provided, the `:offset` option can be set to specify the offset between the legend and the right margin.

  • :line_width (Numeric) — default: 3

    the line width for line graphs.

  • :steps (Numeric) — default: 4

    the number of gridlines.

  • :ticks (Boolean) — default: true

    whether to plot the ticks.

  • :type (Symbol) — default: :column

    the type of graph.


30
31
32
# File 'lib/squid.rb', line 30

def chart(data =  {}, settings = {})
  Graph.new(self, data, settings).draw
end