Module: D3
- Defined in:
- lib/opal/d3/search.rb,
lib/opal/d3.rb,
lib/opal/d3/arc.rb,
lib/opal/d3/dsv.rb,
lib/opal/d3/map.rb,
lib/opal/d3/pie.rb,
lib/opal/d3/set.rb,
lib/opal/d3/area.rb,
lib/opal/d3/axis.rb,
lib/opal/d3/ease.rb,
lib/opal/d3/line.rb,
lib/opal/d3/misc.rb,
lib/opal/d3/nest.rb,
lib/opal/d3/path.rb,
lib/opal/d3/color.rb,
lib/opal/d3/curve.rb,
lib/opal/d3/stack.rb,
lib/opal/d3/format.rb,
lib/opal/d3/native.rb,
lib/opal/d3/random.rb,
lib/opal/d3/symbol.rb,
lib/opal/d3/creator.rb,
lib/opal/d3/polygon.rb,
lib/opal/d3/quadtree.rb,
lib/opal/d3/selection.rb,
lib/opal/d3/band_scale.rb,
lib/opal/d3/histograms.rb,
lib/opal/d3/statistics.rb,
lib/opal/d3/collections.rb,
lib/opal/d3/interpolate.rb,
lib/opal/d3/point_scale.rb,
lib/opal/d3/radial_area.rb,
lib/opal/d3/radial_line.rb,
lib/opal/d3/time_format.rb,
lib/opal/d3/ordinal_scale.rb,
lib/opal/d3/time_interval.rb,
lib/opal/d3/quantile_scale.rb,
lib/opal/d3/quantize_scale.rb,
lib/opal/d3/threshold_scale.rb,
lib/opal/d3/transformations.rb,
lib/opal/d3/continuous_scale.rb,
lib/opal/d3/sequential_scale.rb
Overview
all these methods return indexes not values
Defined Under Namespace
Modules: Native Classes: ArcGenerator, AreaGenerator, Axis, BandScale, Bisector, Color, ContinuousScale, Creator, Curve, CurveBundle, CurveCardinal, CurveCatmullRom, DsvFormat, EaseBack, EaseElastic, EasePoly, FormatLocale, FormatSpecifier, Histogram, LineGenerator, LogScale, Map, Nest, OrdinalScale, Path, PieGenerator, PointScale, PowScale, Quad, QuadTree, QuantileScale, QuantizeScale, RadialAreaGenerator, RadialLineGenerator, Selection, SequentialScale, Set, StackGenerator, SymbolGenerator, SymbolType, ThresholdScale, TimeFormatLocale, TimeInterval
Class Method Summary collapse
- .arc ⇒ Object
- .area ⇒ Object
- .axis_bottom(scale) ⇒ Object
- .axis_left(scale) ⇒ Object
- .axis_right(scale) ⇒ Object
- .axis_top(scale) ⇒ Object
- .bisector(&block) ⇒ Object
- .color(description) ⇒ Object
- .creator(name) ⇒ Object
- .csv_format(rows, columns = `undefined`) ⇒ Object
- .csv_format_rows(rows) ⇒ Object
- .csv_parse(string, row = `undefined`, &block) ⇒ Object
- .csv_parse_rows(string, row = `undefined`, &block) ⇒ Object
- .cubehelix(*args) ⇒ Object
- .curve_basis ⇒ Object
- .curve_basis_closed ⇒ Object
- .curve_basis_open ⇒ Object
- .curve_bundle ⇒ Object
- .curve_cardinal ⇒ Object
- .curve_cardinal_closed ⇒ Object
- .curve_cardinal_open ⇒ Object
- .curve_catmull_rom ⇒ Object
- .curve_catmull_rom_closed ⇒ Object
- .curve_catmull_rom_open ⇒ Object
- .curve_linear ⇒ Object
- .curve_linear_closed ⇒ Object
- .curve_monotone_x ⇒ Object
- .curve_monotone_y ⇒ Object
- .curve_natural ⇒ Object
- .curve_step ⇒ Object
- .curve_step_after ⇒ Object
- .curve_step_before ⇒ Object
- .deviation(data, &block) ⇒ Object
- .dsv_format(separator) ⇒ Object
- .ease_back(t = nil) ⇒ Object
- .ease_back_in(t = nil) ⇒ Object
- .ease_back_in_out(t = nil) ⇒ Object
- .ease_back_out(t = nil) ⇒ Object
- .ease_bounce(t = nil) ⇒ Object
- .ease_bounce_in(t = nil) ⇒ Object
- .ease_bounce_in_out(t = nil) ⇒ Object
- .ease_bounce_out(t = nil) ⇒ Object
- .ease_circle(t = nil) ⇒ Object
- .ease_circle_in(t = nil) ⇒ Object
- .ease_circle_in_out(t = nil) ⇒ Object
- .ease_circle_out(t = nil) ⇒ Object
- .ease_cubic(t = nil) ⇒ Object
- .ease_cubic_in(t = nil) ⇒ Object
- .ease_cubic_in_out(t = nil) ⇒ Object
- .ease_cubic_out(t = nil) ⇒ Object
- .ease_elastic(t = nil) ⇒ Object
- .ease_elastic_in(t = nil) ⇒ Object
- .ease_elastic_in_out(t = nil) ⇒ Object
- .ease_elastic_out(t = nil) ⇒ Object
- .ease_exp(t = nil) ⇒ Object
- .ease_exp_in(t = nil) ⇒ Object
- .ease_exp_in_out(t = nil) ⇒ Object
- .ease_exp_out(t = nil) ⇒ Object
- .ease_linear(t = nil) ⇒ Object
- .ease_poly_in(t = nil) ⇒ Object
- .ease_poly_in_out(t = nil) ⇒ Object
- .ease_poly_out(t = nil) ⇒ Object
- .ease_quad(t = nil) ⇒ Object
- .ease_quad_in(t = nil) ⇒ Object
- .ease_quad_in_out(t = nil) ⇒ Object
- .ease_quad_out(t = nil) ⇒ Object
- .ease_sin(t = nil) ⇒ Object
- .ease_sin_in(t = nil) ⇒ Object
- .ease_sin_in_out(t = nil) ⇒ Object
- .ease_sin_out(t = nil) ⇒ Object
- .entries(obj) ⇒ Object
- .extent(data, &block) ⇒ Object
- .format(specifier) ⇒ Object
- .format_default_locale(spec = {}) ⇒ Object
- .format_locale(spec = {}) ⇒ Object
- .format_prefix(specifier, value) ⇒ Object
- .format_specifier(specifier) ⇒ Object
- .hcl(*args) ⇒ Object
- .histogram ⇒ Object
- .hsl(*args) ⇒ Object
- .interpolate_array(a = nil, b = nil) ⇒ Object
- .interpolate_cool(t = nil) ⇒ Object
- .interpolate_cubehelix(a = nil, b = nil) ⇒ Object
- .interpolate_cubehelix_default(t = nil) ⇒ Object
- .interpolate_cubehelix_long(a = nil, b = nil) ⇒ Object
- .interpolate_date(a = nil, b = nil) ⇒ Object
- .interpolate_hcl(a = nil, b = nil) ⇒ Object
- .interpolate_hcl_long(a = nil, b = nil) ⇒ Object
- .interpolate_hsl(a = nil, b = nil) ⇒ Object
- .interpolate_hsl_long(a = nil, b = nil) ⇒ Object
- .interpolate_inferno(t = nil) ⇒ Object
- .interpolate_lab(a = nil, b = nil) ⇒ Object
- .interpolate_magma(t = nil) ⇒ Object
- .interpolate_number(a = nil, b = nil) ⇒ Object
- .interpolate_plasma(t = nil) ⇒ Object
- .interpolate_rainbow(t = nil) ⇒ Object
-
.interpolate_rgb(a = nil, b = nil) ⇒ Object
These should support gamma.
- .interpolate_rgb_basis(a = nil, b = nil) ⇒ Object
- .interpolate_rgb_basis_closed(a = nil, b = nil) ⇒ Object
- .interpolate_round(a = nil, b = nil) ⇒ Object
- .interpolate_string(a = nil, b = nil) ⇒ Object
- .interpolate_viridis(t = nil) ⇒ Object
- .interpolate_warm(t = nil) ⇒ Object
- .lab(*args) ⇒ Object
- .line ⇒ Object
- .map(object = nil, &block) ⇒ Object
- .max(data, &block) ⇒ Object
- .mean(data, &block) ⇒ Object
- .median(data, &block) ⇒ Object
- .min(data, &block) ⇒ Object
- .namespace(name) ⇒ Object
- .namespaces ⇒ Object
- .nest ⇒ Object
- .path ⇒ Object
- .pie ⇒ Object
- .polygon_hull(points) ⇒ Object
- .quadtree(*args) ⇒ Object
- .quantile(data, p, &block) ⇒ Object
- .radial_area ⇒ Object
- .radial_line ⇒ Object
- .rgb(*args) ⇒ Object
- .scale_band(*args) ⇒ Object
- .scale_identity ⇒ Object
- .scale_implicit ⇒ Object
- .scale_linear ⇒ Object
- .scale_log ⇒ Object
- .scale_ordinal(*args) ⇒ Object
- .scale_point ⇒ Object
- .scale_pow ⇒ Object
- .scale_quantile ⇒ Object
- .scale_quantize ⇒ Object
- .scale_sequential(&block) ⇒ Object
- .scale_sqrt ⇒ Object
- .scale_threshold ⇒ Object
- .scale_time ⇒ Object
- .scale_utc ⇒ Object
- .scan(array, &block) ⇒ Object
- .scheme_category_10 ⇒ Object
- .scheme_category_20 ⇒ Object
- .scheme_category_20b ⇒ Object
- .scheme_category_20c ⇒ Object
- .select(selector) ⇒ Object
- .select_all(selector) ⇒ Object
- .selection ⇒ Object
- .set(array = nil, &block) ⇒ Object
- .stack ⇒ Object
- .sum(data, &block) ⇒ Object
- .symbol ⇒ Object
- .symbol_circle ⇒ Object
- .symbol_cross ⇒ Object
- .symbol_diamond ⇒ Object
- .symbol_square ⇒ Object
- .symbol_star ⇒ Object
- .symbol_triangle ⇒ Object
- .symbol_wye ⇒ Object
- .symbols ⇒ Object
- .threshold_freedman_diaconis(*args) ⇒ Object
- .threshold_scott(*args) ⇒ Object
- .threshold_sturges(*args) ⇒ Object
- .time_day ⇒ Object
- .time_format_default_locale(spec = {}) ⇒ Object
- .time_format_locale(spec = {}) ⇒ Object
- .time_friday ⇒ Object
- .time_hour ⇒ Object
- .time_millisecond ⇒ Object
- .time_minute ⇒ Object
- .time_monday ⇒ Object
- .time_month ⇒ Object
- .time_saturday ⇒ Object
- .time_second ⇒ Object
- .time_sunday ⇒ Object
- .time_thursday ⇒ Object
- .time_tuesday ⇒ Object
- .time_wednesday ⇒ Object
- .time_week ⇒ Object
- .time_year ⇒ Object
- .tsv_format(rows, columns = `undefined`) ⇒ Object
- .tsv_format_rows(rows) ⇒ Object
- .tsv_parse(string, row = `undefined`, &block) ⇒ Object
- .tsv_parse_rows(string, row = `undefined`, &block) ⇒ Object
- .utc_day ⇒ Object
- .utc_friday ⇒ Object
- .utc_hour ⇒ Object
- .utc_millisecond ⇒ Object
- .utc_minute ⇒ Object
- .utc_monday ⇒ Object
- .utc_month ⇒ Object
- .utc_saturday ⇒ Object
- .utc_second ⇒ Object
- .utc_sunday ⇒ Object
- .utc_thursday ⇒ Object
- .utc_tuesday ⇒ Object
- .utc_wednesday ⇒ Object
- .utc_week ⇒ Object
- .utc_year ⇒ Object
- .variance(data, &block) ⇒ Object
- .version ⇒ Object
Class Method Details
.arc ⇒ Object
17 18 19 |
# File 'lib/opal/d3/arc.rb', line 17 def arc D3::ArcGenerator.new @d3.JS.arc end |
.area ⇒ Object
45 46 47 |
# File 'lib/opal/d3/area.rb', line 45 def area D3::AreaGenerator.new @d3.JS.area end |
.axis_bottom(scale) ⇒ Object
65 66 67 |
# File 'lib/opal/d3/axis.rb', line 65 def axis_bottom(scale) D3::Axis.new(@d3.JS.axisBottom(scale.to_n), scale) end |
.axis_left(scale) ⇒ Object
73 74 75 |
# File 'lib/opal/d3/axis.rb', line 73 def axis_left(scale) D3::Axis.new(@d3.JS.axisLeft(scale.to_n), scale) end |
.axis_right(scale) ⇒ Object
69 70 71 |
# File 'lib/opal/d3/axis.rb', line 69 def axis_right(scale) D3::Axis.new(@d3.JS.axisRight(scale.to_n), scale) end |
.axis_top(scale) ⇒ Object
61 62 63 |
# File 'lib/opal/d3/axis.rb', line 61 def axis_top(scale) D3::Axis.new(@d3.JS.axisTop(scale.to_n), scale) end |
.bisector(&block) ⇒ Object
24 25 26 |
# File 'lib/opal/d3/search.rb', line 24 def bisector(&block) D3::Bisector.new @d3.JS.bisector(block) end |
.color(description) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/opal/d3/color.rb', line 24 def color(description) color = @d3.JS.color(description) if color D3::Color.new(color) else raise ArgumentError, "Invalid color: #{description}" end end |
.creator(name) ⇒ Object
7 8 9 |
# File 'lib/opal/d3/creator.rb', line 7 def creator(name) D3::Creator.new @d3.JS.creator(name) end |
.csv_format(rows, columns = `undefined`) ⇒ Object
95 96 97 |
# File 'lib/opal/d3/dsv.rb', line 95 def csv_format(rows, columns=`undefined`) @d3.JS.csvFormat(rows.to_n, columns) end |
.csv_format_rows(rows) ⇒ Object
63 64 65 |
# File 'lib/opal/d3/dsv.rb', line 63 def csv_format_rows(rows) @d3.JS.csvFormatRows(rows) end |
.csv_parse(string, row = `undefined`, &block) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/opal/d3/dsv.rb', line 71 def csv_parse(string, row=`undefined`, &block) row = block if block_given? if `row !== undefined` @d3.JS.csvParse(string, proc{|e| result = row.call(`Opal.hash(e)`) result == nil ? `null` : result }) else @d3.JS.csvParse(string).map{|e| `Opal.hash(e)` } end end |
.csv_parse_rows(string, row = `undefined`, &block) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/opal/d3/dsv.rb', line 39 def csv_parse_rows(string, row=`undefined`, &block) row = block if block_given? if `row !== undefined` @d3.JS.csvParseRows(string, proc{|d| result = row.call(d) result == nil ? `null` : result }) else @d3.JS.csvParseRows(string) end end |
.cubehelix(*args) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/opal/d3/color.rb', line 69 def cubehelix(*args) color = if args[0].is_a?(Color) @d3.JS.cubehelix(args[0].native) else @d3.JS.cubehelix(*args) end D3::Color.new(color) end |
.curve_basis ⇒ Object
19 20 21 |
# File 'lib/opal/d3/curve.rb', line 19 def curve_basis D3::Curve.new `window.d3.curveBasis` end |
.curve_basis_closed ⇒ Object
22 23 24 |
# File 'lib/opal/d3/curve.rb', line 22 def curve_basis_closed D3::Curve.new `window.d3.curveBasisClosed` end |
.curve_basis_open ⇒ Object
25 26 27 |
# File 'lib/opal/d3/curve.rb', line 25 def curve_basis_open D3::Curve.new `window.d3.curveBasisOpen` end |
.curve_bundle ⇒ Object
28 29 30 |
# File 'lib/opal/d3/curve.rb', line 28 def curve_bundle D3::CurveBundle.new `window.d3.curveBundle` end |
.curve_cardinal ⇒ Object
31 32 33 |
# File 'lib/opal/d3/curve.rb', line 31 def curve_cardinal D3::CurveCardinal.new `window.d3.curveCardinal` end |
.curve_cardinal_closed ⇒ Object
34 35 36 |
# File 'lib/opal/d3/curve.rb', line 34 def curve_cardinal_closed D3::CurveCardinal.new `window.d3.curveCardinalClosed` end |
.curve_cardinal_open ⇒ Object
37 38 39 |
# File 'lib/opal/d3/curve.rb', line 37 def curve_cardinal_open D3::CurveCardinal.new `window.d3.curveCardinalOpen` end |
.curve_catmull_rom ⇒ Object
40 41 42 |
# File 'lib/opal/d3/curve.rb', line 40 def curve_catmull_rom D3::CurveCatmullRom.new `window.d3.curveCatmullRom` end |
.curve_catmull_rom_closed ⇒ Object
43 44 45 |
# File 'lib/opal/d3/curve.rb', line 43 def curve_catmull_rom_closed D3::CurveCatmullRom.new `window.d3.curveCatmullRomClosed` end |
.curve_catmull_rom_open ⇒ Object
46 47 48 |
# File 'lib/opal/d3/curve.rb', line 46 def curve_catmull_rom_open D3::CurveCatmullRom.new `window.d3.curveCatmullRomOpen` end |
.curve_linear ⇒ Object
49 50 51 |
# File 'lib/opal/d3/curve.rb', line 49 def curve_linear D3::Curve.new `window.d3.curveLinear` end |
.curve_linear_closed ⇒ Object
52 53 54 |
# File 'lib/opal/d3/curve.rb', line 52 def curve_linear_closed D3::Curve.new `window.d3.curveLinearClosed` end |
.curve_monotone_x ⇒ Object
55 56 57 |
# File 'lib/opal/d3/curve.rb', line 55 def curve_monotone_x D3::Curve.new `window.d3.curveMonotoneX` end |
.curve_monotone_y ⇒ Object
58 59 60 |
# File 'lib/opal/d3/curve.rb', line 58 def curve_monotone_y D3::Curve.new `window.d3.curveMonotoneY` end |
.curve_natural ⇒ Object
61 62 63 |
# File 'lib/opal/d3/curve.rb', line 61 def curve_natural D3::Curve.new `window.d3.curveNatural` end |
.curve_step ⇒ Object
64 65 66 |
# File 'lib/opal/d3/curve.rb', line 64 def curve_step D3::Curve.new `window.d3.curveStep` end |
.curve_step_after ⇒ Object
67 68 69 |
# File 'lib/opal/d3/curve.rb', line 67 def curve_step_after D3::Curve.new `window.d3.curveStepAfter` end |
.curve_step_before ⇒ Object
70 71 72 |
# File 'lib/opal/d3/curve.rb', line 70 def curve_step_before D3::Curve.new `window.d3.curveStepBefore` end |
.deviation(data, &block) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/opal/d3/statistics.rb', line 45 def deviation(data, &block) result = if block @d3.JS.deviation(data, proc{|x| y=yield(x); y.nil? ? `undefined` : y}) else @d3.JS.deviation(data.compact) end `result === undefined ? nil : result` end |
.dsv_format(separator) ⇒ Object
35 36 37 |
# File 'lib/opal/d3/dsv.rb', line 35 def dsv_format(separator) D3::DsvFormat.new @d3.JS.dsvFormat(separator) end |
.ease_back(t = nil) ⇒ Object
255 256 257 258 259 260 261 |
# File 'lib/opal/d3/ease.rb', line 255 def ease_back(t=nil) if t @d3.JS.easeBack(t) else D3::EaseBack.new `#@d3.easeBack` end end |
.ease_back_in(t = nil) ⇒ Object
263 264 265 266 267 268 269 |
# File 'lib/opal/d3/ease.rb', line 263 def ease_back_in(t=nil) if t @d3.JS.easeBackIn(t) else D3::EaseBack.new `#@d3.easeBackIn` end end |
.ease_back_in_out(t = nil) ⇒ Object
279 280 281 282 283 284 285 |
# File 'lib/opal/d3/ease.rb', line 279 def ease_back_in_out(t=nil) if t @d3.JS.easeBackInOut(t) else D3::EaseBack.new `#@d3.easeBackInOut` end end |
.ease_back_out(t = nil) ⇒ Object
271 272 273 274 275 276 277 |
# File 'lib/opal/d3/ease.rb', line 271 def ease_back_out(t=nil) if t @d3.JS.easeBackOut(t) else D3::EaseBack.new `#@d3.easeBackOut` end end |
.ease_bounce(t = nil) ⇒ Object
199 200 201 202 203 204 205 |
# File 'lib/opal/d3/ease.rb', line 199 def ease_bounce(t=nil) if t @d3.JS.easeBounce(t) else `#@d3.easeBounce` end end |
.ease_bounce_in(t = nil) ⇒ Object
207 208 209 210 211 212 213 |
# File 'lib/opal/d3/ease.rb', line 207 def ease_bounce_in(t=nil) if t @d3.JS.easeBounceIn(t) else `#@d3.easeBounceIn` end end |
.ease_bounce_in_out(t = nil) ⇒ Object
223 224 225 226 227 228 229 |
# File 'lib/opal/d3/ease.rb', line 223 def ease_bounce_in_out(t=nil) if t @d3.JS.easeBounceInOut(t) else `#@d3.easeBounceInOut` end end |
.ease_bounce_out(t = nil) ⇒ Object
215 216 217 218 219 220 221 |
# File 'lib/opal/d3/ease.rb', line 215 def ease_bounce_out(t=nil) if t @d3.JS.easeBounceOut(t) else `#@d3.easeBounceOut` end end |
.ease_circle(t = nil) ⇒ Object
167 168 169 170 171 172 173 |
# File 'lib/opal/d3/ease.rb', line 167 def ease_circle(t=nil) if t @d3.JS.easeCircle(t) else `#@d3.easeCircle` end end |
.ease_circle_in(t = nil) ⇒ Object
175 176 177 178 179 180 181 |
# File 'lib/opal/d3/ease.rb', line 175 def ease_circle_in(t=nil) if t @d3.JS.easeCircleIn(t) else `#@d3.easeCircleIn` end end |
.ease_circle_in_out(t = nil) ⇒ Object
191 192 193 194 195 196 197 |
# File 'lib/opal/d3/ease.rb', line 191 def ease_circle_in_out(t=nil) if t @d3.JS.easeCircleInOut(t) else `#@d3.easeCircleInOut` end end |
.ease_circle_out(t = nil) ⇒ Object
183 184 185 186 187 188 189 |
# File 'lib/opal/d3/ease.rb', line 183 def ease_circle_out(t=nil) if t @d3.JS.easeCircleOut(t) else `#@d3.easeCircleOut` end end |
.ease_cubic(t = nil) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/opal/d3/ease.rb', line 71 def ease_cubic(t=nil) if t @d3.JS.easeCubic(t) else `#@d3.easeCubic` end end |
.ease_cubic_in(t = nil) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/opal/d3/ease.rb', line 79 def ease_cubic_in(t=nil) if t @d3.JS.easeCubicIn(t) else `#@d3.easeCubicIn` end end |
.ease_cubic_in_out(t = nil) ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/opal/d3/ease.rb', line 95 def ease_cubic_in_out(t=nil) if t @d3.JS.easeCubicInOut(t) else `#@d3.easeCubicInOut` end end |
.ease_cubic_out(t = nil) ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/opal/d3/ease.rb', line 87 def ease_cubic_out(t=nil) if t @d3.JS.easeCubicOut(t) else `#@d3.easeCubicOut` end end |
.ease_elastic(t = nil) ⇒ Object
287 288 289 290 291 292 293 |
# File 'lib/opal/d3/ease.rb', line 287 def ease_elastic(t=nil) if t @d3.JS.easeElastic(t) else D3::EaseElastic.new `#@d3.easeElastic` end end |
.ease_elastic_in(t = nil) ⇒ Object
295 296 297 298 299 300 301 |
# File 'lib/opal/d3/ease.rb', line 295 def ease_elastic_in(t=nil) if t @d3.JS.easeElasticIn(t) else D3::EaseElastic.new `#@d3.easeElasticIn` end end |
.ease_elastic_in_out(t = nil) ⇒ Object
311 312 313 314 315 316 317 |
# File 'lib/opal/d3/ease.rb', line 311 def ease_elastic_in_out(t=nil) if t @d3.JS.easeElasticInOut(t) else D3::EaseElastic.new `#@d3.easeElasticInOut` end end |
.ease_elastic_out(t = nil) ⇒ Object
303 304 305 306 307 308 309 |
# File 'lib/opal/d3/ease.rb', line 303 def ease_elastic_out(t=nil) if t @d3.JS.easeElasticOut(t) else D3::EaseElastic.new `#@d3.easeElasticOut` end end |
.ease_exp(t = nil) ⇒ Object
135 136 137 138 139 140 141 |
# File 'lib/opal/d3/ease.rb', line 135 def ease_exp(t=nil) if t @d3.JS.easeExp(t) else `#@d3.easeExp` end end |
.ease_exp_in(t = nil) ⇒ Object
143 144 145 146 147 148 149 |
# File 'lib/opal/d3/ease.rb', line 143 def ease_exp_in(t=nil) if t @d3.JS.easeExpIn(t) else `#@d3.easeExpIn` end end |
.ease_exp_in_out(t = nil) ⇒ Object
159 160 161 162 163 164 165 |
# File 'lib/opal/d3/ease.rb', line 159 def ease_exp_in_out(t=nil) if t @d3.JS.easeExpInOut(t) else `#@d3.easeExpInOut` end end |
.ease_exp_out(t = nil) ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/opal/d3/ease.rb', line 151 def ease_exp_out(t=nil) if t @d3.JS.easeExpOut(t) else `#@d3.easeExpOut` end end |
.ease_linear(t = nil) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/opal/d3/ease.rb', line 31 def ease_linear(t=nil) if t @d3.JS.easeLinear(t) else `#@d3.easeLinear` end end |
.ease_poly_in(t = nil) ⇒ Object
231 232 233 234 235 236 237 |
# File 'lib/opal/d3/ease.rb', line 231 def ease_poly_in(t=nil) if t @d3.JS.easePolyIn(t) else D3::EasePoly.new `#@d3.easePolyIn` end end |
.ease_poly_in_out(t = nil) ⇒ Object
247 248 249 250 251 252 253 |
# File 'lib/opal/d3/ease.rb', line 247 def ease_poly_in_out(t=nil) if t @d3.JS.easePolyInOut(t) else D3::EasePoly.new `#@d3.easePolyInOut` end end |
.ease_poly_out(t = nil) ⇒ Object
239 240 241 242 243 244 245 |
# File 'lib/opal/d3/ease.rb', line 239 def ease_poly_out(t=nil) if t @d3.JS.easePolyOut(t) else D3::EasePoly.new `#@d3.easePolyOut` end end |
.ease_quad(t = nil) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/opal/d3/ease.rb', line 39 def ease_quad(t=nil) if t @d3.JS.easeQuad(t) else `#@d3.easeQuad` end end |
.ease_quad_in(t = nil) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/opal/d3/ease.rb', line 47 def ease_quad_in(t=nil) if t @d3.JS.easeQuadIn(t) else `#@d3.easeQuadIn` end end |
.ease_quad_in_out(t = nil) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/opal/d3/ease.rb', line 63 def ease_quad_in_out(t=nil) if t @d3.JS.easeQuadInOut(t) else `#@d3.easeQuadInOut` end end |
.ease_quad_out(t = nil) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/opal/d3/ease.rb', line 55 def ease_quad_out(t=nil) if t @d3.JS.easeQuadOut(t) else `#@d3.easeQuadOut` end end |
.ease_sin(t = nil) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/opal/d3/ease.rb', line 103 def ease_sin(t=nil) if t @d3.JS.easeSin(t) else `#@d3.easeSin` end end |
.ease_sin_in(t = nil) ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/opal/d3/ease.rb', line 111 def ease_sin_in(t=nil) if t @d3.JS.easeSinIn(t) else `#@d3.easeSinIn` end end |
.ease_sin_in_out(t = nil) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/opal/d3/ease.rb', line 127 def ease_sin_in_out(t=nil) if t @d3.JS.easeSinInOut(t) else `#@d3.easeSinInOut` end end |
.ease_sin_out(t = nil) ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/opal/d3/ease.rb', line 119 def ease_sin_out(t=nil) if t @d3.JS.easeSinOut(t) else `#@d3.easeSinOut` end end |
.entries(obj) ⇒ Object
6 7 8 |
# File 'lib/opal/d3/collections.rb', line 6 def entries(obj) @d3.JS.entries(obj).map{|o| [`o.key`, `o.value`]} end |
.extent(data, &block) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/opal/d3/statistics.rb', line 72 def extent(data, &block) (a,b) = if block @d3.JS.extent(data, proc{|x| y=yield(x); y.nil? ? `undefined` : y}) else @d3.JS.extent(data.compact) end [`a === undefined ? nil : a`, `b === undefined ? nil : b`] end |
.format(specifier) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/opal/d3/format.rb', line 55 def format(specifier) if specifier.is_a?(FormatSpecifier) @d3.JS.format(specifier.to_n) else @d3.JS.format(specifier) end end |
.format_default_locale(spec = {}) ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/opal/d3/format.rb', line 86 def format_default_locale(spec={}) D3::FormatLocale.new @d3.JS.formatDefaultLocale( { decimal: spec.fetch("decimal", "."), thousands: spec.fetch("thousands", ","), grouping: spec.fetch("grouping", [3]), currency: spec.fetch("currency", ["$", ""]), }.to_n ) end |
.format_locale(spec = {}) ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/opal/d3/format.rb', line 75 def format_locale(spec={}) D3::FormatLocale.new @d3.JS.formatLocale( { decimal: spec.fetch("decimal", "."), thousands: spec.fetch("thousands", ","), grouping: spec.fetch("grouping", [3]), currency: spec.fetch("currency", ["$", ""]), }.to_n ) end |
.format_prefix(specifier, value) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/opal/d3/format.rb', line 63 def format_prefix(specifier, value) if specifier.is_a?(FormatSpecifier) @d3.JS.formatPrefix(specifier.to_n, value) else @d3.JS.formatPrefix(specifier, value) end end |
.format_specifier(specifier) ⇒ Object
71 72 73 |
# File 'lib/opal/d3/format.rb', line 71 def format_specifier(specifier) D3::FormatSpecifier.new @d3.JS.formatSpecifier(specifier) end |
.hcl(*args) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/opal/d3/color.rb', line 60 def hcl(*args) color = if args[0].is_a?(Color) @d3.JS.hcl(args[0].native) else @d3.JS.hcl(*args) end D3::Color.new(color) end |
.histogram ⇒ Object
28 29 30 |
# File 'lib/opal/d3/histograms.rb', line 28 def histogram D3::Histogram.new @d3.JS.histogram end |
.hsl(*args) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/opal/d3/color.rb', line 42 def hsl(*args) color = if args[0].is_a?(Color) @d3.JS.hsl(args[0].native) else @d3.JS.hsl(*args) end D3::Color.new(color) end |
.interpolate_array(a = nil, b = nil) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/opal/d3/interpolate.rb', line 27 def interpolate_array(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateArray` else @d3.JS.interpolateArray(a,b) end end |
.interpolate_cool(t = nil) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/opal/d3/sequential_scale.rb', line 72 def interpolate_cool(t=nil) if t @d3.JS.interpolateCool(t) else `#@d3.interpolateCool` end end |
.interpolate_cubehelix(a = nil, b = nil) ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/opal/d3/interpolate.rb', line 108 def interpolate_cubehelix(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateCubehelix` else @d3.JS.interpolateCubehelix(a,b) end end |
.interpolate_cubehelix_default(t = nil) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/opal/d3/sequential_scale.rb', line 88 def interpolate_cubehelix_default(t=nil) if t @d3.JS.interpolateCubehelixDefault(t) else `#@d3.interpolateCubehelixDefault` end end |
.interpolate_cubehelix_long(a = nil, b = nil) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/opal/d3/interpolate.rb', line 116 def interpolate_cubehelix_long(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateCubehelixLong` else @d3.JS.interpolateCubehelixLong(a,b) end end |
.interpolate_date(a = nil, b = nil) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/opal/d3/interpolate.rb', line 35 def interpolate_date(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateDate` else @d3.JS.interpolateDate(a,b) end end |
.interpolate_hcl(a = nil, b = nil) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/opal/d3/interpolate.rb', line 92 def interpolate_hcl(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateHcl` else @d3.JS.interpolateHcl(a,b) end end |
.interpolate_hcl_long(a = nil, b = nil) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/opal/d3/interpolate.rb', line 100 def interpolate_hcl_long(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateHclLong` else @d3.JS.interpolateHclLong(a,b) end end |
.interpolate_hsl(a = nil, b = nil) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/opal/d3/interpolate.rb', line 68 def interpolate_hsl(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateHsl` else @d3.JS.interpolateHsl(a,b) end end |
.interpolate_hsl_long(a = nil, b = nil) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/opal/d3/interpolate.rb', line 76 def interpolate_hsl_long(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateHslLong` else @d3.JS.interpolateHslLong(a,b) end end |
.interpolate_inferno(t = nil) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/opal/d3/sequential_scale.rb', line 40 def interpolate_inferno(t=nil) if t @d3.JS.interpolateInferno(t) else `#@d3.interpolateInferno` end end |
.interpolate_lab(a = nil, b = nil) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/opal/d3/interpolate.rb', line 84 def interpolate_lab(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateLab` else @d3.JS.interpolateLab(a,b) end end |
.interpolate_magma(t = nil) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/opal/d3/sequential_scale.rb', line 48 def interpolate_magma(t=nil) if t @d3.JS.interpolateMagma(t) else `#@d3.interpolateMagma` end end |
.interpolate_number(a = nil, b = nil) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/opal/d3/interpolate.rb', line 3 def interpolate_number(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateNumber` else @d3.JS.interpolateNumber(a,b) end end |
.interpolate_plasma(t = nil) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/opal/d3/sequential_scale.rb', line 56 def interpolate_plasma(t=nil) if t @d3.JS.interpolatePlasma(t) else `#@d3.interpolatePlasma` end end |
.interpolate_rainbow(t = nil) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/opal/d3/sequential_scale.rb', line 80 def interpolate_rainbow(t=nil) if t @d3.JS.interpolateRainbow(t) else `#@d3.interpolateRainbow` end end |
.interpolate_rgb(a = nil, b = nil) ⇒ Object
These should support gamma
44 45 46 47 48 49 50 |
# File 'lib/opal/d3/interpolate.rb', line 44 def interpolate_rgb(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateRgb` else @d3.JS.interpolateRgb(a,b) end end |
.interpolate_rgb_basis(a = nil, b = nil) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/opal/d3/interpolate.rb', line 52 def interpolate_rgb_basis(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateRgbBasis` else @d3.JS.interpolateRgbBasis(a,b) end end |
.interpolate_rgb_basis_closed(a = nil, b = nil) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/opal/d3/interpolate.rb', line 60 def interpolate_rgb_basis_closed(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateRgbBasisClosed` else @d3.JS.interpolateRgbBasisClosed(a,b) end end |
.interpolate_round(a = nil, b = nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/opal/d3/interpolate.rb', line 11 def interpolate_round(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateRound` else @d3.JS.interpolateRound(a,b) end end |
.interpolate_string(a = nil, b = nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/opal/d3/interpolate.rb', line 19 def interpolate_string(a=nil,b=nil) if a == nil and b == nil `#@d3.interpolateString` else @d3.JS.interpolateString(a,b) end end |
.interpolate_viridis(t = nil) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/opal/d3/sequential_scale.rb', line 32 def interpolate_viridis(t=nil) if t @d3.JS.interpolateViridis(t) else `#@d3.interpolateViridis` end end |
.interpolate_warm(t = nil) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/opal/d3/sequential_scale.rb', line 64 def interpolate_warm(t=nil) if t @d3.JS.interpolateWarm(t) else `#@d3.interpolateWarm` end end |
.lab(*args) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/opal/d3/color.rb', line 51 def lab(*args) color = if args[0].is_a?(Color) @d3.JS.lab(args[0].native) else @d3.JS.lab(*args) end D3::Color.new(color) end |
.line ⇒ Object
25 26 27 |
# File 'lib/opal/d3/line.rb', line 25 def line D3::LineGenerator.new @d3.JS.line end |
.map(object = nil, &block) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/opal/d3/map.rb', line 42 def map(object=nil, &block) if block_given? D3::Map.new(@d3.JS.map(object, proc{|x| yield(x)})) elsif object D3::Map.new(@d3.JS.map(object)) else D3::Map.new(@d3.JS.map()) end end |
.max(data, &block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/opal/d3/statistics.rb', line 11 def max(data, &block) if block @d3.JS.max(data, proc{|x| y=yield(x); y.nil? ? `undefined` : y}) else @d3.JS.max(data.compact) end end |
.mean(data, &block) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/opal/d3/statistics.rb', line 27 def mean(data, &block) result = if block @d3.JS.mean(data, proc{|x| y=yield(x); y.nil? ? `undefined` : y}) else @d3.JS.mean(data.compact) end `result === undefined ? nil : result` end |
.median(data, &block) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/opal/d3/statistics.rb', line 36 def median(data, &block) result = if block @d3.JS.median(data, proc{|x| y=yield(x); y.nil? ? `undefined` : y}) else @d3.JS.median(data.compact) end `result === undefined ? nil : result` end |
.min(data, &block) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/opal/d3/statistics.rb', line 3 def min(data, &block) if block @d3.JS.min(data, proc{|x| y=yield(x); y.nil? ? `undefined` : y}) else @d3.JS.min(data.compact) end end |
.namespace(name) ⇒ Object
11 12 13 |
# File 'lib/opal/d3/misc.rb', line 11 def namespace(name) `Opal.hash(window.d3.namespace(name))` end |
.namespaces ⇒ Object
7 8 9 |
# File 'lib/opal/d3/misc.rb', line 7 def namespaces `Opal.hash(window.d3.namespaces)` end |
.pie ⇒ Object
19 20 21 |
# File 'lib/opal/d3/pie.rb', line 19 def pie D3::PieGenerator.new @d3.JS.pie end |
.polygon_hull(points) ⇒ Object
11 12 13 14 |
# File 'lib/opal/d3/polygon.rb', line 11 def polygon_hull(points) hull = @d3.JS.polygonHull(points) `hull === null ? nil : hull` end |
.quadtree(*args) ⇒ Object
91 92 93 |
# File 'lib/opal/d3/quadtree.rb', line 91 def quadtree(*args) D3::QuadTree.new @d3.JS.quadtree(*args) end |
.quantile(data, p, &block) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/opal/d3/statistics.rb', line 63 def quantile(data, p, &block) result = if block @d3.JS.quantile(data, p, proc{|x| y=yield(x); y.nil? ? `undefined` : y}) else @d3.JS.quantile(data.compact, p) end `result === undefined ? nil : result` end |
.radial_area ⇒ Object
45 46 47 |
# File 'lib/opal/d3/radial_area.rb', line 45 def radial_area D3::RadialAreaGenerator.new @d3.JS.radialArea end |
.radial_line ⇒ Object
25 26 27 |
# File 'lib/opal/d3/radial_line.rb', line 25 def radial_line D3::RadialLineGenerator.new @d3.JS.radialLine end |
.rgb(*args) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/opal/d3/color.rb', line 33 def rgb(*args) color = if args[0].is_a?(Color) @d3.JS.rgb(args[0].native) else @d3.JS.rgb(*args) end D3::Color.new(color) end |
.scale_band(*args) ⇒ Object
25 26 27 |
# File 'lib/opal/d3/band_scale.rb', line 25 def scale_band(*args) D3::BandScale.new @d3.JS.scaleBand(*args) end |
.scale_identity ⇒ Object
52 53 54 |
# File 'lib/opal/d3/continuous_scale.rb', line 52 def scale_identity D3::ContinuousScale.new @d3.JS.scaleIdentity end |
.scale_implicit ⇒ Object
36 37 38 |
# File 'lib/opal/d3/ordinal_scale.rb', line 36 def scale_implicit :implicit end |
.scale_linear ⇒ Object
44 45 46 |
# File 'lib/opal/d3/continuous_scale.rb', line 44 def scale_linear D3::ContinuousScale.new @d3.JS.scaleLinear end |
.scale_log ⇒ Object
48 49 50 |
# File 'lib/opal/d3/continuous_scale.rb', line 48 def scale_log D3::LogScale.new @d3.JS.scaleLog end |
.scale_ordinal(*args) ⇒ Object
32 33 34 |
# File 'lib/opal/d3/ordinal_scale.rb', line 32 def scale_ordinal(*args) D3::OrdinalScale.new @d3.JS.scaleOrdinal(*args) end |
.scale_point ⇒ Object
22 23 24 |
# File 'lib/opal/d3/point_scale.rb', line 22 def scale_point D3::PointScale.new @d3.JS.scalePoint end |
.scale_pow ⇒ Object
36 37 38 |
# File 'lib/opal/d3/continuous_scale.rb', line 36 def scale_pow D3::PowScale.new @d3.JS.scalePow end |
.scale_quantile ⇒ Object
17 18 19 |
# File 'lib/opal/d3/quantile_scale.rb', line 17 def scale_quantile D3::QuantileScale.new @d3.JS.scaleQuantile end |
.scale_quantize ⇒ Object
19 20 21 |
# File 'lib/opal/d3/quantize_scale.rb', line 19 def scale_quantize D3::QuantizeScale.new @d3.JS.scaleQuantize end |
.scale_sequential(&block) ⇒ Object
27 28 29 30 |
# File 'lib/opal/d3/sequential_scale.rb', line 27 def scale_sequential(&block) raise unless block_given? SequentialScale.new @d3.JS.scaleSequential(block) end |
.scale_sqrt ⇒ Object
40 41 42 |
# File 'lib/opal/d3/continuous_scale.rb', line 40 def scale_sqrt D3::PowScale.new @d3.JS.scaleSqrt end |
.scale_threshold ⇒ Object
19 20 21 |
# File 'lib/opal/d3/threshold_scale.rb', line 19 def scale_threshold D3::ThresholdScale.new @d3.JS.scaleThreshold end |
.scale_time ⇒ Object
56 57 58 |
# File 'lib/opal/d3/continuous_scale.rb', line 56 def scale_time D3::ContinuousScale.new @d3.JS.scaleTime end |
.scale_utc ⇒ Object
60 61 62 |
# File 'lib/opal/d3/continuous_scale.rb', line 60 def scale_utc D3::ContinuousScale.new @d3.JS.scaleUtc end |
.scan(array, &block) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/opal/d3/search.rb', line 16 def scan(array, &block) if block_given? @d3.JS.scan(array, block) else @d3.JS.scan(array) end end |
.scheme_category_10 ⇒ Object
40 41 42 |
# File 'lib/opal/d3/ordinal_scale.rb', line 40 def scheme_category_10 `window.d3.schemeCategory10` end |
.scheme_category_20 ⇒ Object
44 45 46 |
# File 'lib/opal/d3/ordinal_scale.rb', line 44 def scheme_category_20 `window.d3.schemeCategory20` end |
.scheme_category_20b ⇒ Object
48 49 50 |
# File 'lib/opal/d3/ordinal_scale.rb', line 48 def scheme_category_20b `window.d3.schemeCategory20b` end |
.scheme_category_20c ⇒ Object
52 53 54 |
# File 'lib/opal/d3/ordinal_scale.rb', line 52 def scheme_category_20c `window.d3.schemeCategory20c` end |
.select(selector) ⇒ Object
141 142 143 |
# File 'lib/opal/d3/selection.rb', line 141 def select(selector) D3::Selection.new(@d3.JS.select(selector)) end |
.select_all(selector) ⇒ Object
145 146 147 |
# File 'lib/opal/d3/selection.rb', line 145 def select_all(selector) D3::Selection.new(@d3.JS.selectAll(selector)) end |
.selection ⇒ Object
137 138 139 |
# File 'lib/opal/d3/selection.rb', line 137 def selection D3::Selection.new(@d3.JS.selection) end |
.set(array = nil, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/opal/d3/set.rb', line 23 def set(array=nil, &block) if block_given? D3::Set.new @d3.JS.set(array, proc{|x| yield(x)}) elsif array D3::Set.new @d3.JS.set(array) else D3::Set.new @d3.JS.set() end end |
.stack ⇒ Object
7 8 9 |
# File 'lib/opal/d3/stack.rb', line 7 def stack D3::StackGenerator.new @d3.JS.stack end |
.sum(data, &block) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/opal/d3/statistics.rb', line 19 def sum(data, &block) if block @d3.JS.sum(data, proc{|x| y=yield(x); y.nil? ? `undefined` : y}) else @d3.JS.sum(data.compact) end end |
.symbol ⇒ Object
34 35 36 |
# File 'lib/opal/d3/symbol.rb', line 34 def symbol D3::SymbolGenerator.new @d3.JS.symbol end |
.symbol_circle ⇒ Object
42 43 44 |
# File 'lib/opal/d3/symbol.rb', line 42 def symbol_circle D3::SymbolType.new `window.d3.symbolCircle` end |
.symbol_cross ⇒ Object
46 47 48 |
# File 'lib/opal/d3/symbol.rb', line 46 def symbol_cross D3::SymbolType.new `window.d3.symbolCross` end |
.symbol_diamond ⇒ Object
50 51 52 |
# File 'lib/opal/d3/symbol.rb', line 50 def symbol_diamond D3::SymbolType.new `window.d3.symbolDiamond` end |
.symbol_square ⇒ Object
54 55 56 |
# File 'lib/opal/d3/symbol.rb', line 54 def symbol_square D3::SymbolType.new `window.d3.symbolSquare` end |
.symbol_star ⇒ Object
58 59 60 |
# File 'lib/opal/d3/symbol.rb', line 58 def symbol_star D3::SymbolType.new `window.d3.symbolStar` end |
.symbol_triangle ⇒ Object
62 63 64 |
# File 'lib/opal/d3/symbol.rb', line 62 def symbol_triangle D3::SymbolType.new `window.d3.symbolTriangle` end |
.symbol_wye ⇒ Object
66 67 68 |
# File 'lib/opal/d3/symbol.rb', line 66 def symbol_wye D3::SymbolType.new `window.d3.symbolWye` end |
.symbols ⇒ Object
38 39 40 |
# File 'lib/opal/d3/symbol.rb', line 38 def symbols `window.d3.symbols`.map{|st| D3::SymbolType.new(st)} end |
.threshold_freedman_diaconis(*args) ⇒ Object
32 33 34 |
# File 'lib/opal/d3/histograms.rb', line 32 def threshold_freedman_diaconis(*args) @d3.JS.thresholdFreedmanDiaconis(*args) end |
.threshold_scott(*args) ⇒ Object
36 37 38 |
# File 'lib/opal/d3/histograms.rb', line 36 def threshold_scott(*args) @d3.JS.thresholdScott(*args) end |
.threshold_sturges(*args) ⇒ Object
40 41 42 |
# File 'lib/opal/d3/histograms.rb', line 40 def threshold_sturges(*args) @d3.JS.thresholdSturges(*args) end |
.time_day ⇒ Object
39 |
# File 'lib/opal/d3/time_interval.rb', line 39 def time_day; D3::TimeInterval.new(`window.d3.timeDay`); end |
.time_format_default_locale(spec = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/opal/d3/time_format.rb', line 33 def time_format_default_locale(spec={}) D3::TimeFormatLocale.new @d3.JS.timeFormatDefaultLocale( { dateTime: spec.fetch(:date_time, "%x, %X"), date: spec.fetch(:date, "%-m/%-d/%Y"), time: spec.fetch(:time, "%-I:%M:%S %p"), periods: spec.fetch(:periods, ["AM", "PM"]), days: spec.fetch(:days, ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]), shortDays: spec.fetch(:short_days, ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]), months: spec.fetch(:months, ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]), shortMonths: spec.fetch(:short_months, ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]), }.to_n ) end |
.time_format_locale(spec = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/opal/d3/time_format.rb', line 18 def time_format_locale(spec={}) D3::TimeFormatLocale.new @d3.JS.timeFormatLocale( { dateTime: spec.fetch(:date_time, "%x, %X"), date: spec.fetch(:date, "%-m/%-d/%Y"), time: spec.fetch(:time, "%-I:%M:%S %p"), periods: spec.fetch(:periods, ["AM", "PM"]), days: spec.fetch(:days, ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]), shortDays: spec.fetch(:short_days, ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]), months: spec.fetch(:months, ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]), shortMonths: spec.fetch(:short_months, ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]), }.to_n ) end |
.time_friday ⇒ Object
33 |
# File 'lib/opal/d3/time_interval.rb', line 33 def time_friday; D3::TimeInterval.new(`window.d3.timeFriday`); end |
.time_hour ⇒ Object
41 |
# File 'lib/opal/d3/time_interval.rb', line 41 def time_hour; D3::TimeInterval.new(`window.d3.timeHour`); end |
.time_millisecond ⇒ Object
47 |
# File 'lib/opal/d3/time_interval.rb', line 47 def time_millisecond; D3::TimeInterval.new(`window.d3.timeMillisecond`); end |
.time_minute ⇒ Object
43 |
# File 'lib/opal/d3/time_interval.rb', line 43 def time_minute; D3::TimeInterval.new(`window.d3.timeMinute`); end |
.time_monday ⇒ Object
25 |
# File 'lib/opal/d3/time_interval.rb', line 25 def time_monday; D3::TimeInterval.new(`window.d3.timeMonday`); end |
.time_month ⇒ Object
21 |
# File 'lib/opal/d3/time_interval.rb', line 21 def time_month; D3::TimeInterval.new(`window.d3.timeMonth`); end |
.time_saturday ⇒ Object
35 |
# File 'lib/opal/d3/time_interval.rb', line 35 def time_saturday; D3::TimeInterval.new(`window.d3.timeSaturday`); end |
.time_second ⇒ Object
45 |
# File 'lib/opal/d3/time_interval.rb', line 45 def time_second; D3::TimeInterval.new(`window.d3.timeSecond`); end |
.time_sunday ⇒ Object
37 |
# File 'lib/opal/d3/time_interval.rb', line 37 def time_sunday; D3::TimeInterval.new(`window.d3.timeSunday`); end |
.time_thursday ⇒ Object
31 |
# File 'lib/opal/d3/time_interval.rb', line 31 def time_thursday; D3::TimeInterval.new(`window.d3.timeThursday`); end |
.time_tuesday ⇒ Object
27 |
# File 'lib/opal/d3/time_interval.rb', line 27 def time_tuesday; D3::TimeInterval.new(`window.d3.timeTuesday`); end |
.time_wednesday ⇒ Object
29 |
# File 'lib/opal/d3/time_interval.rb', line 29 def time_wednesday; D3::TimeInterval.new(`window.d3.timeWednesday`); end |
.time_week ⇒ Object
23 |
# File 'lib/opal/d3/time_interval.rb', line 23 def time_week; D3::TimeInterval.new(`window.d3.timeWeek`); end |
.time_year ⇒ Object
19 |
# File 'lib/opal/d3/time_interval.rb', line 19 def time_year; D3::TimeInterval.new(`window.d3.timeYear`); end |
.tsv_format(rows, columns = `undefined`) ⇒ Object
99 100 101 |
# File 'lib/opal/d3/dsv.rb', line 99 def tsv_format(rows, columns=`undefined`) @d3.JS.tsvFormat(rows.to_n, columns) end |
.tsv_format_rows(rows) ⇒ Object
67 68 69 |
# File 'lib/opal/d3/dsv.rb', line 67 def tsv_format_rows(rows) @d3.JS.tsvFormatRows(rows) end |
.tsv_parse(string, row = `undefined`, &block) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/opal/d3/dsv.rb', line 83 def tsv_parse(string, row=`undefined`, &block) row = block if block_given? if `row !== undefined` @d3.JS.tsvParse(string, proc{|e| result = row.call(`Opal.hash(e)`) result == nil ? `null` : result }) else @d3.JS.tsvParse(string).map{|e| `Opal.hash(e)` } end end |
.tsv_parse_rows(string, row = `undefined`, &block) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/opal/d3/dsv.rb', line 51 def tsv_parse_rows(string, row=`undefined`, &block) row = block if block_given? if `row !== undefined` @d3.JS.tsvParseRows(string, proc{|d| result = row.call(d) result == nil ? `null` : result }) else @d3.JS.tsvParseRows(string) end end |
.utc_day ⇒ Object
40 |
# File 'lib/opal/d3/time_interval.rb', line 40 def utc_day; D3::TimeInterval.new(`window.d3.utcDay`); end |
.utc_friday ⇒ Object
34 |
# File 'lib/opal/d3/time_interval.rb', line 34 def utc_friday; D3::TimeInterval.new(`window.d3.utcFriday`); end |
.utc_hour ⇒ Object
42 |
# File 'lib/opal/d3/time_interval.rb', line 42 def utc_hour; D3::TimeInterval.new(`window.d3.utcHour`); end |
.utc_millisecond ⇒ Object
48 |
# File 'lib/opal/d3/time_interval.rb', line 48 def utc_millisecond; D3::TimeInterval.new(`window.d3.utcMillisecond`); end |
.utc_minute ⇒ Object
44 |
# File 'lib/opal/d3/time_interval.rb', line 44 def utc_minute; D3::TimeInterval.new(`window.d3.utcMinute`); end |
.utc_monday ⇒ Object
26 |
# File 'lib/opal/d3/time_interval.rb', line 26 def utc_monday; D3::TimeInterval.new(`window.d3.utcMonday`); end |
.utc_month ⇒ Object
22 |
# File 'lib/opal/d3/time_interval.rb', line 22 def utc_month; D3::TimeInterval.new(`window.d3.utcMonth`); end |
.utc_saturday ⇒ Object
36 |
# File 'lib/opal/d3/time_interval.rb', line 36 def utc_saturday; D3::TimeInterval.new(`window.d3.utcSaturday`); end |
.utc_second ⇒ Object
46 |
# File 'lib/opal/d3/time_interval.rb', line 46 def utc_second; D3::TimeInterval.new(`window.d3.utcSecond`); end |
.utc_sunday ⇒ Object
38 |
# File 'lib/opal/d3/time_interval.rb', line 38 def utc_sunday; D3::TimeInterval.new(`window.d3.utcSunday`); end |
.utc_thursday ⇒ Object
32 |
# File 'lib/opal/d3/time_interval.rb', line 32 def utc_thursday; D3::TimeInterval.new(`window.d3.utcThursday`); end |
.utc_tuesday ⇒ Object
28 |
# File 'lib/opal/d3/time_interval.rb', line 28 def utc_tuesday; D3::TimeInterval.new(`window.d3.utcTuesday`); end |
.utc_wednesday ⇒ Object
30 |
# File 'lib/opal/d3/time_interval.rb', line 30 def utc_wednesday; D3::TimeInterval.new(`window.d3.utcWednesday`); end |
.utc_week ⇒ Object
24 |
# File 'lib/opal/d3/time_interval.rb', line 24 def utc_week; D3::TimeInterval.new(`window.d3.utcWeek`); end |
.utc_year ⇒ Object
20 |
# File 'lib/opal/d3/time_interval.rb', line 20 def utc_year; D3::TimeInterval.new(`window.d3.utcYear`); end |
.variance(data, &block) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/opal/d3/statistics.rb', line 54 def variance(data, &block) result = if block @d3.JS.variance(data, proc{|x| y=yield(x); y.nil? ? `undefined` : y}) else @d3.JS.variance(data.compact) end `result === undefined ? nil : result` end |
.version ⇒ Object
3 4 5 |
# File 'lib/opal/d3/misc.rb', line 3 def version `window.d3.version` end |