Class: D3::Axis
Overview
It might be better to rewrap the Scale every time, as we’re duplicating it
Instance Method Summary collapse
- #call(context) ⇒ Object
-
#initialize(native, scale_obj) ⇒ Axis
constructor
A new instance of Axis.
- #scale(v = `undefined`) ⇒ Object (also: #scale=)
- #tick_format(v = `undefined`, &block) ⇒ Object (also: #tick_format=)
- #tick_values(v = `undefined`) ⇒ Object (also: #tick_values=)
Methods included from Native
Constructor Details
#initialize(native, scale_obj) ⇒ Axis
Returns a new instance of Axis.
6 7 8 9 10 11 |
# File 'lib/opal/d3/axis.rb', line 6 def initialize(native, scale_obj) raise unless native raise unless scale_obj @scale_obj = scale_obj @native = native end |
Instance Method Details
#call(context) ⇒ Object
20 21 22 23 |
# File 'lib/opal/d3/axis.rb', line 20 def call(context) @native.call(context.to_n) self end |
#scale(v = `undefined`) ⇒ Object Also known as: scale=
25 26 27 28 29 30 31 32 33 |
# File 'lib/opal/d3/axis.rb', line 25 def scale(v=`undefined`) if `v === undefined` @scale_obj else @scale_obj = v @native.JS.scale(v.to_n) self end end |
#tick_format(v = `undefined`, &block) ⇒ Object Also known as: tick_format=
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/opal/d3/axis.rb', line 47 def tick_format(v=`undefined`, &block) v = block if block_given? if `v === undefined` result = @native.JS.tickFormat `result === null ? nil : result` else @native.JS.tickFormat(v == nil ? `null` : v) self end end |
#tick_values(v = `undefined`) ⇒ Object Also known as: tick_values=
36 37 38 39 40 41 42 43 44 |
# File 'lib/opal/d3/axis.rb', line 36 def tick_values(v=`undefined`) if `v === undefined` result = @native.JS.tickValues `result === null ? nil : result` else @native.JS.tickValues(v == nil ? `null` : v) self end end |