opal-d3 0.0.20170205

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/Gemfile +3 -0
  4. data/README.md +7 -0
  5. data/Rakefile +31 -0
  6. data/d3.js +16393 -0
  7. data/demo/Gemfile +4 -0
  8. data/demo/README.md +7 -0
  9. data/demo/app/data/elections_2016.rb +10 -0
  10. data/demo/app/data/harry_potter.rb +19 -0
  11. data/demo/app/data/iphones.rb +29 -0
  12. data/demo/app/data/london_population.rb +26 -0
  13. data/demo/app/data/man_vs_horse.rb +55 -0
  14. data/demo/app/data/mtg_modern_colors.rb +96 -0
  15. data/demo/app/data/mtg_modern_creatures.rb +116 -0
  16. data/demo/app/data/olympics_2016_medals.rb +100 -0
  17. data/demo/app/data/paradox.rb +60 -0
  18. data/demo/app/data/polish_pms.rb +28 -0
  19. data/demo/app/data/star_trek_voyager.rb +183 -0
  20. data/demo/app/data/weather_in_london.rb +381 -0
  21. data/demo/app/elections_2016.rb +19 -0
  22. data/demo/app/harry_potter.rb +35 -0
  23. data/demo/app/iphones.rb +47 -0
  24. data/demo/app/london_population.rb +46 -0
  25. data/demo/app/london_population_area.rb +42 -0
  26. data/demo/app/man_vs_horse.rb +53 -0
  27. data/demo/app/mtg_modern_colors.rb +49 -0
  28. data/demo/app/mtg_modern_creatures.rb +63 -0
  29. data/demo/app/olympics_2016_medals.rb +54 -0
  30. data/demo/app/paradox.rb +57 -0
  31. data/demo/app/polish_pms.rb +53 -0
  32. data/demo/app/star_trek_voyager.rb +39 -0
  33. data/demo/app/weather_in_london.rb +62 -0
  34. data/demo/assets/d3.js +16393 -0
  35. data/demo/assets/style.css +0 -0
  36. data/demo/config.ru +39 -0
  37. data/demo/views/index.erb +21 -0
  38. data/demo/views/visualization.erb +29 -0
  39. data/lib/opal/d3/arc.rb +21 -0
  40. data/lib/opal/d3/area.rb +49 -0
  41. data/lib/opal/d3/axis.rb +77 -0
  42. data/lib/opal/d3/band_scale.rb +29 -0
  43. data/lib/opal/d3/collections.rb +10 -0
  44. data/lib/opal/d3/color.rb +78 -0
  45. data/lib/opal/d3/continuous_scale.rb +64 -0
  46. data/lib/opal/d3/creator.rb +11 -0
  47. data/lib/opal/d3/curve.rb +74 -0
  48. data/lib/opal/d3/dsv.rb +103 -0
  49. data/lib/opal/d3/ease.rb +319 -0
  50. data/lib/opal/d3/format.rb +97 -0
  51. data/lib/opal/d3/histograms.rb +44 -0
  52. data/lib/opal/d3/interpolate.rb +125 -0
  53. data/lib/opal/d3/line.rb +29 -0
  54. data/lib/opal/d3/map.rb +52 -0
  55. data/lib/opal/d3/misc.rb +15 -0
  56. data/lib/opal/d3/native.rb +84 -0
  57. data/lib/opal/d3/nest.rb +100 -0
  58. data/lib/opal/d3/ordinal_scale.rb +56 -0
  59. data/lib/opal/d3/path.rb +22 -0
  60. data/lib/opal/d3/pie.rb +23 -0
  61. data/lib/opal/d3/point_scale.rb +26 -0
  62. data/lib/opal/d3/polygon.rb +16 -0
  63. data/lib/opal/d3/quadtree.rb +95 -0
  64. data/lib/opal/d3/quantile_scale.rb +21 -0
  65. data/lib/opal/d3/quantize_scale.rb +23 -0
  66. data/lib/opal/d3/radial_area.rb +49 -0
  67. data/lib/opal/d3/radial_line.rb +29 -0
  68. data/lib/opal/d3/random.rb +12 -0
  69. data/lib/opal/d3/search.rb +28 -0
  70. data/lib/opal/d3/selection.rb +149 -0
  71. data/lib/opal/d3/sequential_scale.rb +96 -0
  72. data/lib/opal/d3/set.rb +33 -0
  73. data/lib/opal/d3/stack.rb +11 -0
  74. data/lib/opal/d3/statistics.rb +81 -0
  75. data/lib/opal/d3/symbol.rb +70 -0
  76. data/lib/opal/d3/threshold_scale.rb +23 -0
  77. data/lib/opal/d3/time_format.rb +48 -0
  78. data/lib/opal/d3/time_interval.rb +81 -0
  79. data/lib/opal/d3/transformations.rb +13 -0
  80. data/lib/opal/d3/version.rb +5 -0
  81. data/lib/opal/d3.rb +62 -0
  82. data/lib/opal-d3.rb +9 -0
  83. data/opal-d3.gemspec +20 -0
  84. data/spec/arc_spec.rb +86 -0
  85. data/spec/area_spec.rb +102 -0
  86. data/spec/axis_spec.rb +174 -0
  87. data/spec/band_scale_spec.rb +73 -0
  88. data/spec/color_spec.rb +74 -0
  89. data/spec/continuous_scale_spec.rb +217 -0
  90. data/spec/coverage_spec.rb +23 -0
  91. data/spec/creator_spec.rb +15 -0
  92. data/spec/curve_spec.rb +214 -0
  93. data/spec/dsv_spec.rb +194 -0
  94. data/spec/ease_spec.rb +370 -0
  95. data/spec/format_spec.rb +87 -0
  96. data/spec/histograms_spec.rb +61 -0
  97. data/spec/html/d3.js +16393 -0
  98. data/spec/html/index.html.erb +12 -0
  99. data/spec/interpolate_spec.rb +152 -0
  100. data/spec/line_spec.rb +58 -0
  101. data/spec/map_spec.rb +80 -0
  102. data/spec/misc_spec.rb +19 -0
  103. data/spec/nest_spec.rb +89 -0
  104. data/spec/objects_spec.rb +22 -0
  105. data/spec/ordinal_scale_spec.rb +59 -0
  106. data/spec/path_spec.rb +65 -0
  107. data/spec/pie_spec.rb +114 -0
  108. data/spec/point_scale_spec.rb +58 -0
  109. data/spec/polygon_spec.rb +51 -0
  110. data/spec/quadtree_spec.rb +128 -0
  111. data/spec/quantile_scale_spec.rb +24 -0
  112. data/spec/quantize_scale_spec.rb +40 -0
  113. data/spec/radial_area_spec.rb +127 -0
  114. data/spec/radial_line_spec.rb +54 -0
  115. data/spec/random_spec.rb +34 -0
  116. data/spec/search_spec.rb +69 -0
  117. data/spec/selection_data_spec.rb +71 -0
  118. data/spec/selection_manipulation_spec.rb +179 -0
  119. data/spec/selection_spec.rb +214 -0
  120. data/spec/sequential_scale_spec.rb +90 -0
  121. data/spec/set_spec.rb +57 -0
  122. data/spec/spec_helper.rb +2 -0
  123. data/spec/stack_spec.rb +23 -0
  124. data/spec/statistics_spec.rb +65 -0
  125. data/spec/symbol_spec.rb +121 -0
  126. data/spec/threshold_scale_spec.rb +28 -0
  127. data/spec/time_format_spec.rb +99 -0
  128. data/spec/time_interval_spec.rb +304 -0
  129. data/spec/transformations_spec.rb +51 -0
  130. metadata +258 -0
