rails_charts 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
  SHA256:
3
- metadata.gz: 50c27a4b7e73edf104326a0c43e498158b15b6983a445ada2bb253ff79ebeeee
4
- data.tar.gz: 2f30630d19ac238e32aca3648ba60adc57d3e82bde8ff3822057165ed2a9efd0
3
+ metadata.gz: 460115967715c86a598bf125d23580fc781154445e4a7752623579868009c409
4
+ data.tar.gz: 63f5815f0c51083b58fc1036c668b51b7a770f47b09f2734ec90b0e6a31fce94
5
5
  SHA512:
6
- metadata.gz: f005aa895ad8979ff0dfbd76c0f11743695ec1bd0ee80a073cd90be2ab7f92823bef2002859ac7f67c4392e36f49ca87ab659be62fbdbdc80a15b8e46c7181fa
7
- data.tar.gz: 6be80b111bbfbaf227c43f1e55cc2bf447a456b7f06e435c5441774faf10afc35b27a14813a05e9969ba507802d72bdd452eaaed991facffacb9e6a02b1a99f8
6
+ metadata.gz: af2ddf1ae9553126c82522db0f37d81da9856d029b1fb8f4be8afeaa609a250a15cb2aebd4e7b8fe7a3f66ccfbbff95d6b02476caed0a898fa887450d6a00074
7
+ data.tar.gz: b0336548ae63cfd514029cd8bc186208981865369c6a68ea99c4aab062a5bfa8743ca7ed33e4590a916e049bbbb8a3bf4719e7221621e171cf60b6e277865f51
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Rails Charts
2
2
 
3
+ [![RailsJazz](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/my_other.svg?raw=true)](https://www.railsjazz.com)
4
+
3
5
  ![Charts](docs/all.jpg)
4
6
 
5
7
  One more gem to build nice charts for your Ruby on Rails application.
6
8
 
7
- With it you can build various types of charts Apache eCharts library (v. 5.3.2). This gem simplifies interface and adding few helpers to start adding charts in your app with just a few lines of code.
9
+ With it you can build various types of charts [Apache eCharts](https://echarts.apache.org/) library (v. 5.3.2). This gem simplifies interface and adding few helpers to start adding charts in your app with just a few lines of code.
8
10
 
9
11
  What you can build with it:
10
12
 
@@ -4,7 +4,7 @@ module RailsCharts
4
4
 
5
5
  using RubyExt
6
6
 
7
- attr_reader :data, :options, :container_id, :defaults
7
+ attr_reader :data, :options, :chart_id, :container_id, :defaults
8
8
  attr_reader :width, :height, :style, :klass, :theme, :locale
9
9
  attr_reader :other_options, :debug
10
10
  attr_reader :vertical
@@ -15,7 +15,8 @@ module RailsCharts
15
15
  @other_options = options.delete(:options).presence || {}
16
16
  @defaults = RailsCharts.defaults[self.class].presence || {}
17
17
 
18
- @container_id = options.delete(:id).presence || "rails_charts_#{Digest::SHA1.hexdigest([Time.now, rand].join)}"
18
+ @chart_id = "rails_charts_#{Digest::SHA1.hexdigest([Time.now, rand].join)}"
19
+ @container_id = options.delete(:id).presence || @chart_id
19
20
 
20
21
  @width = options.delete(:width).presence || RailsCharts.options[:width]
21
22
  @height = options.delete(:height).presence || RailsCharts.options[:height]
@@ -23,7 +24,7 @@ module RailsCharts
23
24
  @locale = options.delete(:locale).presence || RailsCharts.options[:locale]
24
25
  @klass = options.delete(:class).presence || RailsCharts.options[:class]
25
26
  @style = options.delete(:style).presence || RailsCharts.options[:style]
26
-
27
+
27
28
  @debug = options.delete(:debug)
28
29
 
29
30
  @vertical = options.delete(:vertical).presence
@@ -43,15 +44,15 @@ module RailsCharts
43
44
  window.RailsCharts.charts = {}
44
45
  }
45
46
 
46
- function init#{container_id}(e) {
47
+ function init_#{chart_id}(e) {
47
48
  if (document.documentElement.hasAttribute("data-turbolinks-preview")) return;
48
49
  if (document.documentElement.hasAttribute("data-turbo-preview")) return;
49
-
50
+
50
51
  <!-- #{self.class} -->
51
52
  var chartDom = document.getElementById('#{container_id}');
52
53
 
53
54
  if (!chartDom) { return }
54
-
55
+
55
56
  var lib = ("echarts" in window) ? window.echarts : echarts;
56
57
  var chart = lib.init(chartDom, #{theme.to_json}, { "locale": #{locale.to_json} });
57
58
  var option = #{option};
@@ -60,7 +61,7 @@ module RailsCharts
60
61
  window.RailsCharts.charts["#{container_id}"] = chart;
61
62
  }
62
63
 
63
- function destroy#{container_id}(e) {
64
+ function destroy_#{chart_id}(e) {
64
65
  var chart = window.RailsCharts.charts["#{container_id}"];
65
66
  if (chart) {
66
67
  chart.dispose()
@@ -68,12 +69,12 @@ module RailsCharts
68
69
  delete window.RailsCharts.charts["#{container_id}"];
69
70
  }
70
71
 
71
- window.addEventListener('load', init#{container_id});
72
- window.addEventListener('turbo:load', init#{container_id});
73
- window.addEventListener('turbolinks:load', init#{container_id});
72
+ window.addEventListener('load', init_#{chart_id});
73
+ window.addEventListener('turbo:load', init_#{chart_id});
74
+ window.addEventListener('turbolinks:load', init_#{chart_id});
74
75
 
75
- document.addEventListener("turbolinks:before-render", destroy#{container_id});
76
- document.addEventListener("turbo:before-render", destroy#{container_id});
76
+ document.addEventListener("turbolinks:before-render", destroy_#{chart_id});
77
+ document.addEventListener("turbo:before-render", destroy_#{chart_id});
77
78
  </script>
78
79
  </div>
79
80
  }
@@ -1,3 +1,3 @@
1
1
  module RailsCharts
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: rails_charts
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
  - Igor Kasyanchuk
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-04-28 00:00:00.000000000 Z
12
+ date: 2022-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails