google_visualr_rails5 2.5.2

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.
Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +22 -0
  3. data/README.md +159 -0
  4. data/Rakefile +9 -0
  5. data/lib/google_visualr.rb +53 -0
  6. data/lib/google_visualr/app/helpers/view_helper.rb +26 -0
  7. data/lib/google_visualr/app/railtie.rb +19 -0
  8. data/lib/google_visualr/base_chart.rb +100 -0
  9. data/lib/google_visualr/data_table.rb +294 -0
  10. data/lib/google_visualr/formatters.rb +78 -0
  11. data/lib/google_visualr/image/bar_chart.rb +47 -0
  12. data/lib/google_visualr/image/line_chart.rb +47 -0
  13. data/lib/google_visualr/image/pie_chart.rb +47 -0
  14. data/lib/google_visualr/image/spark_line.rb +34 -0
  15. data/lib/google_visualr/interactive/annotated_time_line.rb +11 -0
  16. data/lib/google_visualr/interactive/annotation_chart.rb +11 -0
  17. data/lib/google_visualr/interactive/area_chart.rb +13 -0
  18. data/lib/google_visualr/interactive/bar_chart.rb +29 -0
  19. data/lib/google_visualr/interactive/bubble_chart.rb +13 -0
  20. data/lib/google_visualr/interactive/calendar.rb +11 -0
  21. data/lib/google_visualr/interactive/candlestick_chart.rb +13 -0
  22. data/lib/google_visualr/interactive/column_chart.rb +29 -0
  23. data/lib/google_visualr/interactive/combo_chart.rb +13 -0
  24. data/lib/google_visualr/interactive/gantt_chart.rb +16 -0
  25. data/lib/google_visualr/interactive/gauge.rb +11 -0
  26. data/lib/google_visualr/interactive/geo_chart.rb +11 -0
  27. data/lib/google_visualr/interactive/geo_map.rb +11 -0
  28. data/lib/google_visualr/interactive/histogram.rb +14 -0
  29. data/lib/google_visualr/interactive/intensity_map.rb +11 -0
  30. data/lib/google_visualr/interactive/line_chart.rb +21 -0
  31. data/lib/google_visualr/interactive/map.rb +11 -0
  32. data/lib/google_visualr/interactive/motion_chart.rb +11 -0
  33. data/lib/google_visualr/interactive/org_chart.rb +11 -0
  34. data/lib/google_visualr/interactive/pie_chart.rb +13 -0
  35. data/lib/google_visualr/interactive/sankey.rb +11 -0
  36. data/lib/google_visualr/interactive/scatter_chart.rb +21 -0
  37. data/lib/google_visualr/interactive/stepped_area_chart.rb +13 -0
  38. data/lib/google_visualr/interactive/table.rb +11 -0
  39. data/lib/google_visualr/interactive/timeline.rb +11 -0
  40. data/lib/google_visualr/interactive/tree_map.rb +11 -0
  41. data/lib/google_visualr/interactive/word_tree.rb +11 -0
  42. data/lib/google_visualr/packages.rb +98 -0
  43. data/lib/google_visualr/param_helpers.rb +57 -0
  44. data/lib/google_visualr/version.rb +3 -0
  45. data/spec/dummy/Gemfile +0 -0
  46. data/spec/dummy/Gemfile.lock +7 -0
  47. data/spec/dummy/Rakefile +7 -0
  48. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  49. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  50. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  51. data/spec/dummy/config.ru +4 -0
  52. data/spec/dummy/config/application.rb +38 -0
  53. data/spec/dummy/config/boot.rb +6 -0
  54. data/spec/dummy/config/database.yml +22 -0
  55. data/spec/dummy/config/environment.rb +5 -0
  56. data/spec/dummy/config/environments/development.rb +30 -0
  57. data/spec/dummy/config/environments/production.rb +84 -0
  58. data/spec/dummy/config/environments/test.rb +41 -0
  59. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  60. data/spec/dummy/config/initializers/inflections.rb +10 -0
  61. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  62. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  63. data/spec/dummy/config/initializers/session_store.rb +8 -0
  64. data/spec/dummy/config/locales/en.yml +5 -0
  65. data/spec/dummy/config/routes.rb +58 -0
  66. data/spec/dummy/db/seeds.rb +7 -0
  67. data/spec/dummy/doc/README_FOR_APP +2 -0
  68. data/spec/dummy/log/development.log +0 -0
  69. data/spec/dummy/log/production.log +0 -0
  70. data/spec/dummy/log/server.log +0 -0
  71. data/spec/dummy/log/test.log +0 -0
  72. data/spec/dummy/public/404.html +26 -0
  73. data/spec/dummy/public/422.html +26 -0
  74. data/spec/dummy/public/500.html +26 -0
  75. data/spec/dummy/public/favicon.ico +0 -0
  76. data/spec/dummy/public/images/rails.png +0 -0
  77. data/spec/dummy/public/index.html +239 -0
  78. data/spec/dummy/public/javascripts/application.js +2 -0
  79. data/spec/dummy/public/javascripts/controls.js +965 -0
  80. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  81. data/spec/dummy/public/javascripts/effects.js +1123 -0
  82. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  83. data/spec/dummy/public/javascripts/rails.js +191 -0
  84. data/spec/dummy/public/robots.txt +5 -0
  85. data/spec/dummy/script/rails +6 -0
  86. data/spec/dummy/test/performance/browsing_test.rb +9 -0
  87. data/spec/dummy/test/test_helper.rb +13 -0
  88. data/spec/google_visualr/app/helpers/view_helper_spec.rb +25 -0
  89. data/spec/google_visualr/base_chart_spec.rb +129 -0
  90. data/spec/google_visualr/data_table_spec.rb +331 -0
  91. data/spec/google_visualr/formatters_spec.rb +105 -0
  92. data/spec/google_visualr/image_charts_spec.rb +127 -0
  93. data/spec/google_visualr/param_helpers_spec.rb +91 -0
  94. data/spec/spec_helper.rb +25 -0
  95. data/spec/support/common.rb +55 -0
  96. data/spec/turbolinks_tests/broken.html +19 -0
  97. data/spec/turbolinks_tests/fixed.html +18 -0
  98. data/spec/turbolinks_tests/index.html +15 -0
  99. data/spec/turbolinks_tests/old.html +17 -0
  100. data/spec/turbolinks_tests/turbolinks.js +455 -0
  101. metadata +204 -0
