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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDM5ZjUxNGRkNzk3ZWFiMGY2NzZhYzdhN2ZmYjM1YWVkNTYyMjE3Yg==
4
+ MDUwZmRkNjllMmI0ZWEzZGU3NDc2NDM3MzkyYjYzYzk3MzZjMDcwOA==
5
5
  data.tar.gz: !binary |-
6
- NTIzMzYyN2RhYzk4YWU3ZTMzYjA5Mjc4NzYwNDE4ZjI0OTNiOTY4ZQ==
6
+ YThhNjE5YWVhODcwNTg2MDczMDNhMTU0Y2QxOWFlYjAzMGQ4NGRkMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGJhM2M5YTJjN2M4NTU4YWMxZjE1YmViMDkwMWFiOGU0Yjg0OWE5NGQzZWNm
10
- NTY3OWU1MjM1OGQ4Nzg5MWFhNDdjZTFhZjBmMGE1MTE1ZDNiNDc3ZjliNzA2
11
- NGE5NmVmZGU5ZDhkM2E5YWVkMThlODQ2YzQ1Njg3ZGJhZDhiMDY=
9
+ YWU0M2Y4M2Q4ZjQzZWM4M2QzZDJmODI0NjY0YmNjMDA0ZjIxYjEzZjU5NmZi
10
+ MGZkOTBmMzc1MmU1Y2U5YTE3MGFkNjdiNjBhMTRiMTYzY2E2NjdiOTY4ZTJl
11
+ ZGZjYzE5MGZjNzExZWYzZTgyZWU4MzdmODQyMTY5NmVjNDUzY2Y=
12
12
  data.tar.gz: !binary |-
13
- YjRiOWMyNzhjODA2NWRjNGFiNDU5ZDA3NTZkZjEwODIxYjBmMDg1Y2RkOWQy
14
- MDQzOTQ2ZWFhODVlNGVlMDU3YjcwODkxYzVjYzE1NDgwNmE3NTVhNTc5NmRl
15
- NmY0NmY4OTg0OWNlZmZlYTBkYjczYTFjNWM4NGMyMTVkOTNhOWE=
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
+ );
@@ -30,6 +30,7 @@ AmCharts.ready(function() {
30
30
  <% builder.render_component(chart.scrollbar, name: :chart_scrollbar) %>
31
31
 
32
32
  <% builder.render_title %>
33
+ <% builder.render_labels %>
33
34
 
34
35
  <% builder.render_listeners %>
35
36
 
@@ -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: '#000000')]
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 < Literal
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
@@ -13,8 +13,8 @@ module AmCharts
13
13
  @settings = hash.with_indifferent_access
14
14
  end
15
15
 
16
- def function(name)
17
- ChartBuilder::Function.new(name)
16
+ def function(name, body = nil)
17
+ ChartBuilder::Function.new(name, body)
18
18
  end
19
19
 
20
20
  def literal(name)
@@ -1,3 +1,3 @@
1
1
  module AmCharts
2
- VERSION = "3.4.7.4"
2
+ VERSION = "3.4.7.5"
3
3
  end
data/spec/chart_spec.rb CHANGED
@@ -42,5 +42,9 @@ describe AmCharts::Chart do
42
42
  subject.update_settings { |c| c.foo = :baz }
43
43
  subject.settings[:foo].should == :baz
44
44
  end
45
+
46
+ it "should return the chart" do
47
+ subject.update_settings{}.should == subject
48
+ end
45
49
  end
46
50
  end
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
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-10 00:00:00.000000000 Z
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