@@ -0,0 +1,84 @@
1
+ require "native"
2
+
3
+ module D3
4
+ module Native
5
+ include ::Native
6
+ def initialize(native)
7
+ raise unless native
8
+ @native = native
9
+ end
10
+
11
+ def self.included(klass)
12
+ klass.extend Helpers
13
+ end
14
+
15
+ module Helpers
16
+ # This provides ruby style and jquery style interfaces:
17
+ # obj.foo
18
+ # obj.foo = 1; obj.bar = 2
19
+ # obj.foo(1).bar(2)
20
+ def attribute_d3(ruby_name, js_name=ruby_name)
21
+ eval <<-EOF
22
+ def #{ruby_name}(new_value=`undefined`)
23
+ if `new_value !== undefined`
24
+ new_value = `null` if new_value == nil
25
+ @native.JS.#{js_name}(new_value)
26
+ self
27
+ else
28
+ value = @native.JS.#{js_name}
29
+ `value === null ? nil : value`
30
+ end
31
+ end
32
+ def #{ruby_name}=(new_value)
33
+ new_value = `null` if new_value == nil
34
+ @native.JS.#{js_name}(new_value)
35
+ end
36
+ EOF
37
+ end
38
+
39
+ # This provides ruby style and jquery style interfaces,
40
+ # and also block interface:
41
+ # obj.foo
42
+ # obj.foo = 1; obj.bar = 2
43
+ # obj.foo(1).bar(2).buzz{...}
44
+ def attribute_d3_block(ruby_name, js_name=ruby_name)
45
+ eval <<-EOF
46
+ def #{ruby_name}(new_value=`undefined`, &block)
47
+ if block_given?
48
+ @native.JS.#{js_name}(block)
49
+ self
50
+ elsif `new_value !== undefined`
51
+ new_value = `null` if new_value == nil
52
+ @native.JS.#{js_name}(new_value)
53
+ self
54
+ else
55
+ value = @native.JS.#{js_name}
56
+ `value === null ? nil : value`
57
+ end
58
+ end
59
+ def #{ruby_name}=(new_value)
60
+ new_value = `null` if new_value == nil
61
+ @native.JS.#{js_name}(new_value)
62
+ end
63
+ EOF
64
+ end
65
+
66
+ def alias_native_chainable(ruby_name, js_name=ruby_name)
67
+ eval <<-EOF
68
+ def #{ruby_name}(*args)
69
+ @native.JS.#{js_name}(*args)
70
+ self
71
+ end
72
+ EOF
73
+ end
74
+
75
+ def alias_native_new(ruby_name, js_name=ruby_name)
76
+ eval <<-EOF
77
+ def #{ruby_name}(*args)
78
+ self.class.new @native.JS.#{js_name}(*args)
79
+ end
80
+ EOF
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,100 @@
1
+ module D3
2
+ class Nest
3
+ def initialize
4
+ @native = `window.d3`.JS.nest
5
+ @depth = 0
6
+ @rollup = false
7
+ end
8
+
9
+ def key(&block)
10
+ @native.JS.key(block)
11
+ @depth += 1
12
+ self
13
+ end
14
+
15
+ def sort_keys(key=nil,&block)
16
+ if block
17
+ raise ArgumentError, "Pass block or :ascending/:descending"
18
+ else
19
+ if key == :ascending
20
+ block = `window.d3.ascending`
21
+ elsif key == :descending
22
+ block = `window.d3.descending`
23
+ else
24
+ raise ArgumentError, "Pass block or :ascending/:descending"
25
+ end
26
+ end
27
+ @native.JS.sortKeys(block)
28
+ self
29
+ end
30
+
31
+ def sort_values(key=nil,&block)
32
+ if block
33
+ raise ArgumentError, "Pass block or :ascending/:descending"
34
+ else
35
+ if key == :ascending
36
+ block = `window.d3.ascending`
37
+ elsif key == :descending
38
+ block = `window.d3.descending`
39
+ else
40
+ raise ArgumentError, "Pass block or :ascending/:descending"
41
+ end
42
+ end
43
+ @native.JS.sortValues(block)
44
+ self
45
+ end
46
+
47
+ # This is really attrocious, why don't we just return nested hash?
48
+ def map(array)
49
+ result = @native.JS.map(array)
50
+ map_map(result, @depth)
51
+ end
52
+
53
+ def entries(array)
54
+ result = @native.JS.entries(array)
55
+ map_entries(result, @depth)
56
+ end
57
+
58
+ def object(array)
59
+ @native.JS.object(array)
60
+ end
61
+
62
+ def rollup(&block)
63
+ @native.JS.rollup(block)
64
+ @rollup = true
65
+ self
66
+ end
67
+
68
+ private
69
+
70
+ def map_entries(result, depth)
71
+ if depth == 0
72
+ result
73
+ else
74
+ if @rollup and depth == 1
75
+ result.map{|o| [`o.key`, `o.value`]}
76
+ else
77
+ result.map{|o| [`o.key`, map_entries(`o.values`, depth-1)]}
78
+ end
79
+ end
80
+ end
81
+
82
+ def map_map(result, depth)
83
+ if depth == 0
84
+ result
85
+ else
86
+ output = D3::Map.new(`window.d3.map()`)
87
+ D3::Map.new(result).each do |vs, k|
88
+ output.set(k, map_map(vs, depth-1))
89
+ end
90
+ output
91
+ end
92
+ end
93
+ end
94
+
95
+ class << self
96
+ def nest
97
+ D3::Nest.new
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,56 @@
1
+ module D3
2
+ class OrdinalScale
3
+ include D3::Native
4
+
5
+ def call(t)
6
+ @native.call(t)
7
+ end
8
+ attribute_d3 :domain
9
+ attribute_d3 :range
10
+ alias_native_new :copy
11
+
12
+ # D3 is trying to reinvent Ruby symbols here
13
+ def unknown(new_value=nil)
14
+ if new_value == nil
15
+ v = @native.JS.unknown
16
+ if `JSON.stringify(v) === '{"name":"implicit"}'`
17
+ :implicit
18
+ else
19
+ v
20
+ end
21
+ else
22
+ if new_value == :implicit
23
+ new_value = `window.d3.scaleImplicit`
24
+ end
25
+ @native.JS.unknown(new_value)
26
+ self
27
+ end
28
+ end
29
+ end
30
+
31
+ class << self
32
+ def scale_ordinal(*args)
33
+ D3::OrdinalScale.new @d3.JS.scaleOrdinal(*args)
34
+ end
35
+
36
+ def scale_implicit
37
+ :implicit
38
+ end
39
+
40
+ def scheme_category_10
41
+ `window.d3.schemeCategory10`
42
+ end
43
+
44
+ def scheme_category_20
45
+ `window.d3.schemeCategory20`
46
+ end
47
+
48
+ def scheme_category_20b
49
+ `window.d3.schemeCategory20b`
50
+ end
51
+
52
+ def scheme_category_20c
53
+ `window.d3.schemeCategory20c`
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,22 @@
1
+ module D3
2
+ class Path
3
+ include D3::Native
4
+
5
+ # D3 methods aren't chainable, but there's no reason why they shouldn't be
6
+ alias_native_chainable :move_to, :moveTo
7
+ alias_native_chainable :close_path, :closePath
8
+ alias_native_chainable :line_to, :lineTo
9
+ alias_native_chainable :quadratic_curve_to, :quadraticCurveTo
10
+ alias_native_chainable :bezier_curve_to, :bezierCurveTo
11
+ alias_native_chainable :arc_to, :arcTo
12
+ alias_native_chainable :arc, :arc
13
+ alias_native_chainable :rect, :rect
14
+ alias_native :to_s, :toString
15
+ end
16
+
17
+ class << self
18
+ def path
19
+ D3::Path.new @d3.JS.path
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ module D3
2
+ class PieGenerator
3
+ include D3::Native
4
+ def call(*args)
5
+ @native.call(*args).map{|o|
6
+ `Opal.hash({ data: o.data, index: o.index, value: o.value, start_angle: o.startAngle, end_angle: o.endAngle, pad_angle: o.padAngle })`
7
+ }
8
+ end
9
+
10
+ attribute_d3_block :start_angle, :startAngle
11
+ attribute_d3_block :end_angle, :endAngle
12
+ attribute_d3_block :pad_angle, :padAngle
13
+ attribute_d3_block :value
14
+ attribute_d3_block :sort
15
+ attribute_d3_block :sort_values, :sortValues
16
+ end
17
+
18
+ class << self
19
+ def pie
20
+ D3::PieGenerator.new @d3.JS.pie
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ module D3
2
+ class PointScale
3
+ include D3::Native
4
+
5
+ def call(t)
6
+ v = @native.call(t)
7
+ `v === undefined ? nil : v`
8
+ end
9
+ attribute_d3 :domain
10
+ attribute_d3 :range
11
+ alias_native_new :copy
12
+ alias_native :bandwidth
13
+ alias_native :step
14
+ attribute_d3 :padding
15
+ attribute_d3 :align
16
+ attribute_d3 :round
17
+ # This requires argument, we might redo this not to
18
+ alias_native_chainable :range_round, :rangeRound
19
+ end
20
+
21
+ class << self
22
+ def scale_point
23
+ D3::PointScale.new @d3.JS.scalePoint
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ module D3
2
+ class << self
3
+ # This could maybe use more OO interface in addition to this?
4
+ # Like D3::Polygon.new(points).area etc.
5
+
6
+ alias_d3 :polygon_area, :polygonArea # signed area
7
+ alias_d3 :polygon_centroid, :polygonCentroid
8
+ alias_d3 :polygon_contains?, :polygonContains
9
+ alias_d3 :polygon_length, :polygonLength
10
+
11
+ def polygon_hull(points)
12
+ hull = @d3.JS.polygonHull(points)
13
+ `hull === null ? nil : hull`
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,95 @@
1
+ module D3
2
+ class Quad
3
+ include D3::Native
4
+
5
+ def internal?
6
+ `#@native.constructor === Array`
7
+ end
8
+
9
+ def leaf?
10
+ `#@native.constructor !== Array`
11
+ end
12
+
13
+ def next
14
+ return nil if internal?
15
+ return nil if `#@native.next == undefined`
16
+ D3::Quad.new(`#@native.next`)
17
+ end
18
+
19
+ def data
20
+ return nil if internal?
21
+ `#@native.data`
22
+ end
23
+
24
+ def children
25
+ return nil if leaf?
26
+ result = (0..3).map do |i|
27
+ q = `#@native[i]`
28
+ if `q == null`
29
+ nil
30
+ else
31
+ D3::Quad.new(q)
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ class QuadTree
38
+ include D3::Native
39
+ alias_native :data
40
+ alias_native :find
41
+ alias_native :size
42
+ alias_native_chainable :add
43
+ alias_native_chainable :add_all, :addAll
44
+ alias_native_chainable :cover
45
+ alias_native_chainable :remove
46
+ alias_native_chainable :remove_all, :removeAll
47
+ alias_native_new :copy
48
+ attribute_d3 :extent
49
+
50
+ # visit/visitAfter functions have stupid JS habit of using non-nil return as control
51
+ # and that messes up with languages which have automatic return
52
+ # Maybe worth rewriting to require explicit StopIteration ?
53
+ def visit
54
+ @native.JS.visit(proc do |node, x0, y0, x1, y1|
55
+ yield(D3::Quad.new(node), x0, y0, x1, y1)
56
+ end)
57
+ self
58
+ end
59
+
60
+ def visit_after
61
+ @native.JS.visitAfter(proc do |node, x0, y0, x1, y1|
62
+ yield(D3::Quad.new(node), x0, y0, x1, y1)
63
+ end)
64
+ self
65
+ end
66
+
67
+ def root
68
+ D3::Quad.new @native.JS.root
69
+ end
70
+
71
+ def x(&block)
72
+ if block_given?
73
+ @native.JS.x(block)
74
+ self
75
+ else
76
+ @native.JS.x
77
+ end
78
+ end
79
+
80
+ def y(&block)
81
+ if block_given?
82
+ @native.JS.y(block)
83
+ self
84
+ else
85
+ @native.JS.y
86
+ end
87
+ end
88
+ end
89
+
90
+ class << self
91
+ def quadtree(*args)
92
+ D3::QuadTree.new @d3.JS.quadtree(*args)
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,21 @@
1
+ module D3
2
+ class QuantileScale
3
+ include D3::Native
4
+
5
+ def call(t)
6
+ @native.call(t)
7
+ end
8
+
9
+ attribute_d3 :domain
10
+ attribute_d3 :range
11
+ alias_native :invert_extent, :invertExtent
12
+ alias_native :quantiles
13
+ alias_native_new :copy
14
+ end
15
+
16
+ class << self
17
+ def scale_quantile
18
+ D3::QuantileScale.new @d3.JS.scaleQuantile
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ module D3
2
+ class QuantizeScale
3
+ include D3::Native
4
+
5
+ def call(t)
6
+ @native.call(t)
7
+ end
8
+
9
+ attribute_d3 :domain
10
+ attribute_d3 :range
11
+ alias_native :invert_extent, :invertExtent
12
+ alias_native :ticks
13
+ alias_native :tick_format, :tickFormat
14
+ alias_native_chainable :nice
15
+ alias_native_new :copy
16
+ end
17
+
18
+ class << self
19
+ def scale_quantize
20
+ D3::QuantizeScale.new @d3.JS.scaleQuantize
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,49 @@
1
+ module D3
2
+ class RadialAreaGenerator
3
+ include D3::Native
4
+
5
+ def call(*args)
6
+ result = @native.call(*args)
7
+ `result === null ? nil : result`
8
+ end
9
+
10
+ attribute_d3_block :angle
11
+ attribute_d3_block :start_angle, :startAngle
12
+ attribute_d3_block :end_angle, :endAngle
13
+ attribute_d3_block :radius
14
+ attribute_d3_block :inner_radius, :innerRadius
15
+ attribute_d3_block :outer_radius, :outerRadius
16
+ attribute_d3_block :defined
17
+
18
+ def curve(new_value=`undefined`)
19
+ if `new_value === undefined`
20
+ D3::Curve.new @native.JS.curve
21
+ else
22
+ @native.JS.curve(new_value.to_n)
23
+ self
24
+ end
25
+ end
26
+
27
+ def line_start_angle
28
+ D3::RadialLineGenerator.new @native.JS.lineStartAngle
29
+ end
30
+
31
+ def line_end_angle
32
+ D3::RadialLineGenerator.new @native.JS.lineEndAngle
33
+ end
34
+
35
+ def line_inner_radius
36
+ D3::RadialLineGenerator.new @native.JS.lineInnerRadius
37
+ end
38
+
39
+ def line_outer_radius
40
+ D3::RadialLineGenerator.new @native.JS.lineOuterRadius
41
+ end
42
+ end
43
+
44
+ class << self
45
+ def radial_area
46
+ D3::RadialAreaGenerator.new @d3.JS.radialArea
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,29 @@
1
+ module D3
2
+ class RadialLineGenerator
3
+ include D3::Native
4
+
5
+ def call(*args)
6
+ result = @native.call(*args)
7
+ `result === null ? nil : result`
8
+ end
9
+
10
+ attribute_d3_block :angle
11
+ attribute_d3_block :radius
12
+ attribute_d3_block :defined
13
+
14
+ def curve(new_value=`undefined`)
15
+ if `new_value === undefined`
16
+ D3::Curve.new @native.JS.curve
17
+ else
18
+ @native.JS.curve(new_value.to_n)
19
+ self
20
+ end
21
+ end
22
+ end
23
+
24
+ class << self
25
+ def radial_line
26
+ D3::RadialLineGenerator.new @d3.JS.radialLine
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,12 @@
1
+ module D3
2
+ class << self
3
+ # These return functions,
4
+ # which doesn't feel very Ruby
5
+ alias_d3 :random_uniform, :randomUniform
6
+ alias_d3 :random_normal, :randomNormal
7
+ alias_d3 :random_log_normal, :randomLogNormal
8
+ alias_d3 :random_bates, :randomBates
9
+ alias_d3 :random_irwin_hall, :randomIrwinHall
10
+ alias_d3 :random_exponential, :randomExponential
11
+ end
12
+ end
@@ -0,0 +1,28 @@
1
+ # all these methods return indexes not values
2
+ module D3
3
+ class Bisector
4
+ include D3::Native
5
+ alias_native :left
6
+ alias_native :right
7
+ end
8
+
9
+ class << self
10
+ alias_d3 :ascending
11
+ alias_d3 :descending
12
+ alias_d3 :bisect
13
+ alias_d3 :bisect_left, :bisectLeft
14
+ alias_d3 :bisect_right, :bisectRight
15
+
16
+ def scan(array, &block)
17
+ if block_given?
18
+ @d3.JS.scan(array, block)
19
+ else
20
+ @d3.JS.scan(array)
21
+ end
22
+ end
23
+
24
+ def bisector(&block)
25
+ D3::Bisector.new @d3.JS.bisector(block)
26
+ end
27
+ end
28
+ end