Class: Charty::Plotters::ColorMapper

Inherits:
BaseMapper show all
Defined in:
lib/charty/plotters/relational_plotter.rb

Instance Attribute Summary collapse

Attributes inherited from BaseMapper

#plotter

Instance Method Summary collapse

Methods inherited from BaseMapper

#[], #initialize

Constructor Details

This class inherits a constructor from Charty::Plotters::BaseMapper

Instance Attribute Details

#levelsObject (readonly)

Returns the value of attribute levels.



193
194
195
# File 'lib/charty/plotters/relational_plotter.rb', line 193

def levels
  @levels
end

#lookup_tableObject (readonly)

Returns the value of attribute lookup_table.



193
194
195
# File 'lib/charty/plotters/relational_plotter.rb', line 193

def lookup_table
  @lookup_table
end

#map_typeObject (readonly)

Returns the value of attribute map_type.



193
194
195
# File 'lib/charty/plotters/relational_plotter.rb', line 193

def map_type
  @map_type
end

#normObject (readonly)

Returns the value of attribute norm.



193
194
195
# File 'lib/charty/plotters/relational_plotter.rb', line 193

def norm
  @norm
end

#paletteObject (readonly)

Returns the value of attribute palette.



193
194
195
# File 'lib/charty/plotters/relational_plotter.rb', line 193

def palette
  @palette
end

Instance Method Details

#inverse_lookup_tableObject



195
196
197
# File 'lib/charty/plotters/relational_plotter.rb', line 195

def inverse_lookup_table
  lookup_table.invert
end

#lookup_single_value(key) ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/charty/plotters/relational_plotter.rb', line 199

def lookup_single_value(key)
  if @lookup_table.key?(key)
    @lookup_table[key]
  elsif @norm
    # Use the colormap to interpolate between existing datapoints
    begin
      normed = @norm.(key)
      @cmap[normed]
    rescue ArgumentError, TypeError => err
      if Util.nan?(key)
        return "#000000"
      else
        raise err
      end
    end
  end
end