d3_rails 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +45 -0
- data/lib/d3_rails/version.rb +1 -1
- data/vendor/assets/javascripts/.DS_Store +0 -0
- data/vendor/assets/javascripts/LICENSE +27 -0
- data/vendor/assets/javascripts/d3.js +11 -10
- data/vendor/assets/javascripts/d3.time.js +15 -6
- metadata +11 -9
- data/README +0 -35
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# D3_Rails
|
2
|
+
|
3
|
+
**D3_Rails** is a small, lightweight gem which allows you to include any
|
4
|
+
and all of D3 Javascripts into your 3.1 Rails application, merely by
|
5
|
+
including any desired D3 files into your application.js manifest.
|
6
|
+
|
7
|
+
# About D3
|
8
|
+
|
9
|
+
**D3** is a small, free JavaScript library for manipulating HTML documents
|
10
|
+
based on data. D3 can help you quickly visualize your data as HTML or SVG,
|
11
|
+
handle interactivity, and incorporate smooth transitions and staged animations
|
12
|
+
into your pages. You can use D3 as a visualization framework (like Protovis),
|
13
|
+
or you can use it to build dynamic pages (like jQuery).
|
14
|
+
|
15
|
+
### Installation
|
16
|
+
|
17
|
+
This gem should work out of the box. All you have to do is add the gem to your Gemfile:
|
18
|
+
|
19
|
+
gem 'd3_rails'
|
20
|
+
|
21
|
+
Then bundle install or update (depending on if you want to upgrade an older version of this gem).
|
22
|
+
|
23
|
+
bundle install
|
24
|
+
bundle update
|
25
|
+
|
26
|
+
In your assets/javascripts/application.js, you will need to add d3 to your manifest:
|
27
|
+
|
28
|
+
//= require jquery
|
29
|
+
.
|
30
|
+
.
|
31
|
+
//= require d3
|
32
|
+
|
33
|
+
### Additional Files
|
34
|
+
|
35
|
+
Bundle installing d3_rails will add the main d3.js file to your application. However, if you require the additional javascripts included by the D3, such as d3.layout.js or d3.chart.js, all you need to do is include the desired javascripts in your javascript manifest in your assets/javascripts/application.js file.
|
36
|
+
|
37
|
+
Ex.
|
38
|
+
|
39
|
+
//= require jquery
|
40
|
+
.
|
41
|
+
.
|
42
|
+
//= require d3
|
43
|
+
//= require d3.chart
|
44
|
+
etc..
|
45
|
+
|
data/lib/d3_rails/version.rb
CHANGED
Binary file
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2010, Nicolas Garcia Belmonte
|
2
|
+
All rights reserved
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
* Neither the name of the organization nor the names of its contributors may
|
15
|
+
be used to endorse or promote products derived from this software without
|
16
|
+
specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY NICOLAS GARCIA BELMONTE ``AS IS'' AND ANY EXPRESS
|
19
|
+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
20
|
+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
21
|
+
EVENT SHALL NICOLAS GARCIA BELMONTE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
22
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
24
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
25
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
26
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
27
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -10,7 +10,7 @@ try {
|
|
10
10
|
d3_style_setProperty.call(this, name, value + "", priority);
|
11
11
|
};
|
12
12
|
}
|
13
|
-
d3 = {version: "2.4.
|
13
|
+
d3 = {version: "2.4.4"}; // semver
|
14
14
|
var d3_array = d3_arraySlice; // conversion for NodeLists
|
15
15
|
|
16
16
|
function d3_arrayCopy(pseudoarray) {
|
@@ -1824,7 +1824,7 @@ d3_selectionPrototype.transition = function() {
|
|
1824
1824
|
}
|
1825
1825
|
}
|
1826
1826
|
|
1827
|
-
return d3_transition(subgroups, d3_transitionInheritId || ++d3_transitionId);
|
1827
|
+
return d3_transition(subgroups, d3_transitionInheritId || ++d3_transitionId, Date.now());
|
1828
1828
|
};
|
1829
1829
|
var d3_selectionRoot = d3_selection([[document]]);
|
1830
1830
|
|
@@ -1844,16 +1844,17 @@ d3.selectAll = function(selector) {
|
|
1844
1844
|
? d3_selectionRoot.selectAll(selector)
|
1845
1845
|
: d3_selection([d3_array(selector)]); // assume node[]
|
1846
1846
|
};
|
1847
|
-
function d3_transition(groups, id) {
|
1847
|
+
function d3_transition(groups, id, time) {
|
1848
1848
|
d3_arraySubclass(groups, d3_transitionPrototype);
|
1849
1849
|
|
1850
1850
|
var tweens = {},
|
1851
1851
|
event = d3.dispatch("start", "end"),
|
1852
|
-
ease = d3_transitionEase
|
1853
|
-
then = Date.now();
|
1852
|
+
ease = d3_transitionEase;
|
1854
1853
|
|
1855
1854
|
groups.id = id;
|
1856
1855
|
|
1856
|
+
groups.time = time;
|
1857
|
+
|
1857
1858
|
groups.tween = function(name, tween) {
|
1858
1859
|
if (arguments.length < 2) return tweens[name];
|
1859
1860
|
if (tween == null) delete tweens[name];
|
@@ -1883,7 +1884,7 @@ function d3_transition(groups, id) {
|
|
1883
1884
|
|
1884
1885
|
++lock.count;
|
1885
1886
|
|
1886
|
-
delay <= elapsed ? start(elapsed) : d3.timer(start, delay,
|
1887
|
+
delay <= elapsed ? start(elapsed) : d3.timer(start, delay, time);
|
1887
1888
|
|
1888
1889
|
function start(elapsed) {
|
1889
1890
|
if (lock.active > id) return stop();
|
@@ -1896,7 +1897,7 @@ function d3_transition(groups, id) {
|
|
1896
1897
|
}
|
1897
1898
|
|
1898
1899
|
event.start.dispatch.call(node, d, i);
|
1899
|
-
if (!tick(elapsed)) d3.timer(tick, 0,
|
1900
|
+
if (!tick(elapsed)) d3.timer(tick, 0, time);
|
1900
1901
|
return 1;
|
1901
1902
|
}
|
1902
1903
|
|
@@ -1926,7 +1927,7 @@ function d3_transition(groups, id) {
|
|
1926
1927
|
}
|
1927
1928
|
});
|
1928
1929
|
return 1;
|
1929
|
-
}, 0,
|
1930
|
+
}, 0, time);
|
1930
1931
|
|
1931
1932
|
return groups;
|
1932
1933
|
}
|
@@ -1987,7 +1988,7 @@ d3_transitionPrototype.select = function(selector) {
|
|
1987
1988
|
}
|
1988
1989
|
}
|
1989
1990
|
|
1990
|
-
return d3_transition(subgroups, this.id).ease(this.ease());
|
1991
|
+
return d3_transition(subgroups, this.id, this.time).ease(this.ease());
|
1991
1992
|
};
|
1992
1993
|
d3_transitionPrototype.selectAll = function(selector) {
|
1993
1994
|
var subgroups = [],
|
@@ -2009,7 +2010,7 @@ d3_transitionPrototype.selectAll = function(selector) {
|
|
2009
2010
|
}
|
2010
2011
|
}
|
2011
2012
|
|
2012
|
-
return d3_transition(subgroups, this.id).ease(this.ease());
|
2013
|
+
return d3_transition(subgroups, this.id, this.time).ease(this.ease());
|
2013
2014
|
};
|
2014
2015
|
d3_transitionPrototype.attr = function(name, value) {
|
2015
2016
|
return this.attrTween(name, d3_transitionTween(value));
|
@@ -302,18 +302,22 @@ function d3_time_year(d) {
|
|
302
302
|
return new d3_time(d.getFullYear(), 0, 1);
|
303
303
|
}
|
304
304
|
|
305
|
+
function d3_time_daysElapsed(d0, d1) {
|
306
|
+
return ~~((d1 - d0) / 864e5 - (d1.getTimezoneOffset() - d0.getTimezoneOffset()) / 1440);
|
307
|
+
}
|
308
|
+
|
305
309
|
function d3_time_dayOfYear(d) {
|
306
|
-
return d3_time_zfill3(1 +
|
310
|
+
return d3_time_zfill3(1 + d3_time_daysElapsed(d3_time_year(d), d));
|
307
311
|
}
|
308
312
|
|
309
313
|
function d3_time_weekNumberSunday(d) {
|
310
314
|
var d0 = d3_time_year(d);
|
311
|
-
return d3_time_zfill2(~~(((d
|
315
|
+
return d3_time_zfill2(~~((d3_time_daysElapsed(d0, d) + d0.getDay()) / 7));
|
312
316
|
}
|
313
317
|
|
314
318
|
function d3_time_weekNumberMonday(d) {
|
315
319
|
var d0 = d3_time_year(d);
|
316
|
-
return d3_time_zfill2(~~(((d
|
320
|
+
return d3_time_zfill2(~~((d3_time_daysElapsed(d0, d) + (d0.getDay() + 6) % 7) / 7));
|
317
321
|
}
|
318
322
|
|
319
323
|
// TODO table of time zone offset names?
|
@@ -328,9 +332,14 @@ d3.time.format.utc = function(template) {
|
|
328
332
|
var local = d3.time.format(template);
|
329
333
|
|
330
334
|
function format(date) {
|
331
|
-
|
332
|
-
|
333
|
-
|
335
|
+
try {
|
336
|
+
d3_time = d3_time_format_utc;
|
337
|
+
var utc = new d3_time();
|
338
|
+
utc._ = date;
|
339
|
+
return local(utc);
|
340
|
+
} finally {
|
341
|
+
d3_time = Date;
|
342
|
+
}
|
334
343
|
}
|
335
344
|
|
336
345
|
format.parse = function(string) {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: d3_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-16 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement: &
|
16
|
+
requirement: &70164288822620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70164288822620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70164288821900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70164288821900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &70164288821060 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '3.1'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70164288821060
|
47
47
|
description: Gem installation of javascript framework for data visualization, D3
|
48
48
|
email:
|
49
49
|
- han@logicallsat.com
|
@@ -54,12 +54,14 @@ files:
|
|
54
54
|
- .gitignore
|
55
55
|
- Gemfile
|
56
56
|
- LICENSE
|
57
|
-
- README
|
57
|
+
- README.md
|
58
58
|
- Rakefile
|
59
59
|
- d3_rails.gemspec
|
60
60
|
- lib/d3_rails.rb
|
61
61
|
- lib/d3_rails/engine.rb
|
62
62
|
- lib/d3_rails/version.rb
|
63
|
+
- vendor/assets/javascripts/.DS_Store
|
64
|
+
- vendor/assets/javascripts/LICENSE
|
63
65
|
- vendor/assets/javascripts/colorbrewer.js
|
64
66
|
- vendor/assets/javascripts/d3-csv.js
|
65
67
|
- vendor/assets/javascripts/d3.chart.js
|
data/README
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
D3_Rails
|
2
|
-
|
3
|
-
Automates the installation of the D3 javascript framework for Ruby on Rails 3.1+ applications with the asset pipeline.
|
4
|
-
|
5
|
-
Installation -
|
6
|
-
|
7
|
-
In your Gemfile:
|
8
|
-
|
9
|
-
gem 'd3_rails'
|
10
|
-
|
11
|
-
Terminal/Command Prompt:
|
12
|
-
|
13
|
-
bundle install/update
|
14
|
-
|
15
|
-
In your assets/javascripts/application.js, you will need to add d3 to your manifest:
|
16
|
-
|
17
|
-
//= require jquery
|
18
|
-
.
|
19
|
-
.
|
20
|
-
//= require d3
|
21
|
-
|
22
|
-
Usage -
|
23
|
-
|
24
|
-
Bundle installing d3_rails will add the main d3.js file to your application. However, if you require the additional javascripts included by the D3, such as d3.layout.js or d3.chart.js, all you need to do is include the desired javascripts in your javascript manifest in your assets/javascripts/application.js file.
|
25
|
-
|
26
|
-
Ex.
|
27
|
-
|
28
|
-
//= require jquery
|
29
|
-
.
|
30
|
-
.
|
31
|
-
//= require d3
|
32
|
-
//= require d3.chart
|
33
|
-
etc..
|
34
|
-
|
35
|
-
|