chartkick 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of chartkick might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d0f0bc351764e3b7e4667d14958ba9672d72949
4
- data.tar.gz: 4d063d2c8ed4d3e6443f8d7ed39c8b2bca48636a
3
+ metadata.gz: 128a490e06abdcd32d0c7b941b4b087b3a633827
4
+ data.tar.gz: fa41e91b74b5d857a5c4037a95795e975a911aa0
5
5
  SHA512:
6
- metadata.gz: 747033c51547a541ce97c4e0c193cd5049484e7cc918df5df3e1c29c453b87f3ac61f0a19e6024f39e9e688bb9f6b419c0267d991491dd5f3d06ef7a6d85907b
7
- data.tar.gz: fa38a2827ad09bb112307fa9ba9d8dd4ce7f7560dc3d6b6927c7954941567f90e1f53e0f5b1a7069821ad758b049a5bcfa6852424beb5c4ee5992edacd3f9281
6
+ metadata.gz: e05a9b51baa1528c89fcc92c23c94b6f010b86e30554552e306ad4f2b502cf95e146b346b716f9dcd08faa3a85bab087fa14410c16ff7a912a7b43dec591c3ef
7
+ data.tar.gz: 2530a2f68acc7c21eb1f653a3b0a7719c2dc0dd41dbaa675402a1e1214b67c78eb08a3aefd27bb5b14231adc8faefa9686be4941ceeea18375a4758e153aa8e7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.1.3
2
+
3
+ - Added content_for option
4
+
1
5
  ## 1.1.2
2
6
 
3
7
  - Updated chartkick.js to v1.0.1
data/README.md CHANGED
@@ -76,6 +76,18 @@ You can pass options directly to the charting library with:
76
76
  <%= line_chart User.group_by_day(:created_at).count, :library => {:backgroundColor => "#eee"} %>
77
77
  ```
78
78
 
79
+ You can also pass a content_for option, which will put the javascript in a content block. This is great for including all of your javascript at the bottom of the page.
80
+
81
+ ```erb
82
+ <%= line_chart User.group_by_day(:created_at).count, :content_for => :js_initialization %>
83
+ ```
84
+ Then, in your layout:
85
+
86
+ ```erb
87
+ <%= yield :js_initialization # Rails %>
88
+ <%= yield_content :js_initialization # Padrino %>
89
+ ```
90
+
79
91
  ### Data
80
92
 
81
93
  Pass data as a Hash or Array
@@ -108,7 +120,7 @@ Add this line to your application's Gemfile:
108
120
  gem "chartkick"
109
121
  ```
110
122
 
111
- And add the javascript files to your views. These files must be included **before** the helper methods.
123
+ And add the javascript files to your views. These files must be included **before** the helper methods, unless using the `:content_for` option.
112
124
 
113
125
  For Google Charts, use:
114
126
 
@@ -28,10 +28,17 @@ module Chartkick
28
28
  <div id="#{ERB::Util.html_escape(element_id)}" style="height: #{ERB::Util.html_escape(height)}; text-align: center; color: #999; line-height: #{ERB::Util.html_escape(height)}; font-size: 14px; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif;">
29
29
  Loading...
30
30
  </div>
31
+ HTML
32
+ js = <<JS
31
33
  <script type="text/javascript">
32
34
  new Chartkick.#{klass}(#{element_id.to_json}, #{data_source.to_json}, #{options.to_json});
33
35
  </script>
34
- HTML
36
+ JS
37
+ if options[:content_for]
38
+ content_for(options[:content_for]) { js.respond_to?(:html_safe) ? js.html_safe : js }
39
+ else
40
+ html += js
41
+ end
35
42
 
36
43
  html.respond_to?(:html_safe) ? html.html_safe : html
37
44
  end
@@ -1,3 +1,3 @@
1
1
  module Chartkick
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chartkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-12 00:00:00.000000000 Z
11
+ date: 2013-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler