google_visualr 2.5.0 → 2.5.1

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
  SHA1:
3
- metadata.gz: 762cd55fa47b092ed0ce4efbe9dfa17d37e787f8
4
- data.tar.gz: 92c5ef41f18dcb711fa9b9a4a42d539a57a9adb6
3
+ metadata.gz: 26841661bff6a29726756d54160ca355717083cd
4
+ data.tar.gz: a1c0aae26ae4cef3d89c4bb24e07c9d255c7aa19
5
5
  SHA512:
6
- metadata.gz: 39bc89ba661c876461e9245758f7b06308df4967841f02146086294299a2524f28c4e94e7adcd8fe0fe36fe0ecaae9a6a4a2a1164162d6893cd5976a0e66e2a7
7
- data.tar.gz: f01987a2e6f447dfebf6bd4347f4a6bcc8b51a3f40a43558bc9cd3984c43e8b46b903e9f7f4375388e8da2e0d2e1b7f909e24c73bce7aa54544fa1c3b63ce6c1
6
+ metadata.gz: 1ec5cb6ef95d5e87d95c183ebfa9c2ce721a8b33053fc2b606e35c051697ac75a0345393c4f575ffae4f46188e783014fa734cece4aa7053f69b04baabf649d1
7
+ data.tar.gz: 42908dc139fecc4a98aa4678ca45fe38d247472c0700f92fcc2a57f9cae02aa3fe8ee0de0cdcce17e6b853f4f699042715f591647dc21a02a0c96133ab3e8c63
@@ -11,7 +11,7 @@ module GoogleVisualr
11
11
  @data_table = data_table
12
12
  @listeners = []
13
13
  @version = options.delete(:version) || DEFAULT_VERSION
14
- @language = options.delete(:language) || "en"
14
+ @language = options.delete(:language)
15
15
  @material = options.delete(:material) || false
16
16
  send(:options=, options)
17
17
  end
@@ -74,7 +74,9 @@ module GoogleVisualr
74
74
  # Parameters:
75
75
  # *div_id [Required] The ID of the DIV element that the Google Chart should be rendered in.
76
76
  def load_js(element_id)
77
- "\n google.load('visualization', '#{version}', {packages: ['#{package_name}'], language: '#{language}', callback: #{chart_function_name(element_id)}});"
77
+ language_opt = ", language: '#{language}'" if language
78
+
79
+ "\n google.load('visualization', '#{version}', {packages: ['#{package_name}']#{language_opt}, callback: #{chart_function_name(element_id)}});"
78
80
  end
79
81
 
80
82
  # Generates JavaScript function for rendering the chart.
@@ -1,3 +1,3 @@
1
1
  module GoogleVisualr
2
- VERSION = "2.5.0"
2
+ VERSION = "2.5.1"
3
3
  end
@@ -13,6 +13,7 @@ describe GoogleVisualr::BaseChart do
13
13
  @chart.version.should == GoogleVisualr::BaseChart::DEFAULT_VERSION
14
14
  @chart.material.should == false
15
15
  @chart.options.should == { "legend" => "Test Chart", "width" => 800, "is3D" => true }
16
+ @chart.language.should == nil
16
17
  end
17
18
 
18
19
  it "accepts version attribute" do
@@ -98,6 +99,11 @@ describe GoogleVisualr::BaseChart do
98
99
  js.should include("<script")
99
100
  end
100
101
 
102
+ it "generates JS without any locale as default" do
103
+ js = @chart.to_js("body")
104
+ js.should == base_chart_js("body", nil)
105
+ end
106
+
101
107
  it "generates JS of a different locale" do
102
108
  @chart.language = "ja"
103
109
 
@@ -17,15 +17,17 @@ def base_chart(data_table = data_table())
17
17
  GoogleVisualr::BaseChart.new(data_table, { :legend => "Test Chart", :width => 800, :is3D => true })
18
18
  end
19
19
 
20
- def base_chart_js_without_script_tag(div_class = "div_class", language = "en")
21
- js = "\n google.load('visualization', '1.0', {packages: ['basechart'], language: '#{language}', callback: draw_#{div_class}});"
20
+ def base_chart_js_without_script_tag(div_class = "div_class", language = nil)
21
+ language_opt = ", language: '#{language}'" if language
22
+
23
+ js = "\n google.load('visualization', '1.0', {packages: ['basechart']#{language_opt}, callback: draw_#{div_class}});"
22
24
  js << "\n function draw_#{div_class}() {"
