rails_charts 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/rails_charts/base_chart.rb +13 -12
- data/lib/rails_charts/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 460115967715c86a598bf125d23580fc781154445e4a7752623579868009c409
|
4
|
+
data.tar.gz: 63f5815f0c51083b58fc1036c668b51b7a770f47b09f2734ec90b0e6a31fce94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af2ddf1ae9553126c82522db0f37d81da9856d029b1fb8f4be8afeaa609a250a15cb2aebd4e7b8fe7a3f66ccfbbff95d6b02476caed0a898fa887450d6a00074
|
7
|
+
data.tar.gz: b0336548ae63cfd514029cd8bc186208981865369c6a68ea99c4aab062a5bfa8743ca7ed33e4590a916e049bbbb8a3bf4719e7221621e171cf60b6e277865f51
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# Rails Charts
|
2
2
|
|
3
|
+
[](https://www.railsjazz.com)
|
4
|
+
|
3
5
|

|
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
|
-
@
|
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
|
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
|
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',
|
72
|
-
window.addEventListener('turbo:load',
|
73
|
-
window.addEventListener('turbolinks:load',
|
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",
|
76
|
-
document.addEventListener("turbo:before-render",
|
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
|
}
|
data/lib/rails_charts/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2022-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|