hyper-d3 1.0.0.lap23
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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +313 -0
- data/README.md +118 -0
- data/Rakefile +31 -0
- data/hyper-d3.gemspec +27 -0
- data/lib/d3.rb +68 -0
- data/lib/d3/arc.rb +29 -0
- data/lib/d3/area.rb +53 -0
- data/lib/d3/axis.rb +79 -0
- data/lib/d3/band_scale.rb +30 -0
- data/lib/d3/collections.rb +9 -0
- data/lib/d3/color.rb +76 -0
- data/lib/d3/color_schemes.rb +34 -0
- data/lib/d3/continuous_scale.rb +60 -0
- data/lib/d3/creator.rb +11 -0
- data/lib/d3/curve.rb +74 -0
- data/lib/d3/dsv.rb +103 -0
- data/lib/d3/ease.rb +319 -0
- data/lib/d3/format.rb +95 -0
- data/lib/d3/histograms.rb +46 -0
- data/lib/d3/interpolate.rb +125 -0
- data/lib/d3/line.rb +27 -0
- data/lib/d3/map.rb +48 -0
- data/lib/d3/misc.rb +15 -0
- data/lib/d3/native.rb +112 -0
- data/lib/d3/nest.rb +100 -0
- data/lib/d3/ordinal_scale.rb +39 -0
- data/lib/d3/path.rb +24 -0
- data/lib/d3/pie.rb +25 -0
- data/lib/d3/point_scale.rb +27 -0
- data/lib/d3/polygon.rb +18 -0
- data/lib/d3/quadtree.rb +89 -0
- data/lib/d3/quantile_scale.rb +19 -0
- data/lib/d3/quantize_scale.rb +20 -0
- data/lib/d3/radial_area.rb +55 -0
- data/lib/d3/radial_line.rb +27 -0
- data/lib/d3/random.rb +14 -0
- data/lib/d3/search.rb +30 -0
- data/lib/d3/selection.rb +151 -0
- data/lib/d3/sequential_scale.rb +31 -0
- data/lib/d3/set.rb +30 -0
- data/lib/d3/source/d3-drag.js +234 -0
- data/lib/d3/source/d3-scale-chromatic.js +484 -0
- data/lib/d3/source/d3.js +17178 -0
- data/lib/d3/stack.rb +13 -0
- data/lib/d3/statistics.rb +81 -0
- data/lib/d3/symbol.rb +70 -0
- data/lib/d3/threshold_scale.rb +22 -0
- data/lib/d3/time_format.rb +47 -0
- data/lib/d3/time_interval.rb +85 -0
- data/lib/d3/transformations.rb +16 -0
- data/lib/hyper-d3.rb +17 -0
- data/lib/hyperloop/d3/component.rb +12 -0
- data/lib/hyperloop/d3/mixin.rb +59 -0
- data/lib/hyperloop/d3/version.rb +5 -0
- data/spec/arc_spec.rb +80 -0
- data/spec/area_spec.rb +98 -0
- data/spec/axis_spec.rb +174 -0
- data/spec/band_scale_spec.rb +73 -0
- data/spec/color_spec.rb +74 -0
- data/spec/continuous_scale_spec.rb +217 -0
- data/spec/coverage_spec.rb +16 -0
- data/spec/creator_spec.rb +15 -0
- data/spec/curve_spec.rb +206 -0
- data/spec/dsv_spec.rb +194 -0
- data/spec/ease_spec.rb +370 -0
- data/spec/format_spec.rb +87 -0
- data/spec/histograms_spec.rb +61 -0
- data/spec/html/index.html.erb +11 -0
- data/spec/interpolate_spec.rb +152 -0
- data/spec/line_spec.rb +54 -0
- data/spec/map_spec.rb +80 -0
- data/spec/misc_spec.rb +21 -0
- data/spec/nest_spec.rb +89 -0
- data/spec/objects_spec.rb +22 -0
- data/spec/ordinal_scale_spec.rb +59 -0
- data/spec/path_spec.rb +65 -0
- data/spec/pie_spec.rb +114 -0
- data/spec/point_scale_spec.rb +58 -0
- data/spec/polygon_spec.rb +51 -0
- data/spec/quadtree_spec.rb +128 -0
- data/spec/quantile_scale_spec.rb +24 -0
- data/spec/quantize_scale_spec.rb +40 -0
- data/spec/radial_area_spec.rb +123 -0
- data/spec/radial_line_spec.rb +50 -0
- data/spec/random_spec.rb +34 -0
- data/spec/search_spec.rb +69 -0
- data/spec/selection_data_spec.rb +64 -0
- data/spec/selection_manipulation_spec.rb +166 -0
- data/spec/selection_spec.rb +187 -0
- data/spec/sequential_scale_spec.rb +90 -0
- data/spec/set_spec.rb +57 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/stack_spec.rb +5 -0
- data/spec/statistics_spec.rb +65 -0
- data/spec/symbol_spec.rb +116 -0
- data/spec/test_app/.gitignore +23 -0
- data/spec/test_app/Gemfile +7 -0
- data/spec/test_app/Gemfile.lock +206 -0
- data/spec/test_app/README.md +9 -0
- data/spec/test_app/Rakefile +6 -0
- data/spec/test_app/app/assets/config/manifest.js +3 -0
- data/spec/test_app/app/assets/images/.keep +0 -0
- data/spec/test_app/app/assets/javascripts/application.js +13 -0
- data/spec/test_app/app/assets/javascripts/cable.js +13 -0
- data/spec/test_app/app/assets/javascripts/channels/.keep +0 -0
- data/spec/test_app/app/assets/javascripts/data/elections_2016.rb +10 -0
- data/spec/test_app/app/assets/javascripts/data/harry_potter.rb +19 -0
- data/spec/test_app/app/assets/javascripts/data/iphones.rb +29 -0
- data/spec/test_app/app/assets/javascripts/data/london_population.rb +26 -0
- data/spec/test_app/app/assets/javascripts/data/man_vs_horse.rb +55 -0
- data/spec/test_app/app/assets/javascripts/data/mtg_modern_colors.rb +96 -0
- data/spec/test_app/app/assets/javascripts/data/mtg_modern_creatures.rb +116 -0
- data/spec/test_app/app/assets/javascripts/data/olympics_2016_medals.rb +100 -0
- data/spec/test_app/app/assets/javascripts/data/paradox.rb +60 -0
- data/spec/test_app/app/assets/javascripts/data/polish_pms.rb +28 -0
- data/spec/test_app/app/assets/javascripts/data/star_trek_voyager.rb +183 -0
- data/spec/test_app/app/assets/javascripts/data/weather_in_london.rb +381 -0
- data/spec/test_app/app/assets/javascripts/elections_2016.rb +27 -0
- data/spec/test_app/app/assets/javascripts/harry_potter.rb +42 -0
- data/spec/test_app/app/assets/javascripts/iphones.rb +54 -0
- data/spec/test_app/app/assets/javascripts/london_population.rb +53 -0
- data/spec/test_app/app/assets/javascripts/london_population_area.rb +49 -0
- data/spec/test_app/app/assets/javascripts/man_vs_horse.rb +60 -0
- data/spec/test_app/app/assets/javascripts/mtg_modern_colors.rb +56 -0
- data/spec/test_app/app/assets/javascripts/mtg_modern_creatures.rb +70 -0
- data/spec/test_app/app/assets/javascripts/olympics_2016_medals.rb +62 -0
- data/spec/test_app/app/assets/javascripts/paradox.rb +64 -0
- data/spec/test_app/app/assets/javascripts/polish_pms.rb +60 -0
- data/spec/test_app/app/assets/javascripts/star_trek_voyager.rb +44 -0
- data/spec/test_app/app/assets/javascripts/weather_in_london.rb +69 -0
- data/spec/test_app/app/assets/stylesheets/application.css +15 -0
- data/spec/test_app/app/channels/application_cable/channel.rb +4 -0
- data/spec/test_app/app/channels/application_cable/connection.rb +4 -0
- data/spec/test_app/app/controllers/application_controller.rb +27 -0
- data/spec/test_app/app/controllers/concerns/.keep +0 -0
- data/spec/test_app/app/helpers/application_helper.rb +2 -0
- data/spec/test_app/app/jobs/application_job.rb +2 -0
- data/spec/test_app/app/mailers/application_mailer.rb +4 -0
- data/spec/test_app/app/models/application_record.rb +3 -0
- data/spec/test_app/app/models/concerns/.keep +0 -0
- data/spec/test_app/app/views/application/index.erb +18 -0
- data/spec/test_app/app/views/application/visualization.erb +28 -0
- data/spec/test_app/app/views/layouts/application.html.erb +13 -0
- data/spec/test_app/bin/bundle +3 -0
- data/spec/test_app/bin/rails +4 -0
- data/spec/test_app/bin/rake +4 -0
- data/spec/test_app/bin/setup +38 -0
- data/spec/test_app/bin/update +29 -0
- data/spec/test_app/bin/yarn +11 -0
- data/spec/test_app/config.ru +5 -0
- data/spec/test_app/config/application.rb +18 -0
- data/spec/test_app/config/boot.rb +3 -0
- data/spec/test_app/config/cable.yml +10 -0
- data/spec/test_app/config/database.yml +25 -0
- data/spec/test_app/config/environment.rb +5 -0
- data/spec/test_app/config/environments/development.rb +54 -0
- data/spec/test_app/config/environments/production.rb +91 -0
- data/spec/test_app/config/environments/test.rb +42 -0
- data/spec/test_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/test_app/config/initializers/assets.rb +14 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_app/config/initializers/cookies_serializer.rb +5 -0
- data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/test_app/config/initializers/inflections.rb +16 -0
- data/spec/test_app/config/initializers/mime_types.rb +4 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/test_app/config/locales/en.yml +33 -0
- data/spec/test_app/config/puma.rb +56 -0
- data/spec/test_app/config/routes.rb +5 -0
- data/spec/test_app/config/secrets.yml +32 -0
- data/spec/test_app/config/spring.rb +6 -0
- data/spec/test_app/db/seeds.rb +7 -0
- data/spec/test_app/lib/assets/.keep +0 -0
- data/spec/test_app/lib/tasks/.keep +0 -0
- data/spec/test_app/log/.keep +0 -0
- data/spec/test_app/package.json +5 -0
- data/spec/test_app/public/404.html +67 -0
- data/spec/test_app/public/422.html +67 -0
- data/spec/test_app/public/500.html +66 -0
- data/spec/test_app/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/test_app/public/apple-touch-icon.png +0 -0
- data/spec/test_app/public/favicon.ico +0 -0
- data/spec/test_app/public/robots.txt +1 -0
- data/spec/test_app/test/application_system_test_case.rb +5 -0
- data/spec/test_app/test/controllers/.keep +0 -0
- data/spec/test_app/test/fixtures/.keep +0 -0
- data/spec/test_app/test/fixtures/files/.keep +0 -0
- data/spec/test_app/test/helpers/.keep +0 -0
- data/spec/test_app/test/integration/.keep +0 -0
- data/spec/test_app/test/mailers/.keep +0 -0
- data/spec/test_app/test/models/.keep +0 -0
- data/spec/test_app/test/system/.keep +0 -0
- data/spec/test_app/test/test_helper.rb +10 -0
- data/spec/test_app/tmp/.keep +0 -0
- data/spec/test_app/vendor/.keep +0 -0
- data/spec/threshold_scale_spec.rb +28 -0
- data/spec/time_format_spec.rb +100 -0
- data/spec/time_interval_spec.rb +314 -0
- data/spec/transformations_spec.rb +51 -0
- data/startrekvoyager.png +0 -0
- metadata +529 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
describe "D3 coverage" do
|
|
2
|
+
# Test code is here because opal-repl doesn't support aggregate_failures mode
|
|
3
|
+
native_methods = `Opal.hash(window.d3)`.keys.sort
|
|
4
|
+
nice_methods = native_methods.map{|m| m.gsub(/([a-z])(?=[A-Z0-9])/, "\\1_").downcase }
|
|
5
|
+
|
|
6
|
+
# format conflict with base ruby
|
|
7
|
+
nice_methods.each do |method|
|
|
8
|
+
it method do
|
|
9
|
+
if D3.respond_to?(method)
|
|
10
|
+
# OK
|
|
11
|
+
else
|
|
12
|
+
skip "not implemented yet"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
describe "d3 - creator" do
|
|
2
|
+
after(:each) do
|
|
3
|
+
D3.select("#test-area").html("")
|
|
4
|
+
end
|
|
5
|
+
let(:root) { D3.select("#test-area") }
|
|
6
|
+
let(:html) { root.html }
|
|
7
|
+
|
|
8
|
+
it "d3.creator" do
|
|
9
|
+
expect(D3.creator("div")).to be_instance_of(D3::Creator)
|
|
10
|
+
D3.select("div").append(D3.creator("span"))
|
|
11
|
+
expect(html).to eq(
|
|
12
|
+
"<span></span>"
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
data/spec/curve_spec.rb
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
describe "d3 - curve" do
|
|
2
|
+
let(:curve) { D3.send(name) }
|
|
3
|
+
# 5 x-x
|
|
4
|
+
# / \
|
|
5
|
+
# 4 x | x
|
|
6
|
+
# \ /
|
|
7
|
+
# 3 x
|
|
8
|
+
# 0 1 2 3 4
|
|
9
|
+
let(:data) { [[0, 4], [1, 5], [2, 5], [3, 3], [4, 4]] }
|
|
10
|
+
let(:line) { D3.line.curve(curve).(data) }
|
|
11
|
+
let(:rounded) { line.gsub(/\d+\.\d+/){$&.to_f.round(2)} }
|
|
12
|
+
describe "curve_basis" do
|
|
13
|
+
let(:name){ :curve_basis }
|
|
14
|
+
it do
|
|
15
|
+
expect(curve).to be_instance_of(D3::Curve)
|
|
16
|
+
expect(rounded).to eq("M0,4L0.17,4.17C0.33,4.33,0.67,4.67,1,4.83C1.33,5,1.67,5,2,4.67C2.33,4.33,2.67,3.67,3,3.5C3.33,3.33,3.67,3.67,3.83,3.83L4,4")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe "curve_basis_closed" do
|
|
21
|
+
let(:name){ :curve_basis_closed }
|
|
22
|
+
it do
|
|
23
|
+
expect(curve).to be_instance_of(D3::Curve)
|
|
24
|
+
expect(rounded).to eq("M1,4.83C1.33,5,1.67,5,2,4.67C2.33,4.33,2.67,3.67,3,3.5C3.33,3.33,3.67,3.67,3.17,3.83C2.67,4,1.33,4,0.83,4.17C0.33,4.33,0.67,4.67,1,4.83")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "curve_basis_open" do
|
|
29
|
+
let(:name){ :curve_basis_open }
|
|
30
|
+
it do
|
|
31
|
+
expect(curve).to be_instance_of(D3::Curve)
|
|
32
|
+
expect(rounded).to eq("M1,4.83C1.33,5,1.67,5,2,4.67C2.33,4.33,2.67,3.67,3,3.5")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe "curve_bundle" do
|
|
37
|
+
let(:name){ :curve_bundle }
|
|
38
|
+
it do
|
|
39
|
+
expect(curve).to be_instance_of(D3::CurveBundle)
|
|
40
|
+
expect(rounded).to eq("M0,4L0.17,4.14C0.33,4.28,0.67,4.57,1,4.71C1.33,4.85,1.67,4.85,2,4.57C2.33,4.28,2.67,3.72,3,3.58C3.33,3.43,3.67,3.72,3.83,3.86L4,4")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe ".beta" do
|
|
44
|
+
let(:curve) { D3.curve_bundle.beta(0.5) }
|
|
45
|
+
it do
|
|
46
|
+
expect(curve).to be_instance_of(D3::CurveBundle)
|
|
47
|
+
expect(rounded).to eq("M0,4L0.17,4.08C0.33,4.17,0.67,4.33,1,4.42C1.33,4.5,1.67,4.5,2,4.33C2.33,4.17,2.67,3.83,3,3.75C3.33,3.67,3.67,3.83,3.83,3.92L4,4")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe "curve_cardinal" do
|
|
53
|
+
let(:name){ :curve_cardinal }
|
|
54
|
+
it do
|
|
55
|
+
expect(curve).to be_instance_of(D3::CurveCardinal)
|
|
56
|
+
expect(rounded).to eq("M0,4C0,4,0.67,4.83,1,5C1.33,5.17,1.67,5.33,2,5C2.33,4.67,2.67,3.17,3,3C3.33,2.83,4,4,4,4")
|
|
57
|
+
end
|
|
58
|
+
describe ".tension" do
|
|
59
|
+
let(:curve) { D3.curve_cardinal.tension(0.5) }
|
|
60
|
+
it do
|
|
61
|
+
expect(curve).to be_instance_of(D3::CurveCardinal)
|
|
62
|
+
expect(rounded).to eq("M0,4C0,4,0.83,4.92,1,5C1.17,5.08,1.83,5.17,2,5C2.17,4.83,2.83,3.08,3,3C3.17,2.92,4,4,4,4")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "curve_cardinal_closed" do
|
|
68
|
+
let(:name){ :curve_cardinal_closed }
|
|
69
|
+
it do
|
|
70
|
+
expect(curve).to be_instance_of(D3::CurveCardinal)
|
|
71
|
+
expect(rounded).to eq("M1,5C1.33,5.17,1.67,5.33,2,5C2.33,4.67,2.67,3.17,3,3C3.33,2.83,4.5,3.83,4,4C3.5,4.17,0.5,3.83,0,4C-0.5,4.17,0.67,4.83,1,5")
|
|
72
|
+
end
|
|
73
|
+
describe ".tension" do
|
|
74
|
+
let(:curve) { D3.curve_cardinal_closed.tension(0.5) }
|
|
75
|
+
it do
|
|
76
|
+
expect(curve).to be_instance_of(D3::CurveCardinal)
|
|
77
|
+
expect(rounded).to eq("M1,5C1.17,5.08,1.83,5.17,2,5C2.17,4.83,2.83,3.08,3,3C3.17,2.92,4.25,3.92,4,4C3.75,4.08,0.25,3.92,0,4C-0.25,4.08,0.83,4.92,1,5")
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe "curve_cardinal_open" do
|
|
83
|
+
let(:name){ :curve_cardinal_open }
|
|
84
|
+
it do
|
|
85
|
+
expect(curve).to be_instance_of(D3::CurveCardinal)
|
|
86
|
+
expect(rounded).to eq("M1,5C1.33,5.17,1.67,5.33,2,5C2.33,4.67,2.67,3.17,3,3")
|
|
87
|
+
end
|
|
88
|
+
describe ".tension" do
|
|
89
|
+
let(:curve) { D3.curve_cardinal_open.tension(0.5) }
|
|
90
|
+
it do
|
|
91
|
+
expect(curve).to be_instance_of(D3::CurveCardinal)
|
|
92
|
+
expect(rounded).to eq("M1,5C1.17,5.08,1.83,5.17,2,5C2.17,4.83,2.83,3.08,3,3")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe "curve_catmull_rom" do
|
|
98
|
+
let(:name){ :curve_catmull_rom }
|
|
99
|
+
it do
|
|
100
|
+
expect(curve).to be_instance_of(D3::CurveCatmullRom)
|
|
101
|
+
expect(rounded).to eq("M0,4C0,4,0.63,4.85,1,5C1.31,5.13,1.71,5.18,2,5C2.43,4.73,2.62,3.06,3,3C3.3,2.95,4,4,4,4")
|
|
102
|
+
end
|
|
103
|
+
describe ".alpha" do
|
|
104
|
+
let(:curve) { D3.curve_catmull_rom.alpha(0.75) }
|
|
105
|
+
it do
|
|
106
|
+
expect(curve).to be_instance_of(D3::CurveCatmullRom)
|
|
107
|
+
expect(rounded).to eq("M0,4C0,4,0.61,4.85,1,5C1.3,5.11,1.72,5.13,2,5C2.51,4.76,2.59,3,3,3C3.29,3,4,4,4,4")
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
describe "curve_catmull_rom_closed" do
|
|
113
|
+
let(:name){ :curve_catmull_rom_closed }
|
|
114
|
+
it do
|
|
115
|
+
expect(curve).to be_instance_of(D3::CurveCatmullRom)
|
|
116
|
+
expect(rounded).to eq("M1,5C1.31,5.13,1.71,5.18,2,5C2.43,4.73,2.62,3.06,3,3C3.3,2.95,4.09,3.79,4,4C3.85,4.35,0.15,3.65,0,4C-0.09,4.21,0.63,4.85,1,5")
|
|
117
|
+
end
|
|
118
|
+
describe ".alpha" do
|
|
119
|
+
let(:curve) { D3.curve_catmull_rom_closed.alpha(0.75) }
|
|
120
|
+
it do
|
|
121
|
+
expect(curve).to be_instance_of(D3::CurveCatmullRom)
|
|
122
|
+
expect(rounded).to eq("M1,5C1.3,5.11,1.72,5.13,2,5C2.51,4.76,2.59,3,3,3C3.29,3,3.96,3.77,4,4C4.08,4.5,-0.08,3.5,0,4C0.04,4.23,0.61,4.85,1,5")
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
describe "curve_catmull_rom_open" do
|
|
128
|
+
let(:name){ :curve_catmull_rom_open }
|
|
129
|
+
it do
|
|
130
|
+
expect(curve).to be_instance_of(D3::CurveCatmullRom)
|
|
131
|
+
expect(rounded).to eq("M1,5C1.31,5.13,1.71,5.18,2,5C2.43,4.73,2.62,3.06,3,3")
|
|
132
|
+
end
|
|
133
|
+
describe ".alpha" do
|
|
134
|
+
let(:curve) { D3.curve_catmull_rom_open.alpha(0.75) }
|
|
135
|
+
it do
|
|
136
|
+
expect(curve).to be_instance_of(D3::CurveCatmullRom)
|
|
137
|
+
expect(rounded).to eq("M1,5C1.3,5.11,1.72,5.13,2,5C2.51,4.76,2.59,3,3,3")
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
describe "curve_linear" do
|
|
143
|
+
let(:name){ :curve_linear }
|
|
144
|
+
it do
|
|
145
|
+
expect(curve).to be_instance_of(D3::Curve)
|
|
146
|
+
expect(rounded).to eq("M0,4L1,5L2,5L3,3L4,4")
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe "curve_linear_closed" do
|
|
151
|
+
let(:name){ :curve_linear_closed }
|
|
152
|
+
it do
|
|
153
|
+
expect(curve).to be_instance_of(D3::Curve)
|
|
154
|
+
expect(rounded).to eq("M0,4L1,5L2,5L3,3L4,4Z")
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
describe "curve_monotone_x" do
|
|
159
|
+
let(:name){ :curve_monotone_x }
|
|
160
|
+
it do
|
|
161
|
+
expect(curve).to be_instance_of(D3::Curve)
|
|
162
|
+
expect(rounded).to eq("M0,4C0.33,4.5,0.67,5,1,5C1.33,5,1.67,5,2,5C2.33,5,2.67,3,3,3C3.33,3,3.67,3.5,4,4")
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
describe "curve_monotone_y" do
|
|
167
|
+
let(:name){ :curve_monotone_y }
|
|
168
|
+
it do
|
|
169
|
+
expect(curve).to be_instance_of(D3::Curve)
|
|
170
|
+
expect(rounded).to eq("M0,4C0.17,4.33,0.33,4.67,1,5C1,5,2,5,2,5C2.67,4.33,3,3.67,3,3C3,3.33,3.5,3.67,4,4")
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
describe "curve_natural" do
|
|
175
|
+
let(:name){ :curve_natural }
|
|
176
|
+
it do
|
|
177
|
+
expect(curve).to be_instance_of(D3::Curve)
|
|
178
|
+
expect(rounded).to eq("M0,4C0.33,4.36,0.67,4.71,1,5C1.33,5.29,1.67,5.5,2,5C2.33,4.5,2.67,3.29,3,3C3.33,2.71,3.67,3.36,4,4")
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
describe "curve_step" do
|
|
183
|
+
let(:name){ :curve_step }
|
|
184
|
+
it do
|
|
185
|
+
expect(curve).to be_instance_of(D3::Curve)
|
|
186
|
+
expect(rounded).to eq("M0,4L0.5,4L0.5,5L1.5,5L1.5,5L2.5,5L2.5,3L3.5,3L3.5,4L4,4")
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
describe "curve_step_after" do
|
|
191
|
+
let(:name){ :curve_step_after }
|
|
192
|
+
it do
|
|
193
|
+
expect(curve).to be_instance_of(D3::Curve)
|
|
194
|
+
expect(rounded).to eq("M0,4L1,4L1,5L2,5L2,5L3,5L3,3L4,3L4,4")
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
describe "curve_step_before" do
|
|
199
|
+
let(:name){ :curve_step_before }
|
|
200
|
+
it do
|
|
201
|
+
expect(curve).to be_instance_of(D3::Curve)
|
|
202
|
+
expect(rounded).to eq("M0,4L0,5L1,5L1,5L2,5L2,3L3,3L3,4L4,4")
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
end
|
data/spec/dsv_spec.rb
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
describe "d3 - dsv" do
|
|
2
|
+
let(:csv_example) do
|
|
3
|
+
"Year,Make,Model,Length\n"+
|
|
4
|
+
"1997,Ford,E350,2.34\n"+
|
|
5
|
+
"2000,Mercury,Cougar,2.38\n"
|
|
6
|
+
end
|
|
7
|
+
let(:tsv_example) do
|
|
8
|
+
"Year\tMake\tModel\tLength\n"+
|
|
9
|
+
"1997\tFord\tE350\t2.34\n"+
|
|
10
|
+
"2000\tMercury\tCougar\t2.38\n"
|
|
11
|
+
end
|
|
12
|
+
let(:dsv_example) do
|
|
13
|
+
"Year;Make;Model;Length\n"+
|
|
14
|
+
"1997;Ford;E350;2.34\n"+
|
|
15
|
+
"2000;Mercury;Cougar;2.38\n"
|
|
16
|
+
end
|
|
17
|
+
let(:rows_example) {
|
|
18
|
+
[
|
|
19
|
+
["Year", "Make", "Model", "Length"],
|
|
20
|
+
["1997", "Ford", "E350", "2.34"],
|
|
21
|
+
["2000", "Mercury", "Cougar", "2.38"],
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
let(:objs_example) {
|
|
25
|
+
[
|
|
26
|
+
{"Year"=>"1997", "Make"=>"Ford", "Model"=>"E350", "Length"=>"2.34"},
|
|
27
|
+
{"Year"=>"2000", "Make"=>"Mercury", "Model"=>"Cougar", "Length"=>"2.38"},
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
let(:csv_format) { D3.dsv_format(",") }
|
|
31
|
+
let(:tsv_format) { D3.dsv_format("\t") }
|
|
32
|
+
let(:dsv_format) { D3.dsv_format(";") }
|
|
33
|
+
let(:format_row) { proc{|(y,f,m,l)|
|
|
34
|
+
["converted", (Integer(y) rescue y), f, m, (Float(l) rescue l)]
|
|
35
|
+
}}
|
|
36
|
+
let(:filter_row) { proc{|d|
|
|
37
|
+
format_row.(d) if d[0] == "2000" or d[0] == "1997"
|
|
38
|
+
}}
|
|
39
|
+
let(:format_obj) { proc{|o|
|
|
40
|
+
{y: o["Year"].to_i, f:o["Make"], m:o["Model"], l:o["Length"].to_f}
|
|
41
|
+
}}
|
|
42
|
+
let(:filter_obj) { proc{|o|
|
|
43
|
+
format_obj.(o) if o["Year"] == "2000"
|
|
44
|
+
}}
|
|
45
|
+
|
|
46
|
+
it "d3.dsv_format" do
|
|
47
|
+
expect(D3.dsv_format(";")).to be_instance_of(D3::DsvFormat)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "dsv_format.parse_rows" do
|
|
51
|
+
expect(dsv_format.parse_rows(dsv_example)).to eq(rows_example)
|
|
52
|
+
expect(dsv_format.parse_rows(dsv_example, format_row)).to eq(
|
|
53
|
+
dsv_format.parse_rows(dsv_example, &format_row)
|
|
54
|
+
)
|
|
55
|
+
expect(dsv_format.parse_rows(dsv_example, format_row)).to eq([
|
|
56
|
+
["converted", "Year", "Make", "Model", "Length"],
|
|
57
|
+
["converted", 1997, "Ford", "E350", 2.34],
|
|
58
|
+
["converted", 2000, "Mercury", "Cougar", 2.38],
|
|
59
|
+
])
|
|
60
|
+
expect(dsv_format.parse_rows(dsv_example, filter_row)).to eq([
|
|
61
|
+
["converted", 1997, "Ford", "E350", 2.34],
|
|
62
|
+
["converted", 2000, "Mercury", "Cougar", 2.38],
|
|
63
|
+
])
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "d3.csv_parse_rows" do
|
|
67
|
+
expect(D3.csv_parse_rows(csv_example)).to eq(
|
|
68
|
+
csv_format.parse_rows(csv_example))
|
|
69
|
+
expect(dsv_format.parse_rows(dsv_example)).to eq(
|
|
70
|
+
csv_format.parse_rows(csv_example))
|
|
71
|
+
expect(D3.csv_parse_rows(csv_example, format_row)).to eq(
|
|
72
|
+
csv_format.parse_rows(csv_example, format_row))
|
|
73
|
+
expect(D3.csv_parse_rows(csv_example, &format_row)).to eq(
|
|
74
|
+
csv_format.parse_rows(csv_example, &format_row))
|
|
75
|
+
expect(D3.csv_parse_rows(csv_example, filter_row)).to eq(
|
|
76
|
+
csv_format.parse_rows(csv_example, filter_row))
|
|
77
|
+
expect(D3.csv_parse_rows(csv_example, &filter_row)).to eq(
|
|
78
|
+
csv_format.parse_rows(csv_example, &filter_row))
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "d3.tsv_parse_rows" do
|
|
82
|
+
expect(D3.tsv_parse_rows(tsv_example)).to eq(
|
|
83
|
+
tsv_format.parse_rows(tsv_example))
|
|
84
|
+
expect(dsv_format.parse_rows(dsv_example)).to eq(
|
|
85
|
+
tsv_format.parse_rows(tsv_example))
|
|
86
|
+
expect(D3.tsv_parse_rows(tsv_example, format_row)).to eq(
|
|
87
|
+
tsv_format.parse_rows(tsv_example, format_row))
|
|
88
|
+
expect(D3.tsv_parse_rows(tsv_example, &format_row)).to eq(
|
|
89
|
+
tsv_format.parse_rows(tsv_example, &format_row))
|
|
90
|
+
expect(D3.tsv_parse_rows(tsv_example, filter_row)).to eq(
|
|
91
|
+
tsv_format.parse_rows(tsv_example, filter_row))
|
|
92
|
+
expect(D3.tsv_parse_rows(tsv_example, &filter_row)).to eq(
|
|
93
|
+
tsv_format.parse_rows(tsv_example, &filter_row))
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# It's awful practice not to include final \n,
|
|
97
|
+
# but it's not our place to workaround D3's bugs here
|
|
98
|
+
it "dsv_format.format_rows" do
|
|
99
|
+
expect(dsv_format.format_rows(rows_example)).to eq(dsv_example.chomp)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "d3.csv_format_rows" do
|
|
103
|
+
expect(csv_format.format_rows(rows_example)).to eq(csv_example.chomp)
|
|
104
|
+
expect(D3.csv_format_rows(rows_example)).to eq(csv_example.chomp)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "d3.tsv_format_rows" do
|
|
108
|
+
expect(tsv_format.format_rows(rows_example)).to eq(tsv_example.chomp)
|
|
109
|
+
expect(D3.tsv_format_rows(rows_example)).to eq(tsv_example.chomp)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# We have ways to enforce proper Hash order, maybe it's a good idea
|
|
113
|
+
it "dsv_format.parse" do
|
|
114
|
+
expect(dsv_format.parse(dsv_example)).to eq(objs_example)
|
|
115
|
+
expect(dsv_format.parse(dsv_example, format_obj)).to eq(
|
|
116
|
+
dsv_format.parse(dsv_example, &format_obj))
|
|
117
|
+
expect(dsv_format.parse(dsv_example, &format_obj)).to eq([
|
|
118
|
+
{"y"=>1997, "f"=>"Ford", "m"=>"E350", "l"=>2.34},
|
|
119
|
+
{"y"=>2000, "f"=>"Mercury", "m"=>"Cougar", "l"=>2.38},
|
|
120
|
+
])
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it "dsv_format.parse - filtering" do
|
|
124
|
+
expect(dsv_format.parse(dsv_example, &filter_obj)).to eq(
|
|
125
|
+
dsv_format.parse(dsv_example, filter_obj))
|
|
126
|
+
expect(dsv_format.parse(dsv_example, &filter_obj)).to eq([
|
|
127
|
+
{"y"=>2000, "f"=>"Mercury", "m"=>"Cougar", "l"=>2.38},
|
|
128
|
+
])
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it "d3.csv_parse" do
|
|
132
|
+
expect(D3.csv_parse(csv_example)).to eq(
|
|
133
|
+
csv_format.parse(csv_example))
|
|
134
|
+
expect(dsv_format.parse(dsv_example)).to eq(
|
|
135
|
+
csv_format.parse(csv_example))
|
|
136
|
+
expect(D3.csv_parse(csv_example, format_obj)).to eq(
|
|
137
|
+
csv_format.parse(csv_example, format_obj))
|
|
138
|
+
expect(D3.csv_parse(csv_example, &format_obj)).to eq(
|
|
139
|
+
csv_format.parse(csv_example, &format_obj))
|
|
140
|
+
expect(D3.csv_parse(csv_example, filter_obj)).to eq(
|
|
141
|
+
csv_format.parse(csv_example, filter_obj))
|
|
142
|
+
expect(D3.csv_parse(csv_example, &filter_obj)).to eq(
|
|
143
|
+
csv_format.parse(csv_example, &filter_obj))
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it "d3.tsv_parse" do
|
|
147
|
+
expect(D3.tsv_parse(tsv_example)).to eq(
|
|
148
|
+
tsv_format.parse(tsv_example))
|
|
149
|
+
expect(dsv_format.parse(dsv_example)).to eq(
|
|
150
|
+
tsv_format.parse(tsv_example))
|
|
151
|
+
expect(D3.tsv_parse(tsv_example, format_obj)).to eq(
|
|
152
|
+
tsv_format.parse(tsv_example, format_obj))
|
|
153
|
+
expect(D3.tsv_parse(tsv_example, &format_obj)).to eq(
|
|
154
|
+
tsv_format.parse(tsv_example, &format_obj))
|
|
155
|
+
expect(D3.tsv_parse(tsv_example, filter_obj)).to eq(
|
|
156
|
+
tsv_format.parse(tsv_example, filter_obj))
|
|
157
|
+
expect(D3.tsv_parse(tsv_example, &filter_obj)).to eq(
|
|
158
|
+
tsv_format.parse(tsv_example, &filter_obj))
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Same awful idea of not including final \n
|
|
162
|
+
it "dsv_format.format" do
|
|
163
|
+
expect(dsv_format.format(objs_example)).to eq(dsv_example.chomp)
|
|
164
|
+
expect(dsv_format.format(objs_example, ["Year", "Make", "Speed"])).to eq(
|
|
165
|
+
"Year;Make;Speed\n"+
|
|
166
|
+
"1997;Ford;\n"+
|
|
167
|
+
"2000;Mercury;"
|
|
168
|
+
)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "d3.tsv_format" do
|
|
172
|
+
expect(tsv_format.format(objs_example, ["Year", "Make", "Speed"])).to eq(
|
|
173
|
+
"Year\tMake\tSpeed\n"+
|
|
174
|
+
"1997\tFord\t\n"+
|
|
175
|
+
"2000\tMercury\t"
|
|
176
|
+
)
|
|
177
|
+
expect(tsv_format.format(objs_example)).to eq(
|
|
178
|
+
D3.tsv_format(objs_example))
|
|
179
|
+
expect(tsv_format.format(objs_example, ["Year", "Make", "Speed"])).to eq(
|
|
180
|
+
D3.tsv_format(objs_example, ["Year", "Make", "Speed"]))
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
it "d3.csv_format" do
|
|
184
|
+
expect(csv_format.format(objs_example, ["Year", "Make", "Speed"])).to eq(
|
|
185
|
+
"Year,Make,Speed\n"+
|
|
186
|
+
"1997,Ford,\n"+
|
|
187
|
+
"2000,Mercury,"
|
|
188
|
+
)
|
|
189
|
+
expect(csv_format.format(objs_example)).to eq(
|
|
190
|
+
D3.csv_format(objs_example))
|
|
191
|
+
expect(csv_format.format(objs_example, ["Year", "Make", "Speed"])).to eq(
|
|
192
|
+
D3.csv_format(objs_example, ["Year", "Make", "Speed"]))
|
|
193
|
+
end
|
|
194
|
+
end
|
data/spec/ease_spec.rb
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
describe "d3-ease" do
|
|
2
|
+
let(:range) { (0..20).map{|x| x / 20 }}
|
|
3
|
+
let(:curve) { range.map{|t| D3.send(ease, t).round(4) }}
|
|
4
|
+
let(:f) { D3.send(ease) }
|
|
5
|
+
let(:curve_f) { range.map{|t| f.call(t).round(4) } }
|
|
6
|
+
describe "d3.ease_linear" do
|
|
7
|
+
let(:ease) { :ease_linear }
|
|
8
|
+
it do
|
|
9
|
+
expect(curve).to eq(curve_f)
|
|
10
|
+
expect(curve).to eq([0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1])
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "d3.ease_quad" do
|
|
15
|
+
let(:ease) { :ease_quad }
|
|
16
|
+
it do
|
|
17
|
+
expect(curve).to eq(curve_f)
|
|
18
|
+
expect(curve).to eq([0, 0.005, 0.02, 0.045, 0.08, 0.125, 0.18, 0.245, 0.32, 0.405, 0.5, 0.595, 0.68, 0.755, 0.82, 0.875, 0.92, 0.955, 0.98, 0.995, 1])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe "d3.ease_quad_in" do
|
|
23
|
+
let(:ease) { :ease_quad_in }
|
|
24
|
+
it do
|
|
25
|
+
expect(curve).to eq(curve_f)
|
|
26
|
+
expect(curve).to eq([0, 0.0025, 0.01, 0.0225, 0.04, 0.0625, 0.09, 0.1225, 0.16, 0.2025, 0.25, 0.3025, 0.36, 0.4225, 0.49, 0.5625, 0.64, 0.7225, 0.81, 0.9025, 1])
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "d3.ease_quad_out" do
|
|
31
|
+
let(:ease) { :ease_quad_out }
|
|
32
|
+
it do
|
|
33
|
+
expect(curve).to eq(curve_f)
|
|
34
|
+
expect(curve).to eq([0, 0.0975, 0.19, 0.2775, 0.36, 0.4375, 0.51, 0.5775, 0.64, 0.6975, 0.75, 0.7975, 0.84, 0.8775, 0.91, 0.9375, 0.96, 0.9775, 0.99, 0.9975, 1])
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe "d3.ease_quad_in_out" do
|
|
39
|
+
let(:ease) { :ease_quad_in_out }
|
|
40
|
+
it do
|
|
41
|
+
expect(curve).to eq(curve_f)
|
|
42
|
+
expect(curve).to eq([0, 0.005, 0.02, 0.045, 0.08, 0.125, 0.18, 0.245, 0.32, 0.405, 0.5, 0.595, 0.68, 0.755, 0.82, 0.875, 0.92, 0.955, 0.98, 0.995, 1])
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe "d3.ease_cubic" do
|
|
47
|
+
let(:ease) { :ease_cubic }
|
|
48
|
+
it do
|
|
49
|
+
expect(curve).to eq(curve_f)
|
|
50
|
+
expect(curve).to eq([0, 0.0005, 0.004, 0.0135, 0.032, 0.0625, 0.108, 0.1715, 0.256, 0.3645, 0.5, 0.6355, 0.744, 0.8285, 0.892, 0.9375, 0.968, 0.9865, 0.996, 0.9995, 1])
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe "d3.ease_cubic_in" do
|
|
55
|
+
let(:ease) { :ease_cubic_in }
|
|
56
|
+
it do
|
|
57
|
+
expect(curve).to eq(curve_f)
|
|
58
|
+
expect(curve).to eq([0, 0.0001, 0.001, 0.0034, 0.008, 0.0156, 0.027, 0.0429, 0.064, 0.0911, 0.125, 0.1664, 0.216, 0.2746, 0.343, 0.4219, 0.512, 0.6141, 0.729, 0.8574, 1])
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe "d3.ease_cubic_out" do
|
|
63
|
+
let(:ease) { :ease_cubic_out }
|
|
64
|
+
it do
|
|
65
|
+
expect(curve).to eq(curve_f)
|
|
66
|
+
expect(curve).to eq([0, 0.1426, 0.271, 0.3859, 0.488, 0.5781, 0.657, 0.7254, 0.784, 0.8336, 0.875, 0.9089, 0.936, 0.9571, 0.973, 0.9844, 0.992, 0.9966, 0.999, 0.9999, 1])
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "d3.ease_cubic_in_out" do
|
|
71
|
+
let(:ease) { :ease_cubic_in_out }
|
|
72
|
+
it do
|
|
73
|
+
expect(curve).to eq(curve_f)
|
|
74
|
+
expect(curve).to eq([0, 0.0005, 0.004, 0.0135, 0.032, 0.0625, 0.108, 0.1715, 0.256, 0.3645, 0.5, 0.6355, 0.744, 0.8285, 0.892, 0.9375, 0.968, 0.9865, 0.996, 0.9995, 1])
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe "d3.ease_sin" do
|
|
79
|
+
let(:ease) { :ease_sin }
|
|
80
|
+
it do
|
|
81
|
+
expect(curve).to eq(curve_f)
|
|
82
|
+
expect(curve).to eq([0, 0.0062, 0.0245, 0.0545, 0.0955, 0.1464, 0.2061, 0.273, 0.3455, 0.4218, 0.5, 0.5782, 0.6545, 0.727, 0.7939, 0.8536, 0.9045, 0.9455, 0.9755, 0.9938, 1])
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe "d3.ease_sin_in" do
|
|
87
|
+
let(:ease) { :ease_sin_in }
|
|
88
|
+
it do
|
|
89
|
+
expect(curve).to eq(curve_f)
|
|
90
|
+
expect(curve).to eq([0, 0.0031, 0.0123, 0.0276, 0.0489, 0.0761, 0.109, 0.1474, 0.191, 0.2396, 0.2929, 0.3506, 0.4122, 0.4775, 0.546, 0.6173, 0.691, 0.7666, 0.8436, 0.9215, 1])
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe "d3.ease_sin_out" do
|
|
95
|
+
let(:ease) { :ease_sin_out }
|
|
96
|
+
it do
|
|
97
|
+
expect(curve).to eq(curve_f)
|
|
98
|
+
expect(curve).to eq([0, 0.0785, 0.1564, 0.2334, 0.309, 0.3827, 0.454, 0.5225, 0.5878, 0.6494, 0.7071, 0.7604, 0.809, 0.8526, 0.891, 0.9239, 0.9511, 0.9724, 0.9877, 0.9969, 1])
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe "d3.ease_sin_in_out" do
|
|
103
|
+
let(:ease) { :ease_sin_in_out }
|
|
104
|
+
it do
|
|
105
|
+
expect(curve).to eq(curve_f)
|
|
106
|
+
expect(curve).to eq([0, 0.0062, 0.0245, 0.0545, 0.0955, 0.1464, 0.2061, 0.273, 0.3455, 0.4218, 0.5, 0.5782, 0.6545, 0.727, 0.7939, 0.8536, 0.9045, 0.9455, 0.9755, 0.9938, 1])
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe "d3.ease_exp" do
|
|
111
|
+
let(:ease) { :ease_exp }
|
|
112
|
+
it do
|
|
113
|
+
expect(curve).to eq(curve_f)
|
|
114
|
+
expect(curve).to eq([0.0005, 0.001, 0.002, 0.0039, 0.0078, 0.0156, 0.0313, 0.0625, 0.125, 0.25, 0.5, 0.75, 0.875, 0.9375, 0.9688, 0.9844, 0.9922, 0.9961, 0.998, 0.999, 0.9995])
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe "d3.ease_exp_in" do
|
|
119
|
+
let(:ease) { :ease_exp_in }
|
|
120
|
+
it do
|
|
121
|
+
expect(curve).to eq(curve_f)
|
|
122
|
+
expect(curve).to eq([0.001, 0.0014, 0.002, 0.0028, 0.0039, 0.0055, 0.0078, 0.011, 0.0156, 0.0221, 0.0313, 0.0442, 0.0625, 0.0884, 0.125, 0.1768, 0.25, 0.3536, 0.5, 0.7071, 1])
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
describe "d3.ease_exp_out" do
|
|
127
|
+
let(:ease) { :ease_exp_out }
|
|
128
|
+
it do
|
|
129
|
+
expect(curve).to eq(curve_f)
|
|
130
|
+
expect(curve).to eq([0, 0.2929, 0.5, 0.6464, 0.75, 0.8232, 0.875, 0.9116, 0.9375, 0.9558, 0.9688, 0.9779, 0.9844, 0.989, 0.9922, 0.9945, 0.9961, 0.9972, 0.998, 0.9986, 0.999])
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
describe "d3.ease_exp_in_out" do
|
|
135
|
+
let(:ease) { :ease_exp_in_out }
|
|
136
|
+
it do
|
|
137
|
+
expect(curve).to eq(curve_f)
|
|
138
|
+
expect(curve).to eq([0.0005, 0.001, 0.002, 0.0039, 0.0078, 0.0156, 0.0313, 0.0625, 0.125, 0.25, 0.5, 0.75, 0.875, 0.9375, 0.9688, 0.9844, 0.9922, 0.9961, 0.998, 0.999, 0.9995])
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
describe "d3.ease_circle" do
|
|
143
|
+
let(:ease) { :ease_circle }
|
|
144
|
+
it do
|
|
145
|
+
expect(curve).to eq(curve_f)
|
|
146
|
+
expect(curve).to eq([0, 0.0025, 0.0101, 0.023, 0.0417, 0.067, 0.1, 0.1429, 0.2, 0.2821, 0.5, 0.7179, 0.8, 0.8571, 0.9, 0.933, 0.9583, 0.977, 0.9899, 0.9975, 1])
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe "d3.ease_circle_in" do
|
|
151
|
+
let(:ease) { :ease_circle_in }
|
|
152
|
+
it do
|
|
153
|
+
expect(curve).to eq(curve_f)
|
|
154
|
+
expect(curve).to eq([0, 0.0013, 0.005, 0.0113, 0.0202, 0.0318, 0.0461, 0.0633, 0.0835, 0.107, 0.134, 0.1648, 0.2, 0.2401, 0.2859, 0.3386, 0.4, 0.4732, 0.5641, 0.6878, 1])
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
describe "d3.ease_circle_out" do
|
|
159
|
+
let(:ease) { :ease_circle_out }
|
|
160
|
+
it do
|
|
161
|
+
expect(curve).to eq(curve_f)
|
|
162
|
+
expect(curve).to eq([0, 0.3122, 0.4359, 0.5268, 0.6, 0.6614, 0.7141, 0.7599, 0.8, 0.8352, 0.866, 0.893, 0.9165, 0.9367, 0.9539, 0.9682, 0.9798, 0.9887, 0.995, 0.9987, 1])
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
describe "d3.ease_circle_in_out" do
|
|
167
|
+
let(:ease) { :ease_circle_in_out }
|
|
168
|
+
it do
|
|
169
|
+
expect(curve).to eq(curve_f)
|
|
170
|
+
expect(curve).to eq([0, 0.0025, 0.0101, 0.023, 0.0417, 0.067, 0.1, 0.1429, 0.2, 0.2821, 0.5, 0.7179, 0.8, 0.8571, 0.9, 0.933, 0.9583, 0.977, 0.9899, 0.9975, 1])
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
describe "d3.ease_bounce" do
|
|
175
|
+
let(:ease) { :ease_bounce }
|
|
176
|
+
it do
|
|
177
|
+
expect(curve).to eq(curve_f)
|
|
178
|
+
expect(curve).to eq([0, 0.0189, 0.0756, 0.1702, 0.3025, 0.4727, 0.6806, 0.9264, 0.91, 0.8189, 0.7656, 0.7502, 0.7725, 0.8327, 0.9306, 0.9727, 0.94, 0.9452, 0.9881, 0.9845, 1])
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
describe "d3.ease_bounce_in" do
|
|
183
|
+
let(:ease) { :ease_bounce_in }
|
|
184
|
+
it do
|
|
185
|
+
expect(curve).to eq(curve_f)
|
|
186
|
+
expect(curve).to eq([0, 0.0155, 0.0119, 0.0548, 0.06, 0.0273, 0.0694, 0.1673, 0.2275, 0.2498, 0.2344, 0.1811, 0.09, 0.0736, 0.3194, 0.5273, 0.6975, 0.8298, 0.9244, 0.9811, 1])
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
describe "d3.ease_bounce_out" do
|
|
191
|
+
let(:ease) { :ease_bounce_out }
|
|
192
|
+
it do
|
|
193
|
+
expect(curve).to eq(curve_f)
|
|
194
|
+
expect(curve).to eq([0, 0.0189, 0.0756, 0.1702, 0.3025, 0.4727, 0.6806, 0.9264, 0.91, 0.8189, 0.7656, 0.7502, 0.7725, 0.8327, 0.9306, 0.9727, 0.94, 0.9452, 0.9881, 0.9845, 1])
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
describe "d3.ease_bounce_in_out" do
|
|
199
|
+
let(:ease) { :ease_bounce_in_out }
|
|
200
|
+
it do
|
|
201
|
+
expect(curve).to eq(curve_f)
|
|
202
|
+
expect(curve).to eq([0, 0.0059, 0.03, 0.0347, 0.1138, 0.1172, 0.045, 0.1597, 0.3488, 0.4622, 0.5, 0.5378, 0.6512, 0.8403, 0.955, 0.8828, 0.8863, 0.9653, 0.97, 0.9941, 1])
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
describe "d3.ease_poly_in" do
|
|
207
|
+
let(:ease) { :ease_poly_in }
|
|
208
|
+
it do
|
|
209
|
+
expect(curve).to eq(curve_f)
|
|
210
|
+
expect(curve).to eq([0, 0.0001, 0.001, 0.0034, 0.008, 0.0156, 0.027, 0.0429, 0.064, 0.0911, 0.125, 0.1664, 0.216, 0.2746, 0.343, 0.4219, 0.512, 0.6141, 0.729, 0.8574, 1])
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
describe "custom exponent" do
|
|
214
|
+
let(:f) { D3.send(ease).exponent(2) }
|
|
215
|
+
it do
|
|
216
|
+
expect(curve_f).to eq([0, 0.0025, 0.01, 0.0225, 0.04, 0.0625, 0.09, 0.1225, 0.16, 0.2025, 0.25, 0.3025, 0.36, 0.4225, 0.49, 0.5625, 0.64, 0.7225, 0.81, 0.9025, 1])
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
describe "d3.ease_poly_out" do
|
|
222
|
+
let(:ease) { :ease_poly_out }
|
|
223
|
+
it do
|
|
224
|
+
expect(curve).to eq(curve_f)
|
|
225
|
+
expect(curve).to eq([0, 0.1426, 0.271, 0.3859, 0.488, 0.5781, 0.657, 0.7254, 0.784, 0.8336, 0.875, 0.9089, 0.936, 0.9571, 0.973, 0.9844, 0.992, 0.9966, 0.999, 0.9999, 1])
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
describe "custom exponent" do
|
|
229
|
+
let(:f) { D3.send(ease).exponent(2) }
|
|
230
|
+
it do
|
|
231
|
+
expect(curve_f).to eq([0, 0.0975, 0.19, 0.2775, 0.36, 0.4375, 0.51, 0.5775, 0.64, 0.6975, 0.75, 0.7975, 0.84, 0.8775, 0.91, 0.9375, 0.96, 0.9775, 0.99, 0.9975, 1])
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
describe "d3.ease_poly_in_out" do
|
|
237
|
+
let(:ease) { :ease_poly_in_out }
|
|
238
|
+
it do
|
|
239
|
+
expect(curve).to eq(curve_f)
|
|
240
|
+
expect(curve).to eq([0, 0.0005, 0.004, 0.0135, 0.032, 0.0625, 0.108, 0.1715, 0.256, 0.3645, 0.5, 0.6355, 0.744, 0.8285, 0.892, 0.9375, 0.968, 0.9865, 0.996, 0.9995, 1])
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
describe "custom exponent" do
|
|
244
|
+
let(:f) { D3.send(ease).exponent(2) }
|
|
245
|
+
it do
|
|
246
|
+
expect(curve_f).to eq([0, 0.005, 0.02, 0.045, 0.08, 0.125, 0.18, 0.245, 0.32, 0.405, 0.5, 0.595, 0.68, 0.755, 0.82, 0.875, 0.92, 0.955, 0.98, 0.995, 1])
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
describe "d3.ease_back_in" do
|
|
252
|
+
let(:ease) { :ease_back_in }
|
|
253
|
+
it do
|
|
254
|
+
expect(curve).to eq(curve_f)
|
|
255
|
+
expect(curve).to eq([0, -0.0039, -0.0143, -0.0292, -0.0465, -0.0641, -0.0802, -0.0926, -0.0994, -0.0984, -0.0877, -0.0653, -0.029, 0.023, 0.0929, 0.1826, 0.2942, 0.4297, 0.5912, 0.7806, 1])
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
describe "custom overshoot" do
|
|
259
|
+
let(:f) { D3.send(ease).overshoot(4) }
|
|
260
|
+
it do
|
|
261
|
+
expect(curve_f).to eq([0, -0.0094, -0.035, -0.0731, -0.12, -0.1719, -0.225, -0.2756, -0.32, -0.3544, -0.375, -0.3781, -0.36, -0.3169, -0.245, -0.1406, 0, 0.1806, 0.405, 0.6769, 1])
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
describe "d3.ease_back_out" do
|
|
267
|
+
let(:ease) { :ease_back_out }
|
|
268
|
+
it do
|
|
269
|
+
expect(curve).to eq(curve_f)
|
|
270
|
+
expect(curve).to eq([0, 0.2194, 0.4088, 0.5703, 0.7058, 0.8174, 0.9071, 0.977, 1.029, 1.0653, 1.0877, 1.0984, 1.0994, 1.0926, 1.0802, 1.0641, 1.0465, 1.0292, 1.0143, 1.0039, 1])
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
describe "custom overshoot" do
|
|
274
|
+
let(:f) { D3.send(ease).overshoot(4) }
|
|
275
|
+
it do
|
|
276
|
+
expect(curve_f).to eq([0, 0.3231, 0.595, 0.8194, 1, 1.1406, 1.245, 1.3169, 1.36, 1.3781, 1.375, 1.3544, 1.32, 1.2756, 1.225, 1.1719, 1.12, 1.0731, 1.035, 1.0094, 1])
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
describe "d3.ease_back" do
|
|
282
|
+
let(:ease) { :ease_back }
|
|
283
|
+
it do
|
|
284
|
+
expect(curve).to eq(curve_f)
|
|
285
|
+
expect(curve).to eq([0, -0.0072, -0.0232, -0.0401, -0.0497, -0.0438, -0.0145, 0.0464, 0.1471, 0.2956, 0.5, 0.7044, 0.8529, 0.9536, 1.0145, 1.0438, 1.0497, 1.0401, 1.0232, 1.0072, 1])
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
describe "custom overshoot" do
|
|
289
|
+
let(:f) { D3.send(ease).overshoot(4) }
|
|
290
|
+
it do
|
|
291
|
+
expect(curve_f).to eq([0, -0.0175, -0.06, -0.1125, -0.16, -0.1875, -0.18, -0.1225, 0, 0.2025, 0.5, 0.7975, 1, 1.1225, 1.18, 1.1875, 1.16, 1.1125, 1.06, 1.0175, 1])
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
describe "d3.ease_back_in_out" do
|
|
297
|
+
let(:ease) { :ease_back_in_out }
|
|
298
|
+
it do
|
|
299
|
+
expect(curve).to eq(curve_f)
|
|
300
|
+
expect(curve).to eq([0, -0.0072, -0.0232, -0.0401, -0.0497, -0.0438, -0.0145, 0.0464, 0.1471, 0.2956, 0.5, 0.7044, 0.8529, 0.9536, 1.0145, 1.0438, 1.0497, 1.0401, 1.0232, 1.0072, 1])
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
describe "custom overshoot" do
|
|
304
|
+
let(:f) { D3.send(ease).overshoot(4) }
|
|
305
|
+
it do
|
|
306
|
+
expect(curve_f).to eq([0, -0.0175, -0.06, -0.1125, -0.16, -0.1875, -0.18, -0.1225, 0, 0.2025, 0.5, 0.7975, 1, 1.1225, 1.18, 1.1875, 1.16, 1.1125, 1.06, 1.0175, 1])
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
describe "d3.ease_elastic_in" do
|
|
312
|
+
let(:ease) { :ease_elastic_in }
|
|
313
|
+
it do
|
|
314
|
+
expect(curve).to eq(curve_f)
|
|
315
|
+
expect(curve).to eq([-0.0005, 0.0007, 0.002, 0.0014, -0.002, -0.0055, -0.0039, 0.0055, 0.0156, 0.011, -0.0156, -0.0442, -0.0313, 0.0442, 0.125, 0.0884, -0.125, -0.3536, -0.25, 0.3536, 1])
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
describe "custom amplitude/period" do
|
|
319
|
+
let(:f) { D3.send(ease).amplitude(2).period(0.2) }
|
|
320
|
+
it do
|
|
321
|
+
expect(curve_f).to eq([0.001, -0.0024, -0.002, 0.0048, 0.0039, -0.0096, -0.0078, 0.0191, 0.0156, -0.0383, -0.0313, 0.0765, 0.0625, -0.1531, -0.125, 0.3062, 0.25, -0.6124, -0.5, 1.2247, 1])
|
|
322
|
+
end
|
|
323
|
+
end
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
describe "d3.ease_elastic_out" do
|
|
327
|
+
let(:ease) { :ease_elastic_out }
|
|
328
|
+
it do
|
|
329
|
+
expect(curve).to eq(curve_f)
|
|
330
|
+
expect(curve).to eq([0, 0.6464, 1.25, 1.3536, 1.125, 0.9116, 0.875, 0.9558, 1.0313, 1.0442, 1.0156, 0.989, 0.9844, 0.9945, 1.0039, 1.0055, 1.002, 0.9986, 0.998, 0.9993, 1.0005])
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
describe "custom amplitude/period" do
|
|
334
|
+
let(:f) { D3.send(ease).amplitude(2).period(0.2) }
|
|
335
|
+
it do
|
|
336
|
+
expect(curve_f).to eq([0, -0.2247, 1.5, 1.6124, 0.75, 0.6938, 1.125, 1.1531, 0.9375, 0.9235, 1.0313, 1.0383, 0.9844, 0.9809, 1.0078, 1.0096, 0.9961, 0.9952, 1.002, 1.0024, 0.999])
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
describe "d3.ease_elastic" do
|
|
342
|
+
let(:ease) { :ease_elastic }
|
|
343
|
+
it do
|
|
344
|
+
expect(curve).to eq(curve_f)
|
|
345
|
+
expect(curve).to eq([0, 0.6464, 1.25, 1.3536, 1.125, 0.9116, 0.875, 0.9558, 1.0313, 1.0442, 1.0156, 0.989, 0.9844, 0.9945, 1.0039, 1.0055, 1.002, 0.9986, 0.998, 0.9993, 1.0005])
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
describe "custom amplitude/period" do
|
|
349
|
+
let(:f) { D3.send(ease).amplitude(2).period(0.2) }
|
|
350
|
+
it do
|
|
351
|
+
expect(curve_f).to eq([0, -0.2247, 1.5, 1.6124, 0.75, 0.6938, 1.125, 1.1531, 0.9375, 0.9235, 1.0313, 1.0383, 0.9844, 0.9809, 1.0078, 1.0096, 0.9961, 0.9952, 1.002, 1.0024, 0.999])
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
describe "d3.ease_elastic_in_out" do
|
|
357
|
+
let(:ease) { :ease_elastic_in_out }
|
|
358
|
+
it do
|
|
359
|
+
expect(curve).to eq(curve_f)
|
|
360
|
+
expect(curve).to eq([-0.0002, 0.001, -0.001, -0.002, 0.0078, -0.0078, -0.0156, 0.0625, -0.0625, -0.125, 0.5, 1.125, 1.0625, 0.9375, 1.0156, 1.0078, 0.9922, 1.002, 1.001, 0.999, 1.0002])
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
describe "custom amplitude/period" do
|
|
364
|
+
let(:f) { D3.send(ease).amplitude(2).period(0.2) }
|
|
365
|
+
it do
|
|
366
|
+
expect(curve_f).to eq([0.0005, -0.001, 0.002, -0.0039, 0.0078, -0.0156, 0.0313, -0.0625, 0.125, -0.25, 0.5, 1.25, 0.875, 1.0625, 0.9688, 1.0156, 0.9922, 1.0039, 0.998, 1.001, 0.9995])
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
end
|