Class: RVGP::Plot::Gnuplot::AreaChart

Inherits:
ChartBuilder show all
Defined in:
lib/rvgp/plot/gnuplot.rb

Overview

This Chart element contains the logic necessary to render Integrals (shaded areas, under a line), onto the plot canvas.

Constant Summary

Constants inherited from ChartBuilder

ChartBuilder::ONE_MONTH_IN_SECONDS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ChartBuilder

#format_num, #series_range

Constructor Details

#initialize(opts, gnuplot) ⇒ AreaChart

Create a chart

Parameters:

Options Hash (opts):

  • :domain (Symbol)

    This option specifies the ‘type’ of the domain. Currently, the only supported type is :monthly

  • :xrange_start (Integer, Date)

    The plot domain origin, either the number 1, or a date

  • :xrange_end (Date)

    The end of the plot domain

  • :axis (Hash<Symbol, String>)

    Axis labels. At the moment, :bottom and :left are supported keys.

  • :is_stacked (TrueClass, FalseClass)

    Whether the series on this chart are offset from the origin, or are offset from each other (aka ‘stacked on top of each other’)



170
171
172
173
174
# File 'lib/rvgp/plot/gnuplot.rb', line 170

def initialize(opts, gnuplot)
  super opts, gnuplot
  @reverse_series_range = opts[:is_stacked]
  reverse_series_colors! if reverse_series_range?
end

Class Method Details

.typesArray<String>

The chart types we support, intended for use in the chart_type parameter of your plot yaml. This class supports: ‘area’

Returns:

  • (Array<String>)

    Supported chart types.



187
188
189
# File 'lib/rvgp/plot/gnuplot.rb', line 187

def self.types
  %w[area]
end

Instance Method Details

#series(_) ⇒ Hash<Symbol, Object>

The gnuplot data specifier components, for series n

Parameters:

  • _ (Integer)

    Series number

Returns:

  • (Hash<Symbol, Object>)

    :using and :with strings, for use by gnuplot



179
180
181
182
# File 'lib/rvgp/plot/gnuplot.rb', line 179

def series(_)
  { using: [1, using_data],
    with: "filledcurves x1 fillcolor '%<rgb>s'" }
end