23
25
  js << "\n var data_table = new google.visualization.DataTable();data_table.addColumn({\"type\":\"string\",\"label\":\"Year\"});data_table.addColumn({\"type\":\"number\",\"label\":\"Sales\"});data_table.addColumn({\"type\":\"number\",\"label\":\"Expenses\"});data_table.addRow([{v: \"2004\"}, {v: 1000}, {v: 400}]);data_table.addRow([{v: \"2005\"}, {v: 1200}, {v: 450}]);data_table.addRow([{v: \"2006\"}, {v: 1500}, {v: 600}]);data_table.addRow([{v: \"2007\"}, {v: 800}, {v: 500}]);\n var chart = new google.visualization.BaseChart(document.getElementById('#{div_class}'));"
24
26
  js << "\n chart.draw(data_table, {legend: \"Test Chart\", width: 800, is3D: true});"
25
27
  js << "\n };"
26
28
  end
27
29
 
28
- def base_chart_js(div_class = "div_class", language = "en")
30
+ def base_chart_js(div_class = "div_class", language = nil)
29
31
  js = "\n<script type='text/javascript'>"
30
32
  js << base_chart_js_without_script_tag(div_class, language)
31
33
  js << "\n</script>"
@@ -33,7 +35,7 @@ end
33
35
 
34
36
  def base_chart_with_listener_js(div_class = "div_class")
35
37
  js = "\n<script type='text/javascript'>"
36
- js << "\n google.load('visualization', '1.0', {packages: ['basechart'], language: 'en', callback: draw_#{div_class}});"
38
+ js << "\n google.load('visualization', '1.0', {packages: ['basechart'], callback: draw_#{div_class}});"
37
39
  js << "\n function draw_#{div_class}() {"
38
40
  js << "\n var data_table = new google.visualization.DataTable();data_table.addColumn({\"type\":\"string\",\"label\":\"Year\"});data_table.addColumn({\"type\":\"number\",\"label\":\"Sales\"});data_table.addColumn({\"type\":\"number\",\"label\":\"Expenses\"});data_table.addRow([{v: \"2004\"}, {v: 1000}, {v: 400}]);data_table.addRow([{v: \"2005\"}, {v: 1200}, {v: 450}]);data_table.addRow([{v: \"2006\"}, {v: 1500}, {v: 600}]);data_table.addRow([{v: \"2007\"}, {v: 800}, {v: 500}]);\n var chart = new google.visualization.BaseChart(document.getElementById('#{div_class}'));"
39
41
  js << "\n google.visualization.events.addListener(chart, 'select', function() {test_event(chart);});"
@@ -44,7 +46,7 @@ end
44
46
 
45
47
  def material_chart(div_class = "div_class")
46
48
  js = "\n<script type='text/javascript'>"
47
- js << "\n google.load('visualization', '1.0', {packages: ['basechart'], language: 'en', callback: draw_#{div_class}});"
49
+ js << "\n google.load('visualization', '1.0', {packages: ['basechart'], callback: draw_#{div_class}});"
48
50
  js << "\n function draw_#{div_class}() {"
49
51
  js << "\n var data_table = new google.visualization.DataTable();data_table.addColumn({\"type\":\"string\",\"label\":\"Year\"});data_table.addColumn({\"type\":\"number\",\"label\":\"Sales\"});data_table.addColumn({\"type\":\"number\",\"label\":\"Expenses\"});data_table.addRow([{v: \"2004\"}, {v: 1000}, {v: 400}]);data_table.addRow([{v: \"2005\"}, {v: 1200}, {v: 450}]);data_table.addRow([{v: \"2006\"}, {v: 1500}, {v: 600}]);data_table.addRow([{v: \"2007\"}, {v: 800}, {v: 500}]);\n var chart = new google.charts.Base(document.getElementById('#{div_class}'));"
50
52
  js << "\n chart.draw(data_table, {legend: \"Test Chart\", width: 800, is3D: true});"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_visualr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winston Teo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-27 00:00:00.000000000 Z
11
+ date: 2015-08-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This Ruby gem, GoogleVisualr, is a wrapper around the Google Chart Tools
14
14
  that allows anyone to create the same beautiful charts with just Ruby; you don't