@@ -0,0 +1,78 @@
1
+ module GoogleVisualr
2
+
3
+ # http://code.google.com/apis/chart/interactive/docs/reference.html#formatters
4
+ class Formatter
5
+ include GoogleVisualr::ParamHelpers
6
+
7
+ def initialize(options={})
8
+ @options = options
9
+ end
10
+
11
+
12
+ def columns(*columns)
13
+ @columns = columns.flatten
14
+ end
15
+
16
+ def options(*options)
17
+ @options = stringify_keys!(options.pop)
18
+ end
19
+
20
+ def to_js(&block)
21
+ js = "\nvar formatter = new google.visualization.#{self.class.to_s.split('::').last}("
22
+ js << js_parameters(@options)
23
+ js << ");"
24
+
25
+ yield js if block_given?
26
+
27
+ @columns.each do |column|
28
+ js << "\nformatter.format(data_table, #{column});"
29
+ end
30
+
31
+ js
32
+ end
33
+
34
+ end
35
+
36
+ class ArrowFormat < Formatter
37
+ end
38
+
39
+ class BarFormat < Formatter
40
+ end
41
+
42
+ class ColorFormat < Formatter
43
+
44
+ attr_accessor :ranges
45
+ attr_accessor :gradient_ranges
46
+
47
+ def initialize
48
+ @ranges = Array.new
49
+ @gradient_ranges = Array.new
50
+ end
51
+
52
+ def add_range(from, to, color, bgcolor)
53
+ @ranges << { :from => from, :to => to, :color => color, :bgcolor => bgcolor }
54
+ end
55
+
56
+ def add_gradient_range(from, to, color, fromBgColor, toBgColor)
57
+ @gradient_ranges << { :from => from, :to => to, :color => color, :fromBgColor => fromBgColor, :toBgColor => toBgColor }
58
+ end
59
+
60
+ def to_js
61
+ super do |js|
62
+ @ranges.each do |r|
63
+ js << "\nformatter.addRange(#{typecast(r[:from])}, #{typecast(r[:to])}, #{typecast(r[:color])}, #{typecast(r[:bgcolor])});"
64
+ end
65
+ @gradient_ranges.each do |r|
66
+ js << "\nformatter.addGradientRange(#{typecast(r[:from])}, #{typecast(r[:to])}, #{typecast(r[:color])}, #{typecast(r[:fromBgColor])}, #{typecast(r[:toBgColor])});"
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ class DateFormat < Formatter
73
+ end
74
+
75
+ class NumberFormat < Formatter
76
+ end
77
+
78
+ end
@@ -0,0 +1,47 @@
1
+ module GoogleVisualr
2
+ module Image
3
+
4
+ # http://code.google.com/apis/chart/interactive/docs/gallery/imagebarchart.html
5
+ class BarChart < BaseChart
6
+ include GoogleVisualr::Packages::ImageChart
7
+
8
+ # For Configuration Options, please refer to:
9
+ # http://code.google.com/apis/chart/interactive/docs/gallery/imagebarchart.html
10
+
11
+ # Create URI for image bar chart. Override parameters by passing in a hash.
12
+ # (see http://code.google.com/apis/chart/image/docs/chart_params.html)
13
+ #
14
+ # Parameters:
15
+ # *params [Optional] Hash of url query parameters
16
+ def uri(params = {})
17
+ query_params = {}
18
+
19
+ # isStacked/isVertical, Chart Type
20
+ chart_type = "b"
21
+ chart_type += @options["isVertical"] ? "v" : "h"
22
+ chart_type += @options["isStacked"] == false ? "g" : "s"
23
+ query_params[:cht] = chart_type
24
+
25
+ # showCategoryLabels (works as long as :chxt => "x,y")
26
+ labels = ""
27
+ val_column = @options["isVertical"] ? 1 : 0
28
+ cat_column = @options["isVertical"] ? 0 : 1
29
+ if @options["showCategoryLabels"] == false
30
+ labels = "#{cat_column}:||"
31
+ else
32
+ labels = "#{cat_column}:|" + data_table.get_column(0).join('|') + "|"
33
+ end
34
+
35
+ # showValueLabels (works as long as :chxt => "x,y")
36
+ if @options["showValueLabels"] == false
37
+ labels += "#{val_column}:||"
38
+ end
39
+
40
+ query_params[:chxl] = labels unless labels.blank?
41
+
42
+ chart_image_url(query_params.merge(params))
43
+ end
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ module GoogleVisualr
2
+ module Image
3
+
4
+ # http://code.google.com/apis/chart/interactive/docs/gallery/imagelinechart.html
5
+ class LineChart < BaseChart
6
+ include GoogleVisualr::Packages::ImageChart
7
+
8
+ # For Configuration Options, please refer to:
9
+ # http://code.google.com/apis/chart/interactive/docs/gallery/imagelinechart.html
10
+
11
+ # Create URI for image line chart. Override parameters by passing in a hash.
12
+ # (see http://code.google.com/apis/chart/image/docs/chart_params.html)
13
+ #
14
+ # Parameters:
15
+ # *params [Optional] Hash of url query parameters
16
+ def uri(params = {})
17
+ query_params = {}
18
+
19
+ # Chart type: line
20
+ query_params[:cht] = "lc"
21
+
22
+ # showAxisLines
23
+ if @options["showAxisLines"] == false
24
+ query_params[:cht] = "lc:nda"
25
+ end
26
+
27
+ # showCategoryLabels (works as long as :chxt => "x,y")
28
+ labels = ""
29
+ if @options["showCategoryLabels"] == false
30
+ labels = "0:||"
31
+ else
32
+ labels = "0:|" + data_table.get_column(0).join('|') + "|"
33
+ end
34
+
35
+ # showValueLabels (works as long as :chxt => "x,y")
36
+ if @options["showValueLabels"] == false
37
+ labels += "1:||"
38
+ end
39
+
40
+ query_params[:chxl] = labels unless labels.blank?
41
+
42
+ chart_image_url(query_params.merge(params))
43
+ end
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ module GoogleVisualr
2
+ module Image
3
+
4
+ # http://code.google.com/apis/chart/interactive/docs/gallery/imagepiechart.html
5
+ class PieChart < BaseChart
6
+ include GoogleVisualr::Packages::ImageChart
7
+
8
+ # For Configuration Options, please refer to:
9
+ # http://code.google.com/apis/chart/interactive/docs/gallery/imagepiechart.html
10
+
11
+ # Create URI for image pie chart. Override parameters by passing in a hash.
12
+ # (see http://code.google.com/apis/chart/image/docs/chart_params.html)
13
+ #
14
+ # Parameters:
15
+ # *params [Optional] Hash of url query parameters
16
+ def uri(params = {})
17
+ query_params = {}
18
+
19
+ # Chart Type: normal or 3D
20
+ query_params[:cht] = @options["is3D"] ? "p3" : "p"
21
+
22
+ # Legend (override generic image chart behavior)
23
+ query_params[:chdl] = @data_table.get_column(0).join('|')
24
+
25
+ # Labels
26
+ case options["labels"]
27
+ when "name"
28
+ query_params[:chl] = @data_table.get_column(0).join('|')
29
+ when "value"
30
+ query_params[:chl] = @data_table.get_column(1).join('|')
31
+ else
32
+ query_params[:chl] = ""
33
+ end
34
+
35
+ # data (override generic chart behavior)
36
+ query_params[:chd] = "t:" + @data_table.get_column(1).join(',')
37
+
38
+ # Chart Colors (override generic chart default)
39
+ query_params[:chco] = @options["colors"].join('|').gsub(/#/, '') if @options["colors"]
40
+
41
+ chart_image_url(query_params.merge(params))
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,34 @@
1
+ module GoogleVisualr
2
+ module Image
3
+
4
+ # http://code.google.com/apis/chart/interactive/docs/gallery/imagesparkline.html
5
+ class SparkLine < BaseChart
6
+ include GoogleVisualr::Packages::ImageChart
7
+
8
+ # For Configuration Options, please refer to:
9
+ # http://code.google.com/apis/chart/interactive/docs/gallery/imagesparkline.html
10
+
11
+ # Create URI for sparkline. Override parameters by passing in a hash.
12
+ # (see http://code.google.com/apis/chart/image/docs/chart_params.html)
13
+ #
14
+ # Parameters:
15
+ # *params [Optional] Hash of url query parameters
16
+ def uri(params = {})
17
+ query_params = {}
18
+
19
+ # Chart type: line
20
+ query_params[:cht] = "ls"
21
+
22
+ # showValueLabels (works as long as :chxt => "x,y")
23
+ labels = "0:||"
24
+ if @options["showValueLabels"] == false || !@options["showAxisLines"]
25
+ labels += "1:||"
26
+ end
27
+
28
+ query_params[:chxl] = labels
29
+
30
+ chart_image_url(query_params.merge(params))
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ module GoogleVisualr
2
+ module Interactive
3
+
4
+ # http://code.google.com/apis/chart/interactive/docs/gallery/annotatedtimeline.html
5
+ class AnnotatedTimeLine < BaseChart
6
+ # For Configuration Options, please refer to:
7
+ # http://code.google.com/apis/chart/interactive/docs/gallery/annotatedtimeline.html#Configuration_Options
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module GoogleVisualr
2
+ module Interactive
3
+
4
+ # https://developers.google.com/chart/interactive/docs/gallery/annotationchart
5
+ class AnnotationChart < BaseChart
6
+ # For Configuration Options, please refer to:
7
+ # https://developers.google.com/chart/interactive/docs/gallery/annotationchart#configuration-options
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module GoogleVisualr
2
+ module Interactive
3
+
4
+ # http://code.google.com/apis/chart/interactive/docs/gallery/areachart.html
5
+ class AreaChart < BaseChart
6
+ include GoogleVisualr::Packages::CoreChart
7
+
8
+ # For Configuration Options, please refer to:
9
+ # http://code.google.com/apis/chart/interactive/docs/gallery/areachart.html#Configuration_Options
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ module GoogleVisualr
2
+ module Interactive
3
+
4
+ # http://code.google.com/apis/chart/interactive/docs/gallery/barchart.html
5
+ class BarChart < BaseChart
6
+ include GoogleVisualr::Packages::CoreChart
7
+
8
+ def package_name
9
+ if material
10
+ "bar"
11
+ else
12
+ super
13
+ end
14
+ end
15
+
16
+ def chart_name
17
+ if material
18
+ "Bar"
19
+ else
20
+ super
21
+ end
22
+ end
23
+
24
+ # For Configuration Options, please refer to:
25
+ # http://code.google.com/apis/chart/interactive/docs/gallery/barchart.html#Configuration_Options
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ module GoogleVisualr
2
+ module Interactive
3
+
4
+ # https://developers.google.com/chart/interactive/docs/gallery/bubblechart
5
+ class BubbleChart < BaseChart
6
+ include GoogleVisualr::Packages::CoreChart
7
+
8
+ # For Configuration Options, please refer to:
9
+ # https://developers.google.com/chart/interactive/docs/gallery/bubblechart#Configuration_Options
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module GoogleVisualr
2
+ module Interactive
3
+
4
+ # https://developers.google.com/chart/interactive/docs/gallery/calendar
5
+ class Calendar < BaseChart
6
+ # For Configuration Options, please refer to:
7
+ # https://developers.google.com/chart/interactive/docs/gallery/calendar#configuration-options
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module GoogleVisualr
2
+ module Interactive
3
+
4
+ # http://code.google.com/apis/chart/interactive/docs/gallery/candlestickchart.html
5
+ class CandlestickChart < BaseChart
6
+ include GoogleVisualr::Packages::CoreChart
7
+
8
+ # For Configuration Options, please refer to:
9
+ # http://code.google.com/apis/chart/interactive/docs/gallery/candlestickchart.html#Configuration_Options
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ module GoogleVisualr
2
+ module Interactive
3
+
4
+ # http://code.google.com/apis/chart/interactive/docs/gallery/columnchart.html
5
+ class ColumnChart < BaseChart
6
+ include GoogleVisualr::Packages::CoreChart
7
+
8
+ def package_name
9
+ if material
10
+ "bar"
11
+ else
12
+ super
13
+ end
14
+ end
15
+
16
+ def chart_name
17
+ if material
18
+ "Bar"
19
+ else
20
+ super
21
+ end
22
+ end
23
+
24
+ # For Configuration Options, please refer to:
25
+ # http://code.google.com/apis/chart/interactive/docs/gallery/columnchart.html#Configuration_Options
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ module GoogleVisualr
2
+ module Interactive
3
+
4
+ # http://code.google.com/apis/chart/interactive/docs/gallery/combochart.html
5
+ class ComboChart < BaseChart
6
+ include GoogleVisualr::Packages::CoreChart
7
+
8
+ # For Configuration Options, please refer to:
9
+ # http://code.google.com/apis/chart/interactive/docs/gallery/combochart.html#Configuration_Options
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ module GoogleVisualr
2
+ module Interactive
3
+
4
+ # https://developers.google.com/chart/interactive/docs/gallery/ganttchart
5
+ class GanttChart < BaseChart
6
+
7
+ def package_name
8
+ "gantt"
9
+ end
10
+
11
+ # For Configuration Options, please refer to:
12
+ # https://developers.google.com/chart/interactive/docs/gallery/ganttchart#configuration-options
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ module GoogleVisualr
2
+ module Interactive
3
+
4
+ # http://code.google.com/apis/chart/interactive/docs/gallery/gauge.html
5
+ class Gauge < BaseChart
6
+ # For Configuration Options, please refer to:
7
+ # http://code.google.com/apis/chart/interactive/docs/gallery/gauge.html#Configuration_Options
8
+ end
9
+
10
+ end
11
+ end