chartjs-ror 2.1.0 → 2.1.1

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: 6f2ebce780d9ca9649f2b1fcd39b5fa6fa09db3b
4
- data.tar.gz: 1363a9862e86500e3387284e7e43d95ba3cb91be
3
+ metadata.gz: 70560e2b456473a72835faec8fb3747a4b8ca1c3
4
+ data.tar.gz: a0ac4716a25acd1fe9c5d982b739147314ded6a4
5
5
  SHA512:
6
- metadata.gz: 007b7d77f5c06bdd6c18cc782940073624d469e8e4ec00c582d156702c5fee413412baae7f7091e660305aac22a77f8a00ed254eace2ea128d507287954ec06a
7
- data.tar.gz: 9030000d33387b7259a27cb871df2d7906867f7f2d9f31b6a6cf636444f7797fed42371f3d0577564f0d70a99077be465b094dd412d174b6e3b051f8bad28737
6
+ metadata.gz: 2d8bf948ec87c2d2df3e29cae59726cd3613cae13e58d94c5f311c54e8ba2fcafa3db8336c62c642419d984cd023415048ca1e55ad8a5abb5fcf61dc2bd9a5b7
7
+ data.tar.gz: 41e7684be82798cf71c7698389733507af5477997da92e77c089a566355ee58f2018a1e263c4e4b1f4e41800e1f408375d061f9611790cb1fc82280158fbc508
data/README.md CHANGED
@@ -5,8 +5,13 @@ Simplifies using [Chart.js][] in Rails views.
5
5
  * All of Chart.js's features via one line of Ruby.
6
6
  * Renders charts on page load rather than DOMContentReady ([reason][browsersupport]).
7
7
  * Animates unless you have Modernizr and it doesn't detect canvas support ([reason][browsersupport]). You can manually override this.
8
- * Optional alternative (better?) abscissa scale calculations.
9
- * Utility method for filling in gaps in integer series.
8
+ * Optional alternative abscissa scale calculations (see [Chart.js#132][calculations]).
9
+ * Optional utility method for filling in gaps in integer series.
10
+
11
+
12
+ ## Current Chart.js version
13
+
14
+ This gem includes [Chart.js v1.0.1](https://github.com/nnnick/Chart.js/tree/v1.0.1).
10
15
 
11
16
 
12
17
  ## Installation
@@ -35,12 +40,30 @@ Each chart type has a corresponding helper for your views. The helper methods t
35
40
 
36
41
 
37
42
  ```erb
38
- <%= line_chart data, options %>
39
- <%= bar_chart data, options %>
40
- <%= radar_chart data, options %>
41
- <%= polar_chart data, options %>
42
- <%= pie_chart data, options %>
43
- <%= doughnut_chart data, options %>
43
+ <%= line_chart data, options %>
44
+ <%= bar_chart data, options %>
45
+ <%= radar_chart data, options %>
46
+ <%= polar_area_chart data, options %>
47
+ <%= pie_chart data, options %>
48
+ <%= doughnut_chart data, options %>
49
+ ```
50
+
51
+ If you don't want these helpers – perhaps they clash with other methods in your views – add this initializer to your app:
52
+
53
+ ```ruby
54
+ # config/initializers/chartjs.rb
55
+ Chartjs.no_confict!
56
+ ```
57
+
58
+ You can use these helpers instead:
59
+
60
+ ```erb
61
+ <%= chartjs_line_chart data, options %>
62
+ <%= chartjs_bar_chart data, options %>
63
+ <%= chartjs_radar_chart data, options %>
64
+ <%= chartjs_polar_area_chart data, options %>
65
+ <%= chartjs_pie_chart data, options %>
66
+ <%= chartjs_doughnut_chart data, options %>
44
67
  ```
45
68
 
46
69
  For example, to render a [line chart][linechart] in Javascript:
@@ -1,5 +1,14 @@
1
- require 'chartjs/engine'
2
- require "chartjs/version"
3
-
4
1
  module Chartjs
2
+ @@no_conflict = false
3
+
4
+ def self.no_conflict!
5
+ @@no_conflict = true
6
+ end
7
+
8
+ def self.no_conflict
9
+ @@no_conflict
10
+ end
5
11
  end
12
+
13
+ require 'chartjs/engine'
14
+ require "chartjs/version"
@@ -3,9 +3,9 @@ module Chartjs
3
3
 
4
4
  %w[ Line Bar Radar PolarArea Pie Doughnut ].each do |type|
5
5
  camel_type = type.gsub(/(\w)([A-Z])/, '\1_\2').downcase
6
- define_method "#{camel_type}_chart" do |data, options = {}| # def polar_area_chart(data, options = {})
7
- chart type, data, options # chart 'PolarArea', data, options
8
- end # end
6
+ define_method "chartjs_#{camel_type}_chart" do |data, options = {}| # def chartjs_polar_area_chart(data, options = {})
7
+ chart type, data, options # chart 'PolarArea', data, options
8
+ end # end
9
9
  end
10
10
 
11
11
  private
@@ -37,6 +37,8 @@ module Chartjs
37
37
  <<-END.squish.html_safe
38
38
  (function() {
39
39
  var initChart = function() {
40
+ window.Chart && window.Chart[#{element_id.to_json}] && window.Chart[#{element_id.to_json}].destroy();
41
+
40
42
  var data = #{data.to_json};
41
43
  var opts = #{options.to_json};
42
44
  if (!("animation" in opts)) {
@@ -5,6 +5,15 @@ module Chartjs
5
5
  class Engine < Rails::Engine
6
6
  initializer 'chartjs.chart_helpers' do
7
7
  ActionView::Base.send :include, Chartjs::ChartHelpers
8
+
9
+ unless ::Chartjs.no_conflict
10
+ ActionView::Base.class_eval do
11
+ %w[ line bar radar polar_area pie doughnut ].each do |type|
12
+ alias :"#{type}_chart" :"chartjs_#{type}_chart"
13
+ end
14
+ end
15
+ end
16
+
8
17
  ActionView::Base.send :include, Chartjs::AxisHelpers
9
18
  end
10
19
  end
@@ -1,3 +1,3 @@
1
1
  module Chartjs
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chartjs-ror
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-14 00:00:00.000000000 Z
11
+ date: 2015-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails