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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f14bd700fdacea816584879122138ce39eab28e6
4
- data.tar.gz: e9adbde0b4e13535a51083e613708062fb732283
3
+ metadata.gz: ffa0c3419f3193fcc1a82ddaaaec263147a861ae
4
+ data.tar.gz: c896ef9f22a8805ba2cf3dae45fbdc4681d6a543
5
5
  SHA512:
6
- metadata.gz: 98f971f160b30396f351098aff05135974cb7d758e2a831982341fbf1dd857f9afb79e98ebbc368cba0b86b4620eec66fe3dcd8c8ad812f0340da96d8f5b958d
7
- data.tar.gz: 40f99d134023f652d2a1a09883c931c7369a3d08402c6c8f63347e27de3c425b7ef1af02b7dcde3a5ce7324cf1c4dd1375b8b0899e9a0ddbbfe28edb6bc4ea6a
6
+ metadata.gz: 477dedeedca6777d798eea4b9d14614b074c3ac94d3baf156d0e83b4e2d6535edf1b12fda135be662b84043bfad390415ebc8e5f4f4bb3b7eb2ad7a9a742495c
7
+ data.tar.gz: 36aabcbecaa467d7e3ce4034581ff018ea15552c33ad33784cf08f30ce2659bc59712af8a95828c3035f19a84ffd41516cc17814d0cfdd5510b5f19650d595a7
@@ -1,19 +1,35 @@
1
- = Bitcharts =
1
+ = Bitcharts
2
2
 
3
- == Usage ==
3
+ == Usage
4
4
 
5
- 1. Generate a chart
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
- 2. Implement chart's value method in `app/charts/user_logins_chart.rb`
14
- 3. Include canvas into your view
9
+ === Generate a chart
15
10
 
16
- ~~~
17
- <%= bitchart 'user_logins', from: 7.days.ago, to: Date.today %>
18
- <%# Check Bitcharts::ApplicationHelper for more options %>
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.
@@ -0,0 +1,2 @@
1
+ #= require chart.min.js
2
+ #= require bitcharts/init
@@ -0,0 +1,3 @@
1
+ #= require jquery
2
+ #= require chart.min.js
3
+ #= require bitcharts/init
@@ -1,6 +1,3 @@
1
- #= require jquery
2
- #= require chart.min.js
3
-
4
1
  @Bitcharts = Bitcharts =
5
2
 
6
3
  defaultBorderWidth: 2
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Bitcharts
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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/application.js.coffee
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