amcharts.rb 3.4.7.4 → 3.4.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/views/amcharts/_label.erb +10 -0
- data/app/views/amcharts/chart_builder.erb +1 -0
- data/lib/amcharts/chart.rb +8 -2
- data/lib/amcharts/chart_builder.rb +6 -0
- data/lib/amcharts/chart_builder/function.rb +10 -1
- data/lib/amcharts/settings.rb +2 -2
- data/lib/amcharts/version.rb +1 -1
- data/spec/chart_spec.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDUwZmRkNjllMmI0ZWEzZGU3NDc2NDM3MzkyYjYzYzk3MzZjMDcwOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YThhNjE5YWVhODcwNTg2MDczMDNhMTU0Y2QxOWFlYjAzMGQ4NGRkMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWU0M2Y4M2Q4ZjQzZWM4M2QzZDJmODI0NjY0YmNjMDA0ZjIxYjEzZjU5NmZi
|
10
|
+
MGZkOTBmMzc1MmU1Y2U5YTE3MGFkNjdiNjBhMTRiMTYzY2E2NjdiOTY4ZTJl
|
11
|
+
ZGZjYzE5MGZjNzExZWYzZTgyZWU4MzdmODQyMTY5NmVjNDUzY2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmVkMzQ1OThkMjRmNTI5NzM1ZThkOGNkNGFiNTA5YWQ3NWU2M2RmNmQwNTcy
|
14
|
+
MjM1ZjI5MThmYzk5YmM5OWIwMzcwNmNhMDFiYzJkMWNhY2U0NGU4OTAwNDE1
|
15
|
+
MDM5ZDAyOTQxZWFkNjZhODFiM2Y5MDM4YTJkMzQwMGVkNGUxZmQ=
|
@@ -0,0 +1,10 @@
|
|
1
|
+
chart.addLabel(
|
2
|
+
<%= builder.to_js x %>, <%= builder.to_js y %>, <%= builder.to_js text %>,
|
3
|
+
<%= builder.to_js options[:align] %>,
|
4
|
+
<%= builder.to_js options[:size] %>,
|
5
|
+
<%= builder.to_js options[:color] %>,
|
6
|
+
<%= builder.to_js options[:rotation] %>,
|
7
|
+
<%= builder.to_js options[:alpha] %>,
|
8
|
+
<%= builder.to_js options[:bold] %>,
|
9
|
+
<%= builder.to_js options[:url] %>
|
10
|
+
);
|
data/lib/amcharts/chart.rb
CHANGED
@@ -15,7 +15,7 @@ module AmCharts
|
|
15
15
|
|
16
16
|
attr_accessor :data_provider, :data_source, :container
|
17
17
|
attr_accessor :width, :height, :loading_indicator
|
18
|
-
attr_reader :titles, :graphs, :legends, :data, :settings, :listeners, :legend_div, :export
|
18
|
+
attr_reader :titles, :labels, :graphs, :legends, :data, :settings, :listeners, :legend_div, :export
|
19
19
|
|
20
20
|
def initialize(*data, &block)
|
21
21
|
@data = data.flatten
|
@@ -26,11 +26,13 @@ module AmCharts
|
|
26
26
|
@settings = Settings.new
|
27
27
|
@export = nil
|
28
28
|
@titles = []
|
29
|
+
@labels = []
|
29
30
|
update_settings(&block) if block_given?
|
30
31
|
end
|
31
32
|
|
32
33
|
def update_settings(&block)
|
33
34
|
instance_exec(self, &block)
|
35
|
+
self
|
34
36
|
end
|
35
37
|
|
36
38
|
# Allow data to be loaded from a remote source
|
@@ -71,7 +73,11 @@ module AmCharts
|
|
71
73
|
alias_method :exportable!, :export
|
72
74
|
|
73
75
|
def add_title(text, options = {})
|
74
|
-
@titles << [text, options.reverse_merge(size: 13, bold: true, alpha: 1, color: '#
|
76
|
+
@titles << [text, options.reverse_merge(size: 13, bold: true, alpha: 1, color: '#000')]
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_label(text, x, y, options = {})
|
80
|
+
@labels << [text, x, y, options.reverse_merge(size: 11, align: 'left', color: '#000', rotation: 0, alpha: 1, bold: false)]
|
75
81
|
end
|
76
82
|
|
77
83
|
def width=(w)
|
@@ -72,6 +72,12 @@ module AmCharts
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
def render_labels
|
76
|
+
chart.labels.each do |(text, x, y, options)|
|
77
|
+
concat render_js('label', locals: { text: text, x: x, y: y, options: options })
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
75
81
|
def render_listeners(object = chart, var_name = 'chart')
|
76
82
|
object.listeners.each do |listener|
|
77
83
|
concat render_js('listener', locals: { type: listener.type, method: listener.method, var_name: var_name })
|
@@ -1,6 +1,15 @@
|
|
1
1
|
module AmCharts
|
2
2
|
class ChartBuilder
|
3
|
-
class Function
|
3
|
+
class Function
|
4
|
+
attr_reader :name, :body
|
5
|
+
|
6
|
+
def initialize(name, body = nil)
|
7
|
+
@name, @body = name, body
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_json
|
11
|
+
body.nil? ? name.to_s : "function #{name}() { #{body} }"
|
12
|
+
end
|
4
13
|
end
|
5
14
|
end
|
6
15
|
end
|
data/lib/amcharts/settings.rb
CHANGED
data/lib/amcharts/version.rb
CHANGED
data/spec/chart_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amcharts.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.7.
|
4
|
+
version: 3.4.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Vandersluis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
type: :runtime
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- app/views/amcharts/_data.erb
|
154
154
|
- app/views/amcharts/_data_source.erb
|
155
155
|
- app/views/amcharts/_export.erb
|
156
|
+
- app/views/amcharts/_label.erb
|
156
157
|
- app/views/amcharts/_legend.erb
|
157
158
|
- app/views/amcharts/_listener.erb
|
158
159
|
- app/views/amcharts/_object.erb
|