Class: Plot::MarkProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/plot/mark.rb

Instance Method Summary collapse

Constructor Details

#initialize(mark, type) ⇒ MarkProxy

Returns a new instance of MarkProxy.



2
3
4
5
# File 'lib/plot/mark.rb', line 2

def initialize(mark, type)
    @mark = mark
    @mark.type = type
end

Instance Method Details

#channel(name, value, **obj) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/plot/mark.rb', line 7

def channel(name, value, **obj)
    # TODO: add checking if option is a channel

    if !obj.blank?
        obj[:value] = value
        @mark.add_option(name, obj)
    else
        @mark.add_option(name, value)
    end
end

#option(name, value, wrap: false) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/plot/mark.rb', line 18

def option(name, value, wrap: false)
    if(value.class == Proc || [:title, :href, :ariaLabel].include?(name)) then
        raise "A channel should be used in place of option"
    end

    if wrap then
        @mark.add_option(name, { value: value })
    else
        @mark.add_option(name, value )
    end
end

#style(name, value) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/plot/mark.rb', line 30

def style(name, value)
    if([:fill, 
        :fillOpacity, 
        :stroke, 
        :strokeWidth,
        :strokeOpacity,
        :strokeLinejoin,
        :strokeLinecap,
        :strokeMiterlimit,
        :strokeDasharray,
        :strokeDashoffset,
        :opacity,
        :mixBlendMode,
        :imageFilter,
        :shapeRendering,
        :paintOrder,
        :dx,
        :dy,
        :target,
        :ariaDescription,
        :ariaHidden,
        :pointerEvents,
        :clip,
        :tip].include? name) 
    then
        @mark.add_option(name, value) 
    else
        raise "Not a style option"
    end
end