rails_charts 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
  }
@@ -12,7 +12,7 @@ module RailsCharts
12
12
  def radar
13
13
  {
14
14
  radar: {
15
- indicator: data[:indicators].map{|(k, v)| {name: k, value: v} }
15
+ indicator: data[:indicators].map { |(k, v)| { name: k, max: v } }
16
16
  }
17
17
  }
18
18
  end
@@ -33,6 +33,6 @@ module RailsCharts
33
33
  },
34
34
  }
35
35
  end
36
-
37
- end
38
- end
36
+
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsCharts
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
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.4
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-10-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -185,6 +185,8 @@ files:
185
185
  - app/assets/javascripts/echarts/i18n/langSI.js
186
186
  - app/assets/javascripts/echarts/i18n/langTH-obj.js
187
187
  - app/assets/javascripts/echarts/i18n/langTH.js
188
+ - app/assets/javascripts/echarts/i18n/langUA-obj.js
189
+ - app/assets/javascripts/echarts/i18n/langUA.js
188
190
  - app/assets/javascripts/echarts/i18n/langZH-obj.js
189
191
  - app/assets/javascripts/echarts/i18n/langZH.js
190
192
  - app/assets/javascripts/echarts/theme/azul.js