From 8e0adf4147f85a67258c53caa7a026b76273f805 Mon Sep 17 00:00:00 2001 From: Igor Kasyanchuk Date: Tue, 23 Oct 2018 05:02:37 -0400 Subject: [PATCH] fixed google.load issue with charts --- lib/google_visualr/base_chart.rb | 2 +- spec/support/common.rb | 6 +++--- spec/turbolinks_tests/broken.html | 2 +- spec/turbolinks_tests/fixed.html | 2 +- spec/turbolinks_tests/old.html | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) mode change 100644 => 100755 lib/google_visualr/base_chart.rb mode change 100644 => 100755 spec/support/common.rb mode change 100644 => 100755 spec/turbolinks_tests/broken.html mode change 100644 => 100755 spec/turbolinks_tests/fixed.html mode change 100644 => 100755 spec/turbolinks_tests/old.html diff --git a/lib/google_visualr/base_chart.rb b/lib/google_visualr/base_chart.rb old mode 100644 new mode 100755 index 56923b2..4c19ae3 --- a/lib/google_visualr/base_chart.rb +++ b/lib/google_visualr/base_chart.rb @@ -76,7 +76,7 @@ def to_js(element_id) def load_js(element_id) language_opt = ", language: '#{language}'" if language - "\n google.load('visualization', '#{version}', {packages: ['#{package_name}']#{language_opt}, callback: #{chart_function_name(element_id)}});" + "\n google.charts.load('visualization', '#{version}', {packages: ['#{package_name}']#{language_opt}, callback: #{chart_function_name(element_id)}});" end # Generates JavaScript function for rendering the chart. diff --git a/spec/support/common.rb b/spec/support/common.rb old mode 100644 new mode 100755 index a878fbc..ed8a774 --- a/spec/support/common.rb +++ b/spec/support/common.rb @@ -20,7 +20,7 @@ def base_chart(data_table = data_table()) def base_chart_js_without_script_tag(div_class = "div_class", language = nil) language_opt = ", language: '#{language}'" if language - js = "\n google.load('visualization', '1.0', {packages: ['basechart']#{language_opt}, callback: draw_#{div_class}});" + js = "\n google.charts.load('visualization', '1.0', {packages: ['basechart']#{language_opt}, callback: draw_#{div_class}});" js << "\n function draw_#{div_class}() {" 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}'));" js << "\n chart.draw(data_table, {legend: \"Test Chart\", width: 800, is3D: true});" @@ -35,7 +35,7 @@ def base_chart_js(div_class = "div_class", language = nil) def base_chart_with_listener_js(div_class = "div_class") js = "\n