Class: Plotrb::Transform

Inherits:
Object show all
Includes:
Base
Defined in:
lib/plotrb/transforms.rb

Overview

Data transform performs operations on a data set prior to

visualization.

See https://github.com/trifacta/vega/wiki/Data-Transforms

Constant Summary collapse

TYPES =

all available types of transforms defined by Vega

%i(array copy cross facet filter flatten fold formula slice sort
stats truncate unique window zip force geo geopath link pie stack
treemap wordcloud)

Instance Method Summary collapse

Methods included from Base

#add_attributes, #attributes, #classify, #collect_attributes, #define_boolean_attribute, #define_boolean_attributes, #define_multi_val_attribute, #define_multi_val_attributes, #define_single_val_attribute, #define_single_val_attributes, #defined_attributes, included, #set_attributes

Constructor Details

#initialize(type, &block) ⇒ Transform

Returns a new instance of Transform.



25
26
27
28
29
30
31
32
# File 'lib/plotrb/transforms.rb', line 25

def initialize(type, &block)
  @type = type
  @extra_fields = [:index, :data]
  self.send(@type)
  self.instance_eval(&block) if block_given?
  ::Plotrb::Kernel.transforms << self
  self
end

Instance Method Details

#extra_fieldsObject



38
39
40
# File 'lib/plotrb/transforms.rb', line 38

def extra_fields
  @extra_fields
end

#typeObject



34
35
36
# File 'lib/plotrb/transforms.rb', line 34

def type
  @type
end