bitcharts 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +30 -14
- data/app/assets/javascripts/bitcharts/default.js.coffee +2 -0
- data/app/assets/javascripts/bitcharts/full.js.coffee +3 -0
- data/app/assets/javascripts/bitcharts/{application.js.coffee → init.js.coffee} +0 -3
- data/lib/bitcharts/engine.rb +5 -0
- data/lib/bitcharts/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffa0c3419f3193fcc1a82ddaaaec263147a861ae
|
4
|
+
data.tar.gz: c896ef9f22a8805ba2cf3dae45fbdc4681d6a543
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 477dedeedca6777d798eea4b9d14614b074c3ac94d3baf156d0e83b4e2d6535edf1b12fda135be662b84043bfad390415ebc8e5f4f4bb3b7eb2ad7a9a742495c
|
7
|
+
data.tar.gz: 36aabcbecaa467d7e3ce4034581ff018ea15552c33ad33784cf08f30ce2659bc59712af8a95828c3035f19a84ffd41516cc17814d0cfdd5510b5f19650d595a7
|
data/README.rdoc
CHANGED
@@ -1,19 +1,35 @@
|
|
1
|
-
= Bitcharts
|
1
|
+
= Bitcharts
|
2
2
|
|
3
|
-
== Usage
|
3
|
+
== Usage
|
4
4
|
|
5
|
-
|
5
|
+
=== Mount Engine in +routes.rb+
|
6
6
|
|
7
|
-
|
8
|
-
rails g bitcharts:chart user_logins
|
9
|
-
# or a scoped chart:
|
10
|
-
rails g bitcharts:scoped_chart user_logins
|
11
|
-
~~~
|
7
|
+
mount Bitcharts::Engine => "/bitcharts"
|
12
8
|
|
13
|
-
|
14
|
-
3. Include canvas into your view
|
9
|
+
=== Generate a chart
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
rails g bitcharts:chart user_logins
|
12
|
+
# or a scoped chart:
|
13
|
+
rails g bitcharts:scoped_chart user_logins
|
14
|
+
|
15
|
+
=== Implement chart's value method
|
16
|
+
|
17
|
+
Change the generated method in +app/charts/user_logins_chart.rb+:
|
18
|
+
|
19
|
+
def value(date_range)
|
20
|
+
User::Login.where(created_at: date_range).count
|
21
|
+
end
|
22
|
+
|
23
|
+
=== Add canvas to your view
|
24
|
+
|
25
|
+
<%= bitchart 'user_logins', from: 7.days.ago, to: Date.today %>
|
26
|
+
|
27
|
+
Check +Bitcharts::ApplicationHelper+ for all available options.
|
28
|
+
|
29
|
+
=== Add Javascript
|
30
|
+
|
31
|
+
Require Javascript in your applications Javascript or load it dynamically in your view when needed:
|
32
|
+
|
33
|
+
<%= javascript_include_tag 'bitcharts/default' %>
|
34
|
+
|
35
|
+
If you don't use jQuery already use +bitcharts/full+ instead.
|
data/lib/bitcharts/engine.rb
CHANGED
@@ -4,6 +4,11 @@ module Bitcharts
|
|
4
4
|
config.autoload_paths += %W(#{config.root}/app/charts)
|
5
5
|
config.to_prepare do
|
6
6
|
::ApplicationController.helper(Bitcharts::ApplicationHelper)
|
7
|
+
Rails.application.config.assets.precompile += %w(
|
8
|
+
bitcharts/default.js
|
9
|
+
bitcharts/full.js
|
10
|
+
bitcharts/init.js
|
11
|
+
)
|
7
12
|
end
|
8
13
|
end
|
9
14
|
end
|
data/lib/bitcharts/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitcharts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Gaul
|
@@ -76,7 +76,9 @@ files:
|
|
76
76
|
- MIT-LICENSE
|
77
77
|
- README.rdoc
|
78
78
|
- Rakefile
|
79
|
-
- app/assets/javascripts/bitcharts/
|
79
|
+
- app/assets/javascripts/bitcharts/default.js.coffee
|
80
|
+
- app/assets/javascripts/bitcharts/full.js.coffee
|
81
|
+
- app/assets/javascripts/bitcharts/init.js.coffee
|
80
82
|
- app/assets/stylesheets/bitcharts/application.css
|
81
83
|
- app/controllers/bitcharts/application_controller.rb
|
82
84
|
- app/controllers/bitcharts/days_controller.rb
|