Class: Integral::ChartRenderer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/integral/chart_renderer/base.rb

Overview

Base class which all Charts should inherit from

Direct Known Subclasses

Donut, Line

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dataset, options = {}) ⇒ Base

Returns a new instance of Base.

Parameters:

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


17
18
19
20
# File 'lib/integral/chart_renderer/base.rb', line 17

def initialize(dataset, options = {})
  @dataset = dataset
  @options = options
end

Class Method Details

.render(dataset, options = {}) ⇒ Object

Render chart markup



10
11
12
13
# File 'lib/integral/chart_renderer/base.rb', line 10

def self.render(dataset, options = {})
  renderer = new(dataset, options)
  renderer.render
end

Instance Method Details

#renderObject

Render chart markup



23
24
25
26
27
28
29
# File 'lib/integral/chart_renderer/base.rb', line 23

def render
  data = process_data

  return respond_with_chart(data) if data_available?(data)

  respond_with_no_data_available
end