opal-d3 0.0.20170205
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/README.md +7 -0
- data/Rakefile +31 -0
- data/d3.js +16393 -0
- data/demo/Gemfile +4 -0
- data/demo/README.md +7 -0
- data/demo/app/data/elections_2016.rb +10 -0
- data/demo/app/data/harry_potter.rb +19 -0
- data/demo/app/data/iphones.rb +29 -0
- data/demo/app/data/london_population.rb +26 -0
- data/demo/app/data/man_vs_horse.rb +55 -0
- data/demo/app/data/mtg_modern_colors.rb +96 -0
- data/demo/app/data/mtg_modern_creatures.rb +116 -0
- data/demo/app/data/olympics_2016_medals.rb +100 -0
- data/demo/app/data/paradox.rb +60 -0
- data/demo/app/data/polish_pms.rb +28 -0
- data/demo/app/data/star_trek_voyager.rb +183 -0
- data/demo/app/data/weather_in_london.rb +381 -0
- data/demo/app/elections_2016.rb +19 -0
- data/demo/app/harry_potter.rb +35 -0
- data/demo/app/iphones.rb +47 -0
- data/demo/app/london_population.rb +46 -0
- data/demo/app/london_population_area.rb +42 -0
- data/demo/app/man_vs_horse.rb +53 -0
- data/demo/app/mtg_modern_colors.rb +49 -0
- data/demo/app/mtg_modern_creatures.rb +63 -0
- data/demo/app/olympics_2016_medals.rb +54 -0
- data/demo/app/paradox.rb +57 -0
- data/demo/app/polish_pms.rb +53 -0
- data/demo/app/star_trek_voyager.rb +39 -0
- data/demo/app/weather_in_london.rb +62 -0
- data/demo/assets/d3.js +16393 -0
- data/demo/assets/style.css +0 -0
- data/demo/config.ru +39 -0
- data/demo/views/index.erb +21 -0
- data/demo/views/visualization.erb +29 -0
- data/lib/opal/d3/arc.rb +21 -0
- data/lib/opal/d3/area.rb +49 -0
- data/lib/opal/d3/axis.rb +77 -0
- data/lib/opal/d3/band_scale.rb +29 -0
- data/lib/opal/d3/collections.rb +10 -0
- data/lib/opal/d3/color.rb +78 -0
- data/lib/opal/d3/continuous_scale.rb +64 -0
- data/lib/opal/d3/creator.rb +11 -0
- data/lib/opal/d3/curve.rb +74 -0
- data/lib/opal/d3/dsv.rb +103 -0
- data/lib/opal/d3/ease.rb +319 -0
- data/lib/opal/d3/format.rb +97 -0
- data/lib/opal/d3/histograms.rb +44 -0
- data/lib/opal/d3/interpolate.rb +125 -0
- data/lib/opal/d3/line.rb +29 -0
- data/lib/opal/d3/map.rb +52 -0
- data/lib/opal/d3/misc.rb +15 -0
- data/lib/opal/d3/native.rb +84 -0
- data/lib/opal/d3/nest.rb +100 -0
- data/lib/opal/d3/ordinal_scale.rb +56 -0
- data/lib/opal/d3/path.rb +22 -0
- data/lib/opal/d3/pie.rb +23 -0
- data/lib/opal/d3/point_scale.rb +26 -0
- data/lib/opal/d3/polygon.rb +16 -0
- data/lib/opal/d3/quadtree.rb +95 -0
- data/lib/opal/d3/quantile_scale.rb +21 -0
- data/lib/opal/d3/quantize_scale.rb +23 -0
- data/lib/opal/d3/radial_area.rb +49 -0
- data/lib/opal/d3/radial_line.rb +29 -0
- data/lib/opal/d3/random.rb +12 -0
- data/lib/opal/d3/search.rb +28 -0
- data/lib/opal/d3/selection.rb +149 -0
- data/lib/opal/d3/sequential_scale.rb +96 -0
- data/lib/opal/d3/set.rb +33 -0
- data/lib/opal/d3/stack.rb +11 -0
- data/lib/opal/d3/statistics.rb +81 -0
- data/lib/opal/d3/symbol.rb +70 -0
- data/lib/opal/d3/threshold_scale.rb +23 -0
- data/lib/opal/d3/time_format.rb +48 -0
- data/lib/opal/d3/time_interval.rb +81 -0
- data/lib/opal/d3/transformations.rb +13 -0
- data/lib/opal/d3/version.rb +5 -0
- data/lib/opal/d3.rb +62 -0
- data/lib/opal-d3.rb +9 -0
- data/opal-d3.gemspec +20 -0
- data/spec/arc_spec.rb +86 -0
- data/spec/area_spec.rb +102 -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 +23 -0
- data/spec/creator_spec.rb +15 -0
- data/spec/curve_spec.rb +214 -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/d3.js +16393 -0
- data/spec/html/index.html.erb +12 -0
- data/spec/interpolate_spec.rb +152 -0
- data/spec/line_spec.rb +58 -0
- data/spec/map_spec.rb +80 -0
- data/spec/misc_spec.rb +19 -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 +127 -0
- data/spec/radial_line_spec.rb +54 -0
- data/spec/random_spec.rb +34 -0
- data/spec/search_spec.rb +69 -0
- data/spec/selection_data_spec.rb +71 -0
- data/spec/selection_manipulation_spec.rb +179 -0
- data/spec/selection_spec.rb +214 -0
- data/spec/sequential_scale_spec.rb +90 -0
- data/spec/set_spec.rb +57 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/stack_spec.rb +23 -0
- data/spec/statistics_spec.rb +65 -0
- data/spec/symbol_spec.rb +121 -0
- data/spec/threshold_scale_spec.rb +28 -0
- data/spec/time_format_spec.rb +99 -0
- data/spec/time_interval_spec.rb +304 -0
- data/spec/transformations_spec.rb +51 -0
- metadata +258 -0
@@ -0,0 +1,183 @@
|
|
1
|
+
require "ostruct"
|
2
|
+
|
3
|
+
# From imdb
|
4
|
+
StarTrekVoyager = [
|
5
|
+
[1, 1, "Caretaker", 7.3],
|
6
|
+
[1, 2, "Parallax", 7.1],
|
7
|
+
[1, 3, "Time and Again", 7.1],
|
8
|
+
[1, 4, "Phage", 7.1],
|
9
|
+
[1, 5, "The Cloud", 6.4],
|
10
|
+
[1, 6, "Eye of the Needle", 8.1],
|
11
|
+
[1, 7, "Ex Post Facto", 6.6],
|
12
|
+
[1, 8, "Emanations", 6.6],
|
13
|
+
[1, 9, "Prime Factors", 7.3],
|
14
|
+
[1, 10, "State of Flux", 7.6],
|
15
|
+
[1, 11, "Heroes and Demons", 6.7],
|
16
|
+
[1, 12, "Cathexis", 6.7],
|
17
|
+
[1, 13, "Faces", 7.2],
|
18
|
+
[1, 14, "Jetrel", 7.2],
|
19
|
+
[1, 15, "Learning Curve", 7.1],
|
20
|
+
[2, 1, "The 37's", 7.3],
|
21
|
+
[2, 2, "Initiations", 6.5],
|
22
|
+
[2, 3, "Projections", 7.9],
|
23
|
+
[2, 4, "Elogium", 5.9],
|
24
|
+
[2, 5, "Non Sequitur", 6.9],
|
25
|
+
[2, 6, "Twisted", 7.0],
|
26
|
+
[2, 7, "Parturition", 6.3],
|
27
|
+
[2, 8, "Persistence of Vision", 6.9],
|
28
|
+
[2, 9, "Tattoo", 6.2],
|
29
|
+
[2, 10, "Cold Fire", 7.2],
|
30
|
+
[2, 11, "Maneuvers", 7.1],
|
31
|
+
[2, 12, "Resistance", 7.0],
|
32
|
+
[2, 13, "Prototype", 7.5],
|
33
|
+
[2, 14, "Alliances", 7.2],
|
34
|
+
[2, 15, "Threshold", 5.2],
|
35
|
+
[2, 16, "Meld", 7.9],
|
36
|
+
[2, 17, "Dreadnought", 7.6],
|
37
|
+
[2, 18, "Death Wish", 8.3],
|
38
|
+
[2, 19, "Lifesigns", 7.4],
|
39
|
+
[2, 20, "Investigations", 7.4],
|
40
|
+
[2, 21, "Deadlock", 8.2],
|
41
|
+
[2, 22, "Innocence", 6.6],
|
42
|
+
[2, 23, "The Thaw", 7.3],
|
43
|
+
[2, 24, "Tuvix", 7.5],
|
44
|
+
[2, 25, "Resolutions", 7.3],
|
45
|
+
[2, 26, "Basics: Part 1", 7.8],
|
46
|
+
[3, 1, "Basics: Part 2", 7.8],
|
47
|
+
[3, 2, "Flashback", 7.7],
|
48
|
+
[3, 3, "The Chute", 6.7],
|
49
|
+
[3, 4, "The Swarm", 7.0],
|
50
|
+
[3, 5, "False Profits", 6.6],
|
51
|
+
[3, 6, "Remember", 7.1],
|
52
|
+
[3, 7, "Sacred Ground", 5.8],
|
53
|
+
[3, 8, "Future's End: Part 1", 8.3],
|
54
|
+
[3, 9, "Future's End: Part 2", 8.2],
|
55
|
+
[3, 10, "Warlord", 6.7],
|
56
|
+
[3, 11, "The Q and the Grey", 7.2],
|
57
|
+
[3, 12, "Macrocosm", 7.2],
|
58
|
+
[3, 13, "Fair Trade", 6.7],
|
59
|
+
[3, 14, "Alter Ego", 6.6],
|
60
|
+
[3, 15, "Coda", 7.0],
|
61
|
+
[3, 16, "Blood Fever", 7.2],
|
62
|
+
[3, 17, "Unity", 7.8],
|
63
|
+
[3, 18, "Darkling", 6.4],
|
64
|
+
[3, 19, "Rise", 6.8],
|
65
|
+
[3, 20, "Favorite Son", 6.0],
|
66
|
+
[3, 21, "Before and After", 7.8],
|
67
|
+
[3, 22, "Real Life", 7.3],
|
68
|
+
[3, 23, "Distant Origin", 8.5],
|
69
|
+
[3, 24, "Displaced", 7.4],
|
70
|
+
[3, 25, "Worst Case Scenario", 8.1],
|
71
|
+
[3, 26, "Scorpion: Part 1", 8.9],
|
72
|
+
[4, 1, "Scorpion: Part 2", 8.8],
|
73
|
+
[4, 2, "The Gift", 7.8],
|
74
|
+
[4, 3, "Day of Honor", 7.3],
|
75
|
+
[4, 4, "Nemesis", 6.8],
|
76
|
+
[4, 5, "Revulsion", 7.4],
|
77
|
+
[4, 6, "The Raven", 7.3],
|
78
|
+
[4, 7, "Scientific Method", 7.9],
|
79
|
+
[4, 8, "Year of Hell: Part 1", 8.8],
|
80
|
+
[4, 9, "Year of Hell: Part 2", 8.6],
|
81
|
+
[4, 10, "Random Thoughts", 6.8],
|
82
|
+
[4, 11, "Concerning Flight", 6.8],
|
83
|
+
[4, 12, "Mortal Coil", 6.7],
|
84
|
+
[4, 13, "Waking Moments", 7.6],
|
85
|
+
[4, 14, "Message in a Bottle", 8.8],
|
86
|
+
[4, 15, "Hunters", 7.8],
|
87
|
+
[4, 16, "Prey", 8.1],
|
88
|
+
[4, 17, "Retrospect", 6.8],
|
89
|
+
[4, 18, "The Killing Game: Part 1", 7.8],
|
90
|
+
[4, 19, "The Killing Game: Part 2", 7.7],
|
91
|
+
[4, 20, "Vis À Vis", 6.6],
|
92
|
+
[4, 21, "The Omega Directive", 7.4],
|
93
|
+
[4, 22, "Unforgettable", 6.4],
|
94
|
+
[4, 23, "Living Witness", 8.8],
|
95
|
+
[4, 24, "Demon", 7.1],
|
96
|
+
[4, 25, "One", 8.1],
|
97
|
+
[4, 26, "Hope and Fear", 8.1],
|
98
|
+
[5, 1, "Night", 7.7],
|
99
|
+
[5, 2, "Drone", 8.5],
|
100
|
+
[5, 3, "Extreme Risk", 6.8],
|
101
|
+
[5, 4, "In the Flesh", 7.9],
|
102
|
+
[5, 5, "Once Upon a Time", 6.3],
|
103
|
+
[5, 6, "Timeless", 8.7],
|
104
|
+
[5, 7, "Infinite Regress", 7.6],
|
105
|
+
[5, 8, "Nothing Human", 7.1],
|
106
|
+
[5, 9, "Thirty Days", 7.2],
|
107
|
+
[5, 10, "Counterpoint", 7.8],
|
108
|
+
[5, 11, "Latent Image", 8.3],
|
109
|
+
[5, 12, "Bride of Chaotica!", 7.4],
|
110
|
+
[5, 13, "Gravity", 7.3],
|
111
|
+
[5, 14, "Bliss", 7.6],
|
112
|
+
[5, 15, "Dark Frontier", 8.4],
|
113
|
+
[5, 16, "Dark Frontier", 8.4],
|
114
|
+
[5, 17, "The Disease", 6.7],
|
115
|
+
[5, 18, "Course: Oblivion", 7.7],
|
116
|
+
[5, 19, "The Fight", 5.3],
|
117
|
+
[5, 20, "Think Tank", 7.6],
|
118
|
+
[5, 21, "Juggernaut", 6.8],
|
119
|
+
[5, 22, "Someone to Watch Over Me", 8.1],
|
120
|
+
[5, 23, "11:59", 6.6],
|
121
|
+
[5, 24, "Relativity", 8.5],
|
122
|
+
[5, 25, "Warhead", 7.1],
|
123
|
+
[5, 26, "Equinox: Part 1", 8.4],
|
124
|
+
[6, 1, "Equinox: Part 2", 8.2],
|
125
|
+
[6, 2, "Survival Instinct", 7.5],
|
126
|
+
[6, 3, "Barge of the Dead", 6.4],
|
127
|
+
[6, 4, "Tinker Tenor Doctor Spy", 8.5],
|
128
|
+
[6, 5, "Alice", 6.5],
|
129
|
+
[6, 6, "Riddles", 7.3],
|
130
|
+
[6, 7, "Dragon's Teeth", 7.6],
|
131
|
+
[6, 8, "One Small Step", 7.6],
|
132
|
+
[6, 9, "The Voyager Conspiracy", 7.4],
|
133
|
+
[6, 10, "Pathfinder", 8.3],
|
134
|
+
[6, 11, "Fair Haven", 6.2],
|
135
|
+
[6, 12, "Blink of an Eye", 8.9],
|
136
|
+
[6, 13, "Virtuoso", 7.1],
|
137
|
+
[6, 14, "Memorial", 7.0],
|
138
|
+
[6, 15, "Tsunkatse", 7.1],
|
139
|
+
[6, 16, "Collective", 7.3],
|
140
|
+
[6, 17, "Spirit Folk", 6.2],
|
141
|
+
[6, 18, "Ashes to Ashes", 6.9],
|
142
|
+
[6, 19, "Child's Play", 7.4],
|
143
|
+
[6, 20, "Good Shepherd", 7.1],
|
144
|
+
[6, 21, "Live Fast and Prosper", 7.2],
|
145
|
+
[6, 22, "Muse", 6.7],
|
146
|
+
[6, 23, "Fury", 6.3],
|
147
|
+
[6, 24, "Life Line", 8.2],
|
148
|
+
[6, 25, "The Haunting of Deck Twelve", 7.1],
|
149
|
+
[6, 26, "Unimatrix Zero: Part 1", 8.0],
|
150
|
+
[7, 1, "Unimatrix Zero: Part 2", 7.9],
|
151
|
+
[7, 2, "Imperfection", 7.5],
|
152
|
+
[7, 3, "Drive", 7.0],
|
153
|
+
[7, 4, "Repression", 6.7],
|
154
|
+
[7, 5, "Critical Care", 7.7],
|
155
|
+
[7, 6, "Inside Man", 7.3],
|
156
|
+
[7, 7, "Body and Soul", 7.8],
|
157
|
+
[7, 8, "Nightingale", 6.6],
|
158
|
+
[7, 9, "Flesh and Blood", 7.6],
|
159
|
+
[7, 10, "Flesh and Blood: Part 2", 7.6],
|
160
|
+
[7, 11, "Shattered", 8.2],
|
161
|
+
[7, 12, "Lineage", 6.9],
|
162
|
+
[7, 13, "Repentance", 7.3],
|
163
|
+
[7, 14, "Prophecy", 7.2],
|
164
|
+
[7, 15, "The Void", 8.0],
|
165
|
+
[7, 16, "Workforce: Part 1", 7.6],
|
166
|
+
[7, 17, "Workforce: Part 2", 7.7],
|
167
|
+
[7, 18, "Human Error", 7.2],
|
168
|
+
[7, 19, "Q2", 7.4],
|
169
|
+
[7, 20, "Author, Author", 7.8],
|
170
|
+
[7, 21, "Friendship One", 7.0],
|
171
|
+
[7, 22, "Natural Law", 7.1],
|
172
|
+
[7, 23, "Homestead", 7.5],
|
173
|
+
[7, 24, "Renaissance Man", 7.6],
|
174
|
+
[7, 25, "Endgame", 8.5],
|
175
|
+
].each_with_index.map do |(s,e,t,r),i|
|
176
|
+
OpenStruct.new(
|
177
|
+
season: s,
|
178
|
+
episode: e,
|
179
|
+
title: t,
|
180
|
+
rating: r,
|
181
|
+
number: i
|
182
|
+
)
|
183
|
+
end
|
@@ -0,0 +1,381 @@
|
|
1
|
+
# From wunderground.com
|
2
|
+
require "ostruct"
|
3
|
+
require "time"
|
4
|
+
|
5
|
+
# 2016
|
6
|
+
WeatherInLondon = [
|
7
|
+
[1, 1, 1, 4, 9],
|
8
|
+
[1, 2, 8, 9, 11],
|
9
|
+
[1, 3, 5, 7, 9],
|
10
|
+
[1, 4, 6, 8, 11],
|
11
|
+
[1, 5, 5, 8, 10],
|
12
|
+
[1, 6, 4, 6, 8],
|
13
|
+
[1, 7, 3, 7, 11],
|
14
|
+
[1, 8, 0, 4, 9],
|
15
|
+
[1, 9, 6, 8, 11],
|
16
|
+
[1, 10, 4, 7, 9],
|
17
|
+
[1, 11, 4, 6, 7],
|
18
|
+
[1, 12, 3, 6, 7],
|
19
|
+
[1, 13, 2, 4, 7],
|
20
|
+
[1, 14, 2, 3, 5],
|
21
|
+
[1, 15, 1, 3, 6],
|
22
|
+
[1, 16, -1, 2, 5],
|
23
|
+
[1, 17, 0, 2, 4],
|
24
|
+
[1, 18, -1, 2, 5],
|
25
|
+
[1, 19, -3, 1, 5],
|
26
|
+
[1, 20, -5, 1, 7],
|
27
|
+
[1, 21, -3, 2, 8],
|
28
|
+
[1, 22, 3, 7, 11],
|
29
|
+
[1, 23, 4, 8, 11],
|
30
|
+
[1, 24, 8, 11, 15],
|
31
|
+
[1, 25, 7, 11, 13],
|
32
|
+
[1, 26, 5, 8, 12],
|
33
|
+
[1, 27, 7, 10, 13],
|
34
|
+
[1, 28, 2, 6, 10],
|
35
|
+
[1, 29, 7, 10, 12],
|
36
|
+
[1, 30, 4, 7, 8],
|
37
|
+
[1, 31, 4, 9, 13],
|
38
|
+
[2, 1, 9, 12, 14],
|
39
|
+
[2, 2, 5, 8, 10],
|
40
|
+
[2, 3, 2, 6, 9],
|
41
|
+
[2, 4, 3, 8, 14],
|
42
|
+
[2, 5, 9, 10, 11],
|
43
|
+
[2, 6, 6, 9, 12],
|
44
|
+
[2, 7, 5, 8, 10],
|
45
|
+
[2, 8, 6, 8, 9],
|
46
|
+
[2, 9, 2, 5, 8],
|
47
|
+
[2, 10, 2, 5, 8],
|
48
|
+
[2, 11, -1, 4, 9],
|
49
|
+
[2, 12, 0, 3, 7],
|
50
|
+
[2, 13, 2, 3, 5],
|
51
|
+
[2, 14, 1, 3, 6],
|
52
|
+
[2, 15, 0, 3, 7],
|
53
|
+
[2, 16, -3, 2, 8],
|
54
|
+
[2, 17, 0, 3, 6],
|
55
|
+
[2, 18, 1, 5, 8],
|
56
|
+
[2, 19, -2, 4, 10],
|
57
|
+
[2, 20, 7, 10, 13],
|
58
|
+
[2, 21, 11, 13, 14],
|
59
|
+
[2, 22, 4, 7, 9],
|
60
|
+
[2, 23, 2, 6, 9],
|
61
|
+
[2, 24, -2, 3, 8],
|
62
|
+
[2, 25, -2, 2, 7],
|
63
|
+
[2, 26, 0, 4, 8],
|
64
|
+
[2, 27, 3, 4, 6],
|
65
|
+
[2, 28, 2, 5, 8],
|
66
|
+
[2, 29, 0, 4, 9],
|
67
|
+
[3, 1, 4, 8, 13],
|
68
|
+
[3, 2, 3, 6, 7],
|
69
|
+
[3, 3, 3, 6, 9],
|
70
|
+
[3, 4, 1, 4, 8],
|
71
|
+
[3, 5, -1, 3, 7],
|
72
|
+
[3, 6, 1, 3, 6],
|
73
|
+
[3, 7, 0, 4, 8],
|
74
|
+
[3, 8, -2, 3, 9],
|
75
|
+
[3, 9, 6, 8, 11],
|
76
|
+
[3, 10, 3, 7, 9],
|
77
|
+
[3, 11, -1, 6, 11],
|
78
|
+
[3, 12, 3, 7, 11],
|
79
|
+
[3, 13, 3, 7, 11],
|
80
|
+
[3, 14, 3, 8, 12],
|
81
|
+
[3, 15, 2, 6, 9],
|
82
|
+
[3, 16, 5, 8, 10],
|
83
|
+
[3, 17, 2, 7, 12],
|
84
|
+
[3, 18, 1, 4, 7],
|
85
|
+
[3, 19, 6, 7, 9],
|
86
|
+
[3, 20, 5, 8, 11],
|
87
|
+
[3, 21, 5, 9, 12],
|
88
|
+
[3, 22, 1, 7, 14],
|
89
|
+
[3, 23, 6, 8, 10],
|
90
|
+
[3, 24, 5, 8, 11],
|
91
|
+
[3, 25, 7, 11, 15],
|
92
|
+
[3, 26, 6, 10, 14],
|
93
|
+
[3, 27, 5, 8, 11],
|
94
|
+
[3, 28, 4, 8, 13],
|
95
|
+
[3, 29, 4, 8, 12],
|
96
|
+
[3, 30, 4, 9, 13],
|
97
|
+
[3, 31, 4, 9, 13],
|
98
|
+
[4, 1, 1, 7, 13],
|
99
|
+
[4, 2, 8, 11, 14],
|
100
|
+
[4, 3, 7, 11, 15],
|
101
|
+
[4, 4, 8, 11, 13],
|
102
|
+
[4, 5, 7, 11, 15],
|
103
|
+
[4, 6, 5, 9, 13],
|
104
|
+
[4, 7, 4, 8, 12],
|
105
|
+
[4, 8, 4, 9, 14],
|
106
|
+
[4, 9, 4, 8, 11],
|
107
|
+
[4, 10, 1, 7, 13],
|
108
|
+
[4, 11, 8, 11, 14],
|
109
|
+
[4, 12, 7, 12, 17],
|
110
|
+
[4, 13, 3, 11, 18],
|
111
|
+
[4, 14, 8, 12, 17],
|
112
|
+
[4, 15, 8, 11, 13],
|
113
|
+
[4, 16, 4, 7, 9],
|
114
|
+
[4, 17, 0, 6, 12],
|
115
|
+
[4, 18, 3, 8, 13],
|
116
|
+
[4, 19, 8, 12, 16],
|
117
|
+
[4, 20, 4, 9, 14],
|
118
|
+
[4, 21, 6, 11, 17],
|
119
|
+
[4, 22, 6, 8, 11],
|
120
|
+
[4, 23, 3, 7, 11],
|
121
|
+
[4, 24, 3, 7, 10],
|
122
|
+
[4, 25, 4, 8, 12],
|
123
|
+
[4, 26, 2, 7, 11],
|
124
|
+
[4, 27, 1, 7, 12],
|
125
|
+
[4, 28, 0, 6, 12],
|
126
|
+
[4, 29, 4, 8, 12],
|
127
|
+
[4, 30, 1, 8, 14],
|
128
|
+
[5, 1, 2, 9, 16],
|
129
|
+
[5, 2, 8, 13, 18],
|
130
|
+
[5, 3, 4, 10, 16],
|
131
|
+
[5, 4, 4, 11, 17],
|
132
|
+
[5, 5, 6, 13, 21],
|
133
|
+
[5, 6, 8, 16, 23],
|
134
|
+
[5, 7, 13, 18, 24],
|
135
|
+
[5, 8, 13, 20, 27],
|
136
|
+
[5, 9, 14, 19, 24],
|
137
|
+
[5, 10, 15, 16, 17],
|
138
|
+
[5, 11, 14, 17, 19],
|
139
|
+
[5, 12, 12, 18, 24],
|
140
|
+
[5, 13, 9, 13, 17],
|
141
|
+
[5, 14, 7, 11, 14],
|
142
|
+
[5, 15, 5, 11, 17],
|
143
|
+
[5, 16, 8, 13, 18],
|
144
|
+
[5, 17, 8, 13, 18],
|
145
|
+
[5, 18, 11, 12, 14],
|
146
|
+
[5, 19, 9, 14, 19],
|
147
|
+
[5, 20, 13, 16, 19],
|
148
|
+
[5, 21, 12, 15, 18],
|
149
|
+
[5, 22, 11, 14, 18],
|
150
|
+
[5, 23, 9, 14, 19],
|
151
|
+
[5, 24, 7, 12, 17],
|
152
|
+
[5, 25, 9, 11, 12],
|
153
|
+
[5, 26, 7, 14, 21],
|
154
|
+
[5, 27, 11, 17, 22],
|
155
|
+
[5, 28, 10, 16, 21],
|
156
|
+
[5, 29, 9, 14, 19],
|
157
|
+
[5, 30, 12, 14, 18],
|
158
|
+
[5, 31, 11, 12, 13],
|
159
|
+
[6, 1, 11, 12, 13],
|
160
|
+
[6, 2, 10, 12, 13],
|
161
|
+
[6, 3, 9, 12, 14],
|
162
|
+
[6, 4, 12, 16, 19],
|
163
|
+
[6, 5, 12, 18, 24],
|
164
|
+
[6, 6, 12, 18, 25],
|
165
|
+
[6, 7, 12, 18, 24],
|
166
|
+
[6, 8, 14, 20, 26],
|
167
|
+
[6, 9, 13, 18, 23],
|
168
|
+
[6, 10, 13, 19, 24],
|
169
|
+
[6, 11, 16, 19, 22],
|
170
|
+
[6, 12, 14, 18, 21],
|
171
|
+
[6, 13, 13, 16, 19],
|
172
|
+
[6, 14, 13, 16, 19],
|
173
|
+
[6, 15, 12, 16, 20],
|
174
|
+
[6, 16, 12, 15, 18],
|
175
|
+
[6, 17, 13, 17, 20],
|
176
|
+
[6, 18, 12, 14, 17],
|
177
|
+
[6, 19, 11, 16, 20],
|
178
|
+
[6, 20, 15, 19, 22],
|
179
|
+
[6, 21, 14, 18, 22],
|
180
|
+
[6, 22, 14, 18, 22],
|
181
|
+
[6, 23, 16, 19, 21],
|
182
|
+
[6, 24, 11, 17, 22],
|
183
|
+
[6, 25, 12, 16, 20],
|
184
|
+
[6, 26, 12, 17, 21],
|
185
|
+
[6, 27, 14, 18, 22],
|
186
|
+
[6, 28, 11, 16, 21],
|
187
|
+
[6, 29, 11, 13, 17],
|
188
|
+
[6, 30, 13, 17, 20],
|
189
|
+
[7, 1, 12, 16, 19],
|
190
|
+
[7, 2, 10, 16, 21],
|
191
|
+
[7, 3, 10, 16, 21],
|
192
|
+
[7, 4, 11, 16, 21],
|
193
|
+
[7, 5, 14, 18, 21],
|
194
|
+
[7, 6, 10, 16, 22],
|
195
|
+
[7, 7, 14, 19, 23],
|
196
|
+
[7, 8, 14, 19, 23],
|
197
|
+
[7, 9, 15, 19, 23],
|
198
|
+
[7, 10, 16, 19, 23],
|
199
|
+
[7, 11, 15, 18, 22],
|
200
|
+
[7, 12, 12, 16, 19],
|
201
|
+
[7, 13, 12, 16, 20],
|
202
|
+
[7, 14, 11, 17, 22],
|
203
|
+
[7, 15, 11, 15, 19],
|
204
|
+
[7, 16, 17, 22, 27],
|
205
|
+
[7, 17, 17, 22, 27],
|
206
|
+
[7, 18, 16, 22, 29],
|
207
|
+
[7, 19, 16, 24, 33],
|
208
|
+
[7, 20, 17, 25, 31],
|
209
|
+
[7, 21, 14, 19, 25],
|
210
|
+
[7, 22, 17, 21, 24],
|
211
|
+
[7, 23, 14, 21, 28],
|
212
|
+
[7, 24, 14, 20, 26],
|
213
|
+
[7, 25, 14, 19, 24],
|
214
|
+
[7, 26, 13, 18, 23],
|
215
|
+
[7, 27, 17, 21, 26],
|
216
|
+
[7, 28, 14, 19, 23],
|
217
|
+
[7, 29, 16, 20, 23],
|
218
|
+
[7, 30, 16, 19, 22],
|
219
|
+
[7, 31, 13, 18, 22],
|
220
|
+
[8, 1, 12, 16, 19],
|
221
|
+
[8, 2, 14, 18, 22],
|
222
|
+
[8, 3, 17, 21, 24],
|
223
|
+
[8, 4, 15, 19, 23],
|
224
|
+
[8, 5, 13, 18, 24],
|
225
|
+
[8, 6, 12, 19, 26],
|
226
|
+
[8, 7, 17, 22, 27],
|
227
|
+
[8, 8, 14, 18, 22],
|
228
|
+
[8, 9, 10, 16, 21],
|
229
|
+
[8, 10, 11, 16, 20],
|
230
|
+
[8, 11, 14, 19, 24],
|
231
|
+
[8, 12, 13, 20, 27],
|
232
|
+
[8, 13, 14, 20, 26],
|
233
|
+
[8, 14, 15, 19, 23],
|
234
|
+
[8, 15, 12, 18, 24],
|
235
|
+
[8, 16, 12, 19, 25],
|
236
|
+
[8, 17, 13, 20, 27],
|
237
|
+
[8, 18, 16, 20, 25],
|
238
|
+
[8, 19, 16, 17, 19],
|
239
|
+
[8, 20, 14, 18, 22],
|
240
|
+
[8, 21, 14, 19, 23],
|
241
|
+
[8, 22, 16, 21, 26],
|
242
|
+
[8, 23, 13, 22, 31],
|
243
|
+
[8, 24, 18, 26, 33],
|
244
|
+
[8, 25, 18, 23, 27],
|
245
|
+
[8, 26, 17, 22, 27],
|
246
|
+
[8, 27, 16, 21, 26],
|
247
|
+
[8, 28, 16, 19, 21],
|
248
|
+
[8, 29, 15, 19, 24],
|
249
|
+
[8, 30, 13, 20, 27],
|
250
|
+
[8, 31, 12, 18, 24],
|
251
|
+
[9, 1, 13, 19, 24],
|
252
|
+
[9, 2, 14, 17, 20],
|
253
|
+
[9, 3, 12, 17, 21],
|
254
|
+
[9, 4, 8, 14, 21],
|
255
|
+
[9, 5, 13, 18, 23],
|
256
|
+
[9, 6, 19, 21, 24],
|
257
|
+
[9, 7, 18, 23, 28],
|
258
|
+
[9, 8, 15, 19, 24],
|
259
|
+
[9, 9, 15, 19, 24],
|
260
|
+
[9, 10, 13, 16, 19],
|
261
|
+
[9, 11, 8, 15, 22],
|
262
|
+
[9, 12, 11, 18, 26],
|
263
|
+
[9, 13, 16, 24, 33],
|
264
|
+
[9, 14, 18, 23, 28],
|
265
|
+
[9, 15, 16, 22, 29],
|
266
|
+
[9, 16, 14, 16, 18],
|
267
|
+
[9, 17, 13, 14, 16],
|
268
|
+
[9, 18, 14, 17, 21],
|
269
|
+
[9, 19, 13, 16, 19],
|
270
|
+
[9, 20, 14, 17, 19],
|
271
|
+
[9, 21, 14, 18, 22],
|
272
|
+
[9, 22, 13, 17, 21],
|
273
|
+
[9, 23, 9, 14, 21],
|
274
|
+
[9, 24, 9, 16, 23],
|
275
|
+
[9, 25, 11, 16, 21],
|
276
|
+
[9, 26, 9, 14, 18],
|
277
|
+
[9, 27, 9, 14, 19],
|
278
|
+
[9, 28, 12, 17, 23],
|
279
|
+
[9, 29, 12, 17, 20],
|
280
|
+
[9, 30, 10, 14, 19],
|
281
|
+
[10, 1, 9, 12, 16],
|
282
|
+
[10, 2, 8, 12, 17],
|
283
|
+
[10, 3, 5, 12, 18],
|
284
|
+
[10, 4, 9, 14, 19],
|
285
|
+
[10, 5, 10, 14, 17],
|
286
|
+
[10, 6, 8, 12, 16],
|
287
|
+
[10, 7, 11, 13, 15],
|
288
|
+
[10, 8, 11, 14, 17],
|
289
|
+
[10, 9, 8, 12, 16],
|
290
|
+
[10, 10, 6, 10, 14],
|
291
|
+
[10, 11, 4, 11, 17],
|
292
|
+
[10, 12, 9, 12, 16],
|
293
|
+
[10, 13, 8, 11, 13],
|
294
|
+
[10, 14, 9, 12, 15],
|
295
|
+
[10, 15, 8, 13, 18],
|
296
|
+
[10, 16, 7, 13, 18],
|
297
|
+
[10, 17, 9, 13, 17],
|
298
|
+
[10, 18, 9, 11, 14],
|
299
|
+
[10, 19, 9, 11, 13],
|
300
|
+
[10, 20, 8, 11, 14],
|
301
|
+
[10, 21, 7, 10, 13],
|
302
|
+
[10, 22, 5, 10, 14],
|
303
|
+
[10, 23, 6, 9, 13],
|
304
|
+
[10, 24, 9, 11, 13],
|
305
|
+
[10, 25, 9, 12, 14],
|
306
|
+
[10, 26, 9, 12, 16],
|
307
|
+
[10, 27, 8, 12, 16],
|
308
|
+
[10, 28, 10, 13, 17],
|
309
|
+
[10, 29, 11, 13, 15],
|
310
|
+
[10, 30, 8, 10, 12],
|
311
|
+
[10, 31, 8, 14, 20],
|
312
|
+
[11, 1, 6, 9, 12],
|
313
|
+
[11, 2, 2, 7, 11],
|
314
|
+
[11, 3, 2, 7, 12],
|
315
|
+
[11, 4, 4, 8, 11],
|
316
|
+
[11, 5, 2, 6, 9],
|
317
|
+
[11, 6, 2, 4, 8],
|
318
|
+
[11, 7, 2, 4, 8],
|
319
|
+
[11, 8, -1, 2, 6],
|
320
|
+
[11, 9, 3, 7, 9],
|
321
|
+
[11, 10, 3, 7, 11],
|
322
|
+
[11, 11, 3, 7, 11],
|
323
|
+
[11, 12, 2, 7, 11],
|
324
|
+
[11, 13, 5, 8, 11],
|
325
|
+
[11, 14, 5, 9, 13],
|
326
|
+
[11, 15, 12, 14, 16],
|
327
|
+
[11, 16, 9, 11, 14],
|
328
|
+
[11, 17, 7, 10, 14],
|
329
|
+
[11, 18, 2, 7, 11],
|
330
|
+
[11, 19, 1, 4, 8],
|
331
|
+
[11, 20, 5, 7, 8],
|
332
|
+
[11, 21, 5, 9, 12],
|
333
|
+
[11, 22, 6, 9, 12],
|
334
|
+
[11, 23, 4, 7, 10],
|
335
|
+
[11, 24, 7, 8, 10],
|
336
|
+
[11, 25, 5, 8, 11],
|
337
|
+
[11, 26, 2, 6, 9],
|
338
|
+
[11, 27, 5, 7, 8],
|
339
|
+
[11, 28, 2, 6, 9],
|
340
|
+
[11, 29, -2, 2, 7],
|
341
|
+
[11, 30, -4, 1, 7],
|
342
|
+
[12, 1, -3, 2, 8],
|
343
|
+
[12, 2, 3, 6, 8],
|
344
|
+
[12, 3, 3, 6, 9],
|
345
|
+
[12, 4, 0, 4, 8],
|
346
|
+
[12, 5, -2, 3, 8],
|
347
|
+
[12, 6, 1, 6, 11],
|
348
|
+
[12, 7, 8, 10, 13],
|
349
|
+
[12, 8, 9, 11, 13],
|
350
|
+
[12, 9, 10, 12, 14],
|
351
|
+
[12, 10, 7, 10, 13],
|
352
|
+
[12, 11, 3, 7, 10],
|
353
|
+
[12, 12, 2, 7, 11],
|
354
|
+
[12, 13, 7, 10, 13],
|
355
|
+
[12, 14, 6, 10, 14],
|
356
|
+
[12, 15, 4, 8, 11],
|
357
|
+
[12, 16, 7, 9, 11],
|
358
|
+
[12, 17, 3, 6, 8],
|
359
|
+
[12, 18, 6, 7, 7],
|
360
|
+
[12, 19, 4, 6, 7],
|
361
|
+
[12, 20, 4, 6, 7],
|
362
|
+
[12, 21, 4, 8, 12],
|
363
|
+
[12, 22, 2, 6, 11],
|
364
|
+
[12, 23, 3, 7, 11],
|
365
|
+
[12, 24, 5, 8, 10],
|
366
|
+
[12, 25, 9, 11, 13],
|
367
|
+
[12, 26, 2, 5, 8],
|
368
|
+
[12, 27, -1, 3, 7],
|
369
|
+
[12, 28, -2, 3, 8],
|
370
|
+
[12, 29, -4, 3, 9],
|
371
|
+
[12, 30, -1, 1, 3],
|
372
|
+
[12, 31, 2, 6, 9],
|
373
|
+
].map do |month,day,min,mean,max|
|
374
|
+
OpenStruct.new(
|
375
|
+
month: month,
|
376
|
+
day: day,
|
377
|
+
min: min,
|
378
|
+
mean: mean,
|
379
|
+
max: max,
|
380
|
+
)
|
381
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "opal"
|
2
|
+
require "opal-d3"
|
3
|
+
require "data/elections_2016"
|
4
|
+
|
5
|
+
list = D3.select("#visualization").append("ul")
|
6
|
+
max_votes = Elections2016.map(&:votes).max
|
7
|
+
|
8
|
+
Elections2016.each do |candidate|
|
9
|
+
item = list.append("li")
|
10
|
+
.style("position", "relative")
|
11
|
+
item.append("span")
|
12
|
+
.style("background-color", candidate.color)
|
13
|
+
.style("position", "absolute")
|
14
|
+
.style("width", "#{100.0 * candidate.votes / max_votes}%")
|
15
|
+
.style("height", "100%")
|
16
|
+
item.append("span")
|
17
|
+
.style("position", "absolute")
|
18
|
+
.text("#{candidate.name} - #{candidate.votes} votes")
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "opal"
|
2
|
+
require "opal-d3"
|
3
|
+
require "data/harry_potter"
|
4
|
+
|
5
|
+
svg = D3.select("#visualization")
|
6
|
+
.append("svg")
|
7
|
+
.attr("height", "400px")
|
8
|
+
.attr("width", "100%")
|
9
|
+
width = svg.style("width").to_i
|
10
|
+
|
11
|
+
bar_size = (400-40-20) / (HarryPotterBooks.size)
|
12
|
+
|
13
|
+
x = D3.scale_linear.domain(HarryPotterBooks.map(&:date).minmax).range([200,width-90])
|
14
|
+
y = D3.scale_ordinal.range(HarryPotterBooks.size.times.map{|i| 40+i*bar_size}.reverse)
|
15
|
+
s = D3.scale_sqrt.domain([0, HarryPotterBooks.map(&:pages).max]).range([0,50])
|
16
|
+
|
17
|
+
HarryPotterBooks.each do |book|
|
18
|
+
svg.append("text")
|
19
|
+
.attr("x", x.(book.date))
|
20
|
+
.attr("y", y.(book.title) + bar_size/2)
|
21
|
+
.attr("font-size", s.(book.pages))
|
22
|
+
.text("📖")
|
23
|
+
.attr("text-anchor", "middle")
|
24
|
+
svg.append("text")
|
25
|
+
.attr("x", 0)
|
26
|
+
.attr("y", y.(book.title) + bar_size/2)
|
27
|
+
.text(book.title)
|
28
|
+
end
|
29
|
+
|
30
|
+
axis_bottom = D3.axis_bottom(x)
|
31
|
+
.tick_format(D3.time_format("%Y-%m-%d"))
|
32
|
+
.tick_values(HarryPotterBooks.map(&:date))
|
33
|
+
svg.append("g")
|
34
|
+
.attr("transform", "translate(0, 380)")
|
35
|
+
.call(axis_bottom)
|
data/demo/app/iphones.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require "opal"
|
2
|
+
require "opal-d3"
|
3
|
+
require "data/iphones"
|
4
|
+
|
5
|
+
svg = D3.select("#visualization")
|
6
|
+
.append("svg")
|
7
|
+
.attr("height", "500px")
|
8
|
+
.attr("width", "100%")
|
9
|
+
width = svg.style("width").to_i
|
10
|
+
|
11
|
+
x = D3.scale_linear.domain(IPhoneVariants.map(&:released).minmax).range([20,width-90]).nice
|
12
|
+
y = D3.scale_log.domain(IPhoneVariants.map(&:size).minmax).range([380,20])
|
13
|
+
c = D3.scale_ordinal.range(D3.scheme_category_20)
|
14
|
+
|
15
|
+
# If there are multiple points on same date/size combination,
|
16
|
+
# move any duplicates 15px right (or 30px for triplicates etc.)
|
17
|
+
duplicates = Hash.new(0)
|
18
|
+
|
19
|
+
graph_area = svg.append("g")
|
20
|
+
.attr("transform", "translate(60, 20)")
|
21
|
+
graph_area.select_all("circle")
|
22
|
+
.data(IPhoneVariants).enter
|
23
|
+
.append("circle")
|
24
|
+
.attr("cx"){|d|
|
25
|
+
count = duplicates[[d.released, d.size]]
|
26
|
+
duplicates[[d.released, d.size]] += 1
|
27
|
+
x.(d.released) + 15 * count
|
28
|
+
}
|
29
|
+
.attr("cy"){|d| y.(d.size)}
|
30
|
+
.attr("r", 10)
|
31
|
+
.attr("fill"){|d| c.(d.name)}
|
32
|
+
|
33
|
+
axis_bottom = D3.axis_bottom(x)
|
34
|
+
.tick_format(D3.time_format("%Y-%m-%d"))
|
35
|
+
axis_left = D3.axis_left(y)
|
36
|
+
.tick_values([4,8,16,32,64,128,256])
|
37
|
+
.tick_format{|v| "#{v} GB"}
|
38
|
+
graph_area.call(axis_left)
|
39
|
+
graph_area.append("g").attr("transform", "translate(0, 400)").call(axis_bottom)
|
40
|
+
|
41
|
+
D3.select("#visualization").append("table")
|
42
|
+
.select_all("tr")
|
43
|
+
.data(IPhones).enter
|
44
|
+
.append("tr")
|
45
|
+
.append("td")
|
46
|
+
.text{|d| d.name}
|
47
|
+
.style("background"){|d| c.(d.name)}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "opal"
|
2
|
+
require "opal-d3"
|
3
|
+
require "data/london_population"
|
4
|
+
|
5
|
+
svg = D3.select("#visualization")
|
6
|
+
.append("svg")
|
7
|
+
.attr("height", "400px")
|
8
|
+
.attr("width", "100%")
|
9
|
+
|
10
|
+
svg.append("g").select_all("rect")
|
11
|
+
.data(LondonPopulation)
|
12
|
+
.enter().append("rect")
|
13
|
+
.attr("width", 30)
|
14
|
+
.attr("height"){|d| d.greater/100_000 }
|
15
|
+
.attr("y"){|d| 200 - d.greater/100_000 }
|
16
|
+
.attr("x"){|d| (d.year-1800)*4 }
|
17
|
+
.attr("fill", "pink")
|
18
|
+
|
19
|
+
svg.append("g").select_all("rect")
|
20
|
+
.data(LondonPopulation)
|
21
|
+
.enter().append("rect")
|
22
|
+
.attr("width", 30)
|
23
|
+
.attr("height"){|d| d.inner/100_000 }
|
24
|
+
.attr("y"){|d| 200 - d.inner/100_000 }
|
25
|
+
.attr("x"){|d| (d.year-1800)*4 }
|
26
|
+
.attr("fill", "steelblue")
|
27
|
+
|
28
|
+
svg.append("g").select_all("circle")
|
29
|
+
.data(LondonPopulation)
|
30
|
+
.enter().append("circle")
|
31
|
+
.attr("fill", "pink")
|
32
|
+
.attr("cx"){|d| 15 + (d.year-1800)*4 }
|
33
|
+
.attr("cy", 300)
|
34
|
+
.attr("r"){|d| (d.greater**0.5)/150.0 }
|
35
|
+
|
36
|
+
svg.append("g").select_all("circle")
|
37
|
+
.data(LondonPopulation)
|
38
|
+
.enter().append("circle")
|
39
|
+
.attr("fill", "steelblue")
|
40
|
+
.attr("cx"){|d| 15 + (d.year-1800)*4 }
|
41
|
+
.attr("cy", 300)
|
42
|
+
.attr("r"){|d| (d.inner**0.5)/150.0 }
|
43
|
+
|
44
|
+
list = D3.select("#visualization").append("table")
|
45
|
+
list.append("tr").append("td").text("Outer London").style("background", "pink")
|
46
|
+
list.append("tr").append("td").text("Inner London").style("background", "steelblue")
|