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,319 @@
1
+ module D3
2
+ class EasePoly
3
+ include D3::Native
4
+ alias_native_new :exponent
5
+
6
+ def call(t)
7
+ @native.call(t)
8
+ end
9
+ end
10
+
11
+ class EaseBack
12
+ include D3::Native
13
+ alias_native_new :overshoot
14
+
15
+ def call(t)
16
+ @native.call(t)
17
+ end
18
+ end
19
+
20
+ class EaseElastic
21
+ include D3::Native
22
+ alias_native_new :amplitude
23
+ alias_native_new :period
24
+
25
+ def call(t)
26
+ @native.call(t)
27
+ end
28
+ end
29
+
30
+ class <<self
31
+ def ease_linear(t=nil)
32
+ if t
33
+ @d3.JS.easeLinear(t)
34
+ else
35
+ `#@d3.easeLinear`
36
+ end
37
+ end
38
+
39
+ def ease_quad(t=nil)
40
+ if t
41
+ @d3.JS.easeQuad(t)
42
+ else
43
+ `#@d3.easeQuad`
44
+ end
45
+ end
46
+
47
+ def ease_quad_in(t=nil)
48
+ if t
49
+ @d3.JS.easeQuadIn(t)
50
+ else
51
+ `#@d3.easeQuadIn`
52
+ end
53
+ end
54
+
55
+ def ease_quad_out(t=nil)
56
+ if t
57
+ @d3.JS.easeQuadOut(t)
58
+ else
59
+ `#@d3.easeQuadOut`
60
+ end
61
+ end
62
+
63
+ def ease_quad_in_out(t=nil)
64
+ if t
65
+ @d3.JS.easeQuadInOut(t)
66
+ else
67
+ `#@d3.easeQuadInOut`
68
+ end
69
+ end
70
+
71
+ def ease_cubic(t=nil)
72
+ if t
73
+ @d3.JS.easeCubic(t)
74
+ else
75
+ `#@d3.easeCubic`
76
+ end
77
+ end
78
+
79
+ def ease_cubic_in(t=nil)
80
+ if t
81
+ @d3.JS.easeCubicIn(t)
82
+ else
83
+ `#@d3.easeCubicIn`
84
+ end
85
+ end
86
+
87
+ def ease_cubic_out(t=nil)
88
+ if t
89
+ @d3.JS.easeCubicOut(t)
90
+ else
91
+ `#@d3.easeCubicOut`
92
+ end
93
+ end
94
+
95
+ def ease_cubic_in_out(t=nil)
96
+ if t
97
+ @d3.JS.easeCubicInOut(t)
98
+ else
99
+ `#@d3.easeCubicInOut`
100
+ end
101
+ end
102
+
103
+ def ease_sin(t=nil)
104
+ if t
105
+ @d3.JS.easeSin(t)
106
+ else
107
+ `#@d3.easeSin`
108
+ end
109
+ end
110
+
111
+ def ease_sin_in(t=nil)
112
+ if t
113
+ @d3.JS.easeSinIn(t)
114
+ else
115
+ `#@d3.easeSinIn`
116
+ end
117
+ end
118
+
119
+ def ease_sin_out(t=nil)
120
+ if t
121
+ @d3.JS.easeSinOut(t)
122
+ else
123
+ `#@d3.easeSinOut`
124
+ end
125
+ end
126
+
127
+ def ease_sin_in_out(t=nil)
128
+ if t
129
+ @d3.JS.easeSinInOut(t)
130
+ else
131
+ `#@d3.easeSinInOut`
132
+ end
133
+ end
134
+
135
+ def ease_exp(t=nil)
136
+ if t
137
+ @d3.JS.easeExp(t)
138
+ else
139
+ `#@d3.easeExp`
140
+ end
141
+ end
142
+
143
+ def ease_exp_in(t=nil)
144
+ if t
145
+ @d3.JS.easeExpIn(t)
146
+ else
147
+ `#@d3.easeExpIn`
148
+ end
149
+ end
150
+
151
+ def ease_exp_out(t=nil)
152
+ if t
153
+ @d3.JS.easeExpOut(t)
154
+ else
155
+ `#@d3.easeExpOut`
156
+ end
157
+ end
158
+
159
+ def ease_exp_in_out(t=nil)
160
+ if t
161
+ @d3.JS.easeExpInOut(t)
162
+ else
163
+ `#@d3.easeExpInOut`
164
+ end
165
+ end
166
+
167
+ def ease_circle(t=nil)
168
+ if t
169
+ @d3.JS.easeCircle(t)
170
+ else
171
+ `#@d3.easeCircle`
172
+ end
173
+ end
174
+
175
+ def ease_circle_in(t=nil)
176
+ if t
177
+ @d3.JS.easeCircleIn(t)
178
+ else
179
+ `#@d3.easeCircleIn`
180
+ end
181
+ end
182
+
183
+ def ease_circle_out(t=nil)
184
+ if t
185
+ @d3.JS.easeCircleOut(t)
186
+ else
187
+ `#@d3.easeCircleOut`
188
+ end
189
+ end
190
+
191
+ def ease_circle_in_out(t=nil)
192
+ if t
193
+ @d3.JS.easeCircleInOut(t)
194
+ else
195
+ `#@d3.easeCircleInOut`
196
+ end
197
+ end
198
+
199
+ def ease_bounce(t=nil)
200
+ if t
201
+ @d3.JS.easeBounce(t)
202
+ else
203
+ `#@d3.easeBounce`
204
+ end
205
+ end
206
+
207
+ def ease_bounce_in(t=nil)
208
+ if t
209
+ @d3.JS.easeBounceIn(t)
210
+ else
211
+ `#@d3.easeBounceIn`
212
+ end
213
+ end
214
+
215
+ def ease_bounce_out(t=nil)
216
+ if t
217
+ @d3.JS.easeBounceOut(t)
218
+ else
219
+ `#@d3.easeBounceOut`
220
+ end
221
+ end
222
+
223
+ def ease_bounce_in_out(t=nil)
224
+ if t
225
+ @d3.JS.easeBounceInOut(t)
226
+ else
227
+ `#@d3.easeBounceInOut`
228
+ end
229
+ end
230
+
231
+ def ease_poly_in(t=nil)
232
+ if t
233
+ @d3.JS.easePolyIn(t)
234
+ else
235
+ D3::EasePoly.new `#@d3.easePolyIn`
236
+ end
237
+ end
238
+
239
+ def ease_poly_out(t=nil)
240
+ if t
241
+ @d3.JS.easePolyOut(t)
242
+ else
243
+ D3::EasePoly.new `#@d3.easePolyOut`
244
+ end
245
+ end
246
+
247
+ def ease_poly_in_out(t=nil)
248
+ if t
249
+ @d3.JS.easePolyInOut(t)
250
+ else
251
+ D3::EasePoly.new `#@d3.easePolyInOut`
252
+ end
253
+ end
254
+
255
+ def ease_back(t=nil)
256
+ if t
257
+ @d3.JS.easeBack(t)
258
+ else
259
+ D3::EaseBack.new `#@d3.easeBack`
260
+ end
261
+ end
262
+
263
+ def ease_back_in(t=nil)
264
+ if t
265
+ @d3.JS.easeBackIn(t)
266
+ else
267
+ D3::EaseBack.new `#@d3.easeBackIn`
268
+ end
269
+ end
270
+
271
+ def ease_back_out(t=nil)
272
+ if t
273
+ @d3.JS.easeBackOut(t)
274
+ else
275
+ D3::EaseBack.new `#@d3.easeBackOut`
276
+ end
277
+ end
278
+
279
+ def ease_back_in_out(t=nil)
280
+ if t
281
+ @d3.JS.easeBackInOut(t)
282
+ else
283
+ D3::EaseBack.new `#@d3.easeBackInOut`
284
+ end
285
+ end
286
+
287
+ def ease_elastic(t=nil)
288
+ if t
289
+ @d3.JS.easeElastic(t)
290
+ else
291
+ D3::EaseElastic.new `#@d3.easeElastic`
292
+ end
293
+ end
294
+
295
+ def ease_elastic_in(t=nil)
296
+ if t
297
+ @d3.JS.easeElasticIn(t)
298
+ else
299
+ D3::EaseElastic.new `#@d3.easeElasticIn`
300
+ end
301
+ end
302
+
303
+ def ease_elastic_out(t=nil)
304
+ if t
305
+ @d3.JS.easeElasticOut(t)
306
+ else
307
+ D3::EaseElastic.new `#@d3.easeElasticOut`
308
+ end
309
+ end
310
+
311
+ def ease_elastic_in_out(t=nil)
312
+ if t
313
+ @d3.JS.easeElasticInOut(t)
314
+ else
315
+ D3::EaseElastic.new `#@d3.easeElasticInOut`
316
+ end
317
+ end
318
+ end
319
+ end
@@ -0,0 +1,97 @@
1
+ module D3
2
+ class FormatSpecifier
3
+ include D3::Native
4
+
5
+ FIELDS = %W[fill align sign symbol zero width comma precision type]
6
+ FIELDS.each do |key|
7
+ define_method(key) {
8
+ `v = #@native[key]`
9
+ `v === undefined ? nil : v`
10
+ }
11
+ define_method("#{key}=") {|v|
12
+ `#@native[key] = (v === nil ? undefined : v)`
13
+ }
14
+ end
15
+
16
+ def to_h
17
+ result = {}
18
+ FIELDS.each do |key|
19
+ result[key] = send(key)
20
+ end
21
+ result
22
+ end
23
+
24
+ def to_n
25
+ @native
26
+ end
27
+ end
28
+
29
+ class FormatLocale
30
+ include D3::Native
31
+
32
+ def format(specifier)
33
+ if specifier.is_a?(FormatSpecifier)
34
+ @native.JS.format(specifier.to_n)
35
+ else
36
+ @native.JS.format(specifier)
37
+ end
38
+ end
39
+
40
+ def format_prefix(specifier, value)
41
+ if specifier.is_a?(FormatSpecifier)
42
+ @native.JS.formatPrefix(specifier.to_n, value)
43
+ else
44
+ @native.JS.formatPrefix(specifier, value)
45
+ end
46
+ end
47
+ end
48
+
49
+
50
+ class << self
51
+ alias_d3 :precision_fixed, :precisionFixed
52
+ alias_d3 :precision_prefix, :precisionPrefix
53
+ alias_d3 :precision_round, :precisionRound
54
+
55
+ def format(specifier)
56
+ if specifier.is_a?(FormatSpecifier)
57
+ @d3.JS.format(specifier.to_n)
58
+ else
59
+ @d3.JS.format(specifier)
60
+ end
61
+ end
62
+
63
+ def format_prefix(specifier, value)
64
+ if specifier.is_a?(FormatSpecifier)
65
+ @d3.JS.formatPrefix(specifier.to_n, value)
66
+ else
67
+ @d3.JS.formatPrefix(specifier, value)
68
+ end
69
+ end
70
+
71
+ def format_specifier(specifier)
72
+ D3::FormatSpecifier.new @d3.JS.formatSpecifier(specifier)
73
+ end
74
+
75
+ def format_locale(spec={})
76
+ D3::FormatLocale.new @d3.JS.formatLocale(
77
+ {
78
+ decimal: spec.fetch("decimal", "."),
79
+ thousands: spec.fetch("thousands", ","),
80
+ grouping: spec.fetch("grouping", [3]),
81
+ currency: spec.fetch("currency", ["$", ""]),
82
+ }.to_n
83
+ )
84
+ end
85
+
86
+ def format_default_locale(spec={})
87
+ D3::FormatLocale.new @d3.JS.formatDefaultLocale(
88
+ {
89
+ decimal: spec.fetch("decimal", "."),
90
+ thousands: spec.fetch("thousands", ","),
91
+ grouping: spec.fetch("grouping", [3]),
92
+ currency: spec.fetch("currency", ["$", ""]),
93
+ }.to_n
94
+ )
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,44 @@
1
+ module D3
2
+ class Histogram
3
+ include D3::Native
4
+
5
+ def call(data)
6
+ @native.call(data)
7
+ end
8
+
9
+ def thresholds(count=nil, &block)
10
+ if block_given?
11
+ @native.JS.thresholds(block)
12
+ elsif count.is_a?(Numeric)
13
+ @native.JS.thresholds(count)
14
+ elsif count == :scott
15
+ @native.JS.thresholds{|*args| D3.threshold_scott(*args)}
16
+ elsif count == :sturges
17
+ @native.JS.thresholds{|*args| D3.threshold_sturges(*args)}
18
+ elsif count == :freedman_diaconis
19
+ @native.JS.thresholds{|*args| D3.threshold_freedman_diaconis(*args)}
20
+ else
21
+ raise ArgumentError, "Wrong use of D3::Histogram.thresholds API - pass block, number, or symbol"
22
+ end
23
+ self
24
+ end
25
+ end
26
+
27
+ class << self
28
+ def histogram
29
+ D3::Histogram.new @d3.JS.histogram
30
+ end
31
+
32
+ def threshold_freedman_diaconis(*args)
33
+ @d3.JS.thresholdFreedmanDiaconis(*args)
34
+ end
35
+
36
+ def threshold_scott(*args)
37
+ @d3.JS.thresholdScott(*args)
38
+ end
39
+
40
+ def threshold_sturges(*args)
41
+ @d3.JS.thresholdSturges(*args)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,125 @@
1
+ module D3
2
+ class << self
3
+ def interpolate_number(a=nil,b=nil)
4
+ if a == nil and b == nil
5
+ `#@d3.interpolateNumber`
6
+ else
7
+ @d3.JS.interpolateNumber(a,b)
8
+ end
9
+ end
10
+
11
+ def interpolate_round(a=nil,b=nil)
12
+ if a == nil and b == nil
13
+ `#@d3.interpolateRound`
14
+ else
15
+ @d3.JS.interpolateRound(a,b)
16
+ end
17
+ end
18
+
19
+ def interpolate_string(a=nil,b=nil)
20
+ if a == nil and b == nil
21
+ `#@d3.interpolateString`
22
+ else
23
+ @d3.JS.interpolateString(a,b)
24
+ end
25
+ end
26
+
27
+ def interpolate_array(a=nil,b=nil)
28
+ if a == nil and b == nil
29
+ `#@d3.interpolateArray`
30
+ else
31
+ @d3.JS.interpolateArray(a,b)
32
+ end
33
+ end
34
+
35
+ def interpolate_date(a=nil,b=nil)
36
+ if a == nil and b == nil
37
+ `#@d3.interpolateDate`
38
+ else
39
+ @d3.JS.interpolateDate(a,b)
40
+ end
41
+ end
42
+
43
+ # These should support gamma
44
+ def interpolate_rgb(a=nil,b=nil)
45
+ if a == nil and b == nil
46
+ `#@d3.interpolateRgb`
47
+ else
48
+ @d3.JS.interpolateRgb(a,b)
49
+ end
50
+ end
51
+
52
+ def interpolate_rgb_basis(a=nil,b=nil)
53
+ if a == nil and b == nil
54
+ `#@d3.interpolateRgbBasis`
55
+ else
56
+ @d3.JS.interpolateRgbBasis(a,b)
57
+ end
58
+ end
59
+
60
+ def interpolate_rgb_basis_closed(a=nil,b=nil)
61
+ if a == nil and b == nil
62
+ `#@d3.interpolateRgbBasisClosed`
63
+ else
64
+ @d3.JS.interpolateRgbBasisClosed(a,b)
65
+ end
66
+ end
67
+
68
+ def interpolate_hsl(a=nil,b=nil)
69
+ if a == nil and b == nil
70
+ `#@d3.interpolateHsl`
71
+ else
72
+ @d3.JS.interpolateHsl(a,b)
73
+ end
74
+ end
75
+
76
+ def interpolate_hsl_long(a=nil,b=nil)
77
+ if a == nil and b == nil
78
+ `#@d3.interpolateHslLong`
79
+ else
80
+ @d3.JS.interpolateHslLong(a,b)
81
+ end
82
+ end
83
+
84
+ def interpolate_lab(a=nil,b=nil)
85
+ if a == nil and b == nil
86
+ `#@d3.interpolateLab`
87
+ else
88
+ @d3.JS.interpolateLab(a,b)
89
+ end
90
+ end
91
+
92
+ def interpolate_hcl(a=nil,b=nil)
93
+ if a == nil and b == nil
94
+ `#@d3.interpolateHcl`
95
+ else
96
+ @d3.JS.interpolateHcl(a,b)
97
+ end
98
+ end
99
+
100
+ def interpolate_hcl_long(a=nil,b=nil)
101
+ if a == nil and b == nil
102
+ `#@d3.interpolateHclLong`
103
+ else
104
+ @d3.JS.interpolateHclLong(a,b)
105
+ end
106
+ end
107
+
108
+ def interpolate_cubehelix(a=nil,b=nil)
109
+ if a == nil and b == nil
110
+ `#@d3.interpolateCubehelix`
111
+ else
112
+ @d3.JS.interpolateCubehelix(a,b)
113
+ end
114
+ end
115
+
116
+ def interpolate_cubehelix_long(a=nil,b=nil)
117
+ if a == nil and b == nil
118
+ `#@d3.interpolateCubehelixLong`
119
+ else
120
+ @d3.JS.interpolateCubehelixLong(a,b)
121
+ end
122
+ end
123
+
124
+ end
125
+ end
@@ -0,0 +1,29 @@
1
+ module D3
2
+ class LineGenerator
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 :x
11
+ attribute_d3_block :y
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 line
26
+ D3::LineGenerator.new @d3.JS.line
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,52 @@
1
+ module D3
2
+ class Map
3
+ include D3::Native
4
+
5
+ def get(key)
6
+ result = @native.JS.get(key)
7
+ `result === undefined ? nil : result`
8
+ end
9
+ include Native
10
+ alias_native_chainable :set
11
+ alias_native_chainable :remove
12
+ alias_native_chainable :clear
13
+ alias_native :keys
14
+ alias_native :values
15
+ alias_native :size
16
+ alias_native :empty?, :empty
17
+ alias_native :has?, :has
18
+ alias_method :[], :get
19
+ alias_method :[]=, :set
20
+
21
+ def entries
22
+ @native.JS.entries().map{|o| [`o.key`, `o.value`]}
23
+ end
24
+
25
+ def to_h
26
+ `Opal.hash(#{entries})`
27
+ end
28
+
29
+ # Should that be reversed to better match ruby and to work with Enumerable?
30
+ # Or just use #to_h if you want ruby interface?
31
+ def each(&block)
32
+ @native.JS.each(block)
33
+ self
34
+ end
35
+
36
+ def inspect
37
+ "#<D3::Map: #{ to_h.inspect }>"
38
+ end
39
+ end
40
+
41
+ class << self
42
+ def map(object=nil, &block)
43
+ if block_given?
44
+ D3::Map.new(@d3.JS.map(object, proc{|x| yield(x)}))
45
+ elsif object
46
+ D3::Map.new(@d3.JS.map(object))
47
+ else
48
+ D3::Map.new(@d3.JS.map())
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,15 @@
1
+ module D3
2
+ class << self
3
+ def version
4
+ `window.d3.version`
5
+ end
6
+
7
+ def namespaces
8
+ `Opal.hash(window.d3.namespaces)`
9
+ end
10
+
11
+ def namespace(name)
12
+ `Opal.hash(window.d3.namespace(name))`
13
+ end
14
+ end
15
+ end