google_visualr 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +159 -0
- data/Rakefile +3 -6
- data/lib/google_visualr.rb +11 -9
- data/lib/google_visualr/base_chart.rb +31 -7
- data/lib/google_visualr/interactive/annotation_chart.rb +11 -0
- data/lib/google_visualr/interactive/bar_chart.rb +16 -0
- data/lib/google_visualr/interactive/calendar.rb +11 -0
- data/lib/google_visualr/interactive/column_chart.rb +16 -0
- data/lib/google_visualr/interactive/gantt_chart.rb +16 -0
- data/lib/google_visualr/interactive/line_chart.rb +8 -0
- data/lib/google_visualr/interactive/sankey.rb +11 -0
- data/lib/google_visualr/interactive/scatter_chart.rb +8 -0
- data/lib/google_visualr/interactive/word_tree.rb +11 -0
- data/lib/google_visualr/packages.rb +0 -11
- data/lib/google_visualr/version.rb +1 -1
- data/spec/dummy/config/environments/development.rb +15 -11
- data/spec/dummy/config/environments/production.rb +61 -26
- data/spec/dummy/config/environments/test.rb +22 -16
- data/spec/google_visualr/base_chart_spec.rb +62 -1
- data/spec/google_visualr/data_table_spec.rb +3 -1
- data/spec/spec_helper.rb +12 -0
- data/spec/support/common.rb +17 -8
- metadata +9 -46
- data/README.markdown +0 -157
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 762cd55fa47b092ed0ce4efbe9dfa17d37e787f8
|
4
|
+
data.tar.gz: 92c5ef41f18dcb711fa9b9a4a42d539a57a9adb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39bc89ba661c876461e9245758f7b06308df4967841f02146086294299a2524f28c4e94e7adcd8fe0fe36fe0ecaae9a6a4a2a1164162d6893cd5976a0e66e2a7
|
7
|
+
data.tar.gz: f01987a2e6f447dfebf6bd4347f4a6bcc8b51a3f40a43558bc9cd3984c43e8b46b903e9f7f4375388e8da2e0d2e1b7f909e24c73bce7aa54544fa1c3b63ce6c1
|
data/README.md
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# GoogleVisualr
|
2
|
+
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/google_visualr.svg?style=flat-square)](https://rubygems.org/gems/google_visualr)
|
4
|
+
[![Build Status](http://img.shields.io/travis/winston/google_visualr.svg?style=flat-square)](https://travis-ci.org/winston/google_visualr)
|
5
|
+
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](https://github.com/winston/google_visualr/blob/master/MIT-LICENSE)
|
6
|
+
|
7
|
+
GoogleVisualr, is a wrapper around the [Google Charts](https://developers.google.com/chart/) that allows anyone to create beautiful charts with just plain Ruby. You don't have to write any JavaScript at all.
|
8
|
+
|
9
|
+
It's good for any Ruby (Rails/Sinatra) setup, and you can handle the entire charting logic in Ruby.
|
10
|
+
|
11
|
+
Please refer to the [GoogleVisualr API Reference site](http://googlevisualr.heroku.com/) for a complete list of Google charts that you can create with GoogleVisualr.
|
12
|
+
|
13
|
+
## tl:dr
|
14
|
+
|
15
|
+
* In your model or controller, write Ruby code to create your chart (e.g. Area Chart, Bar Chart etc).
|
16
|
+
* Configure your chart with any of the options as listed in Google's API Docs. E.g. [Area Chart](http://code.google.com/apis/chart/interactive/docs/gallery/areachart.html#Configuration_Options).
|
17
|
+
* In your view, call `chart.to_js(div_id)` and that renders JavaScript into the HTML output.
|
18
|
+
* You get your awesome Google chart, and you didn't write any JavaScript!
|
19
|
+
|
20
|
+
## Limitations
|
21
|
+
|
22
|
+
GoogleVisualr is not a 100% complete wrapper for Google Chart Tools.
|
23
|
+
|
24
|
+
`Methods` and `Events` as described in Google's API Docs - for use after a chart has been rendered,
|
25
|
+
are not implemented because they feel more natural being written as JavaScript functions, within the views or .js files.
|
26
|
+
|
27
|
+
## Install
|
28
|
+
|
29
|
+
Assuming you are on Rails 3/4, include the gem in your Gemfile.
|
30
|
+
|
31
|
+
gem "google_visualr", ">= 2.5"
|
32
|
+
|
33
|
+
## Basics
|
34
|
+
|
35
|
+
This is a basic implementation of `GoogleVisualr::DataTable` and `GoogleVisualr::AreaChart`.
|
36
|
+
|
37
|
+
For detailed documentation, please refer to the [GoogleVisualr API Reference](http://googlevisualr.heroku.com/) or [read the source](https://github.com/winston/google_visualr_app).
|
38
|
+
|
39
|
+
---
|
40
|
+
|
41
|
+
In your Rails layout, load Google Ajax API in the head tag, at the very top.
|
42
|
+
|
43
|
+
<script src='https://www.google.com/jsapi'></script>
|
44
|
+
|
45
|
+
In your Rails controller, initialize a GoogleVisualr::DataTable object with an empty constructor.
|
46
|
+
|
47
|
+
data_table = GoogleVisualr::DataTable.new
|
48
|
+
|
49
|
+
Populate data_table with column headers, and row values.
|
50
|
+
|
51
|
+
# Add Column Headers
|
52
|
+
data_table.new_column('string', 'Year' )
|
53
|
+
data_table.new_column('number', 'Sales')
|
54
|
+
data_table.new_column('number', 'Expenses')
|
55
|
+
|
56
|
+
# Add Rows and Values
|
57
|
+
data_table.add_rows([
|
58
|
+
['2004', 1000, 400],
|
59
|
+
['2005', 1170, 460],
|
60
|
+
['2006', 660, 1120],
|
61
|
+
['2007', 1030, 540]
|
62
|
+
])
|
63
|
+
|
64
|
+
Create a GoogleVisualr::AreaChart with data_table and configuration options.
|
65
|
+
|
66
|
+
option = { width: 400, height: 240, title: 'Company Performance' }
|
67
|
+
@chart = GoogleVisualr::Interactive::AreaChart.new(data_table, option)
|
68
|
+
|
69
|
+
In your Rails view, render the Google chart.
|
70
|
+
|
71
|
+
<div id='chart'></div>
|
72
|
+
<%= render_chart(@chart, 'chart') %>
|
73
|
+
|
74
|
+
## Chart Initializer
|
75
|
+
|
76
|
+
The initializer of `GoogleVisualr::<ChartName>` takes in two parameters: `data_table` and `options`.
|
77
|
+
|
78
|
+
### `data_table`
|
79
|
+
|
80
|
+
`data_table` is an instance of `GoogleVisualr::DataTable` and contains headers and rows of data.
|
81
|
+
|
82
|
+
### `options`
|
83
|
+
|
84
|
+
`options` is a hash of configuration options for the Google chart (e.g. width, height, colors etc).
|
85
|
+
|
86
|
+
The available configuration options are exactly the same as those specified in Google's API Docs.
|
87
|
+
|
88
|
+
For example:
|
89
|
+
- [Configuration options for AreaChart](https://developers.google.com/chart/interactive/docs/gallery/areachart#configuration-options)
|
90
|
+
- [Configuration options for BarChart](https://developers.google.com/chart/interactive/docs/gallery/barchart#configuration-options)
|
91
|
+
|
92
|
+
At the same time, you can also specify `version`, `language` and `material` as configuration options.
|
93
|
+
|
94
|
+
#### `version`
|
95
|
+
|
96
|
+
The default version of Google Charts library loaded is `1.0`.
|
97
|
+
|
98
|
+
However, some charts (e.g. Gantt Charts) require the latest version of the Google Charts library,
|
99
|
+
so you will have to specify `version` as `1.1` in the configuration options
|
100
|
+
|
101
|
+
```
|
102
|
+
....
|
103
|
+
@chart = GoogleVisualr::GanttChart.new(data_table, { version: '1.1' })
|
104
|
+
```
|
105
|
+
|
106
|
+
[Read more about it on Google's API Docs](https://developers.google.com/chart/interactive/docs/basic_load_libs).
|
107
|
+
|
108
|
+
#### `language`
|
109
|
+
|
110
|
+
The default locale of all Google Charts is `en`.
|
111
|
+
|
112
|
+
You can override this default by specifying `language` in the configuration options.
|
113
|
+
|
114
|
+
```
|
115
|
+
....
|
116
|
+
@chart = GoogleVisualr::BarChart.new(data_table, { language: 'ja' })
|
117
|
+
```
|
118
|
+
|
119
|
+
[Read more about it on Google's API Docs](https://developers.google.com/chart/interactive/docs/library_loading_enhancements#loadwithlocale).
|
120
|
+
|
121
|
+
#### `material`
|
122
|
+
|
123
|
+
Google has also enabled `Material` design for some charts:
|
124
|
+
|
125
|
+
> In 2014, Google announced guidelines intended to support a common look and feel across its properties and apps (such as Android apps) that run on Google platforms. We call this effort Material Design. We'll be providing "Material" versions of all our core charts; you're welcome to use them if you like how they look.
|
126
|
+
|
127
|
+
To use material design, you will have to specify `material` as `true`
|
128
|
+
in the configuration options.
|
129
|
+
|
130
|
+
```
|
131
|
+
....
|
132
|
+
@chart = GoogleVisualr::BarChart.new(data_table, { material: true })
|
133
|
+
```
|
134
|
+
|
135
|
+
## Listeners
|
136
|
+
|
137
|
+
For an example usage of `listeners`, please refer to [this comment](https://github.com/winston/google_visualr/issues/36#issuecomment-9880256).
|
138
|
+
|
139
|
+
Besides `listeners` you can now also redraw charts in your JavaScript maunally by calling `draw_<element id>()` function. See [this commit](https://github.com/winston/google_visualr/commit/e5554886bd83f56dd31bbc543fdcf1e24523776a) for more details.
|
140
|
+
|
141
|
+
## Support
|
142
|
+
|
143
|
+
Please submit all feedback, bugs and feature-requests to [GitHub Issues Tracker](http://github.com/winston/google_visualr/issues).
|
144
|
+
|
145
|
+
Feel free to fork the project, make improvements or bug fixes and submit pull requests (with tests!).
|
146
|
+
|
147
|
+
## Who's Using GoogleVisualr?
|
148
|
+
|
149
|
+
I would like to collect some data about who's using this Gem. [Please drop me a line](mailto:winstonyw+googlevisualr@gmail.com).
|
150
|
+
|
151
|
+
## Author
|
152
|
+
|
153
|
+
GoogleVisualr is maintained by [Winston Teo](mailto:winstonyw+googlevisualr@gmail.com).
|
154
|
+
|
155
|
+
Who is Winston Teo? [You should follow Winston on Twitter](http://www.twitter.com/winstonyw), or find out more on [WinstonYW](http://www.winstonyw.com).
|
156
|
+
|
157
|
+
## License
|
158
|
+
|
159
|
+
Copyright © 2015 Winston Teo Yong Wei. Free software, released under the MIT license.
|
data/Rakefile
CHANGED
@@ -2,11 +2,8 @@
|
|
2
2
|
require 'bundler'
|
3
3
|
Bundler::GemHelper.install_tasks
|
4
4
|
|
5
|
-
# RSpec Tasks
|
6
5
|
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
task :default => :spec
|
8
|
+
task test: :spec
|
9
|
+
task default: :spec
|
data/lib/google_visualr.rb
CHANGED
@@ -14,31 +14,33 @@ require "#{lib_path}/google_visualr/formatters"
|
|
14
14
|
# Interactive Charts
|
15
15
|
|
16
16
|
## Main
|
17
|
+
require "#{lib_path}/google_visualr/interactive/annotated_time_line"
|
18
|
+
require "#{lib_path}/google_visualr/interactive/annotation_chart"
|
17
19
|
require "#{lib_path}/google_visualr/interactive/area_chart"
|
18
20
|
require "#{lib_path}/google_visualr/interactive/bar_chart"
|
19
21
|
require "#{lib_path}/google_visualr/interactive/bubble_chart"
|
22
|
+
require "#{lib_path}/google_visualr/interactive/calendar"
|
20
23
|
require "#{lib_path}/google_visualr/interactive/candlestick_chart"
|
21
24
|
require "#{lib_path}/google_visualr/interactive/column_chart"
|
22
25
|
require "#{lib_path}/google_visualr/interactive/combo_chart"
|
26
|
+
require "#{lib_path}/google_visualr/interactive/gantt_chart"
|
23
27
|
require "#{lib_path}/google_visualr/interactive/gauge"
|
24
28
|
require "#{lib_path}/google_visualr/interactive/geo_chart"
|
25
29
|
require "#{lib_path}/google_visualr/interactive/geo_map"
|
26
30
|
require "#{lib_path}/google_visualr/interactive/histogram"
|
31
|
+
require "#{lib_path}/google_visualr/interactive/intensity_map"
|
27
32
|
require "#{lib_path}/google_visualr/interactive/line_chart"
|
33
|
+
require "#{lib_path}/google_visualr/interactive/map"
|
34
|
+
require "#{lib_path}/google_visualr/interactive/motion_chart"
|
35
|
+
require "#{lib_path}/google_visualr/interactive/org_chart"
|
28
36
|
require "#{lib_path}/google_visualr/interactive/pie_chart"
|
37
|
+
require "#{lib_path}/google_visualr/interactive/sankey"
|
29
38
|
require "#{lib_path}/google_visualr/interactive/scatter_chart"
|
30
39
|
require "#{lib_path}/google_visualr/interactive/stepped_area_chart"
|
31
40
|
require "#{lib_path}/google_visualr/interactive/table"
|
32
|
-
require "#{lib_path}/google_visualr/interactive/tree_map"
|
33
|
-
|
34
|
-
|
35
|
-
## Additional
|
36
|
-
require "#{lib_path}/google_visualr/interactive/annotated_time_line"
|
37
|
-
require "#{lib_path}/google_visualr/interactive/intensity_map"
|
38
|
-
require "#{lib_path}/google_visualr/interactive/map"
|
39
|
-
require "#{lib_path}/google_visualr/interactive/motion_chart"
|
40
|
-
require "#{lib_path}/google_visualr/interactive/org_chart"
|
41
41
|
require "#{lib_path}/google_visualr/interactive/timeline"
|
42
|
+
require "#{lib_path}/google_visualr/interactive/tree_map"
|
43
|
+
require "#{lib_path}/google_visualr/interactive/word_tree"
|
42
44
|
|
43
45
|
# Image Charts
|
44
46
|
require "#{lib_path}/google_visualr/image/spark_line"
|
@@ -1,19 +1,43 @@
|
|
1
1
|
module GoogleVisualr
|
2
2
|
|
3
3
|
class BaseChart
|
4
|
-
include GoogleVisualr::Packages
|
5
4
|
include GoogleVisualr::ParamHelpers
|
6
5
|
|
7
|
-
|
6
|
+
DEFAULT_VERSION = "1.0".freeze
|
7
|
+
|
8
|
+
attr_accessor :data_table, :listeners, :version, :language, :material
|
8
9
|
|
9
10
|
def initialize(data_table, options={})
|
10
|
-
@data_table
|
11
|
+
@data_table = data_table
|
12
|
+
@listeners = []
|
13
|
+
@version = options.delete(:version) || DEFAULT_VERSION
|
14
|
+
@language = options.delete(:language) || "en"
|
15
|
+
@material = options.delete(:material) || false
|
11
16
|
send(:options=, options)
|
12
|
-
|
17
|
+
end
|
18
|
+
|
19
|
+
def package_name
|
20
|
+
self.class.to_s.split("::").last.downcase
|
21
|
+
end
|
22
|
+
|
23
|
+
def class_name
|
24
|
+
self.class.to_s.split("::").last
|
25
|
+
end
|
26
|
+
|
27
|
+
def chart_class
|
28
|
+
if material
|
29
|
+
"charts"
|
30
|
+
else
|
31
|
+
"visualization"
|
32
|
+
end
|
13
33
|
end
|
14
34
|
|
15
35
|
def chart_name
|
16
|
-
|
36
|
+
if material
|
37
|
+
class_name.gsub!("Chart", "")
|
38
|
+
else
|
39
|
+
class_name
|
40
|
+
end
|
17
41
|
end
|
18
42
|
|
19
43
|
def chart_function_name(element_id)
|
@@ -50,7 +74,7 @@ module GoogleVisualr
|
|
50
74
|
# Parameters:
|
51
75
|
# *div_id [Required] The ID of the DIV element that the Google Chart should be rendered in.
|
52
76
|
def load_js(element_id)
|
53
|
-
"\n google.load('visualization','
|
77
|
+
"\n google.load('visualization', '#{version}', {packages: ['#{package_name}'], language: '#{language}', callback: #{chart_function_name(element_id)}});"
|
54
78
|
end
|
55
79
|
|
56
80
|
# Generates JavaScript function for rendering the chart.
|
@@ -61,7 +85,7 @@ module GoogleVisualr
|
|
61
85
|
js = ""
|
62
86
|
js << "\n function #{chart_function_name(element_id)}() {"
|
63
87
|
js << "\n #{@data_table.to_js}"
|
64
|
-
js << "\n var chart = new google
|
88
|
+
js << "\n var chart = new google.#{chart_class}.#{chart_name}(document.getElementById('#{element_id}'));"
|
65
89
|
@listeners.each do |listener|
|
66
90
|
js << "\n google.visualization.events.addListener(chart, '#{listener[:event]}', #{listener[:callback]});"
|
67
91
|
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
|
@@ -5,6 +5,22 @@ module GoogleVisualr
|
|
5
5
|
class BarChart < BaseChart
|
6
6
|
include GoogleVisualr::Packages::CoreChart
|
7
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
|
+
|
8
24
|
# For Configuration Options, please refer to:
|
9
25
|
# http://code.google.com/apis/chart/interactive/docs/gallery/barchart.html#Configuration_Options
|
10
26
|
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
|
@@ -5,6 +5,22 @@ module GoogleVisualr
|
|
5
5
|
class ColumnChart < BaseChart
|
6
6
|
include GoogleVisualr::Packages::CoreChart
|
7
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
|
+
|
8
24
|
# For Configuration Options, please refer to:
|
9
25
|
# http://code.google.com/apis/chart/interactive/docs/gallery/columnchart.html#Configuration_Options
|
10
26
|
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
|
@@ -5,6 +5,14 @@ module GoogleVisualr
|
|
5
5
|
class LineChart < BaseChart
|
6
6
|
include GoogleVisualr::Packages::CoreChart
|
7
7
|
|
8
|
+
def package_name
|
9
|
+
if material
|
10
|
+
"line"
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
8
16
|
# For Configuration Options, please refer to:
|
9
17
|
# http://code.google.com/apis/chart/interactive/docs/gallery/linechart.html#Configuration_Options
|
10
18
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module GoogleVisualr
|
2
|
+
module Interactive
|
3
|
+
|
4
|
+
# https://developers.google.com/chart/interactive/docs/gallery/sankey
|
5
|
+
class Sankey < BaseChart
|
6
|
+
# For Configuration Options, please refer to:
|
7
|
+
# https://developers.google.com/chart/interactive/docs/gallery/sankey#configuration-options
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
@@ -5,6 +5,14 @@ module GoogleVisualr
|
|
5
5
|
class ScatterChart < BaseChart
|
6
6
|
include GoogleVisualr::Packages::CoreChart
|
7
7
|
|
8
|
+
def package_name
|
9
|
+
if material
|
10
|
+
"scatter"
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
8
16
|
# For Configuration Options, please refer to:
|
9
17
|
# http://code.google.com/apis/chart/interactive/docs/gallery/scatterchart.html#Configuration_Options
|
10
18
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module GoogleVisualr
|
2
|
+
module Interactive
|
3
|
+
|
4
|
+
# https://developers.google.com/chart/interactive/docs/gallery/wordtree
|
5
|
+
class WordTree < BaseChart
|
6
|
+
# For Configuration Options, please refer to:
|
7
|
+
# https://developers.google.com/chart/interactive/docs/gallery/wordtree#a-simple-example
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
@@ -1,15 +1,5 @@
|
|
1
1
|
module GoogleVisualr
|
2
|
-
|
3
2
|
module Packages
|
4
|
-
|
5
|
-
def package_name
|
6
|
-
self.class.to_s.split("::").last.downcase
|
7
|
-
end
|
8
|
-
|
9
|
-
def class_name
|
10
|
-
self.class.to_s.split('::').last
|
11
|
-
end
|
12
|
-
|
13
3
|
module CoreChart
|
14
4
|
def package_name
|
15
5
|
"corechart"
|
@@ -105,5 +95,4 @@ module GoogleVisualr
|
|
105
95
|
end
|
106
96
|
end
|
107
97
|
end
|
108
|
-
|
109
98
|
end
|
@@ -1,26 +1,30 @@
|
|
1
1
|
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# In the development environment your application's code is reloaded on
|
5
|
-
# every request.
|
6
|
-
# since you don't have to restart the
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
8
|
|
9
|
-
#
|
10
|
-
config.
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
11
|
|
12
|
-
# Show full error reports and disable caching
|
12
|
+
# Show full error reports and disable caching.
|
13
13
|
config.consider_all_requests_local = true
|
14
|
-
config.action_view.debug_rjs = true
|
15
14
|
config.action_controller.perform_caching = false
|
16
15
|
|
17
|
-
# Don't care if the mailer can't send
|
16
|
+
# Don't care if the mailer can't send.
|
18
17
|
config.action_mailer.raise_delivery_errors = false
|
19
18
|
|
20
|
-
# Print deprecation notices to the Rails logger
|
19
|
+
# Print deprecation notices to the Rails logger.
|
21
20
|
config.active_support.deprecation = :log
|
22
21
|
|
23
|
-
# Only use best-standards-support built into browsers
|
22
|
+
# Only use best-standards-support built into browsers.
|
24
23
|
config.action_dispatch.best_standards_support = :builtin
|
25
|
-
end
|
26
24
|
|
25
|
+
# Raise an error on page load if there are pending migrations
|
26
|
+
config.active_record.migration_error = :page_load
|
27
|
+
|
28
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
29
|
+
config.assets.debug = true
|
30
|
+
end
|
@@ -1,49 +1,84 @@
|
|
1
1
|
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
|
-
#
|
5
|
-
# Code is not reloaded between requests
|
4
|
+
# Code is not reloaded between requests.
|
6
5
|
config.cache_classes = true
|
7
6
|
|
8
|
-
#
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both thread web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
9
14
|
config.consider_all_requests_local = false
|
10
15
|
config.action_controller.perform_caching = true
|
11
16
|
|
12
|
-
#
|
13
|
-
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
20
|
+
# config.action_dispatch.rack_cache = true
|
14
21
|
|
15
|
-
#
|
16
|
-
|
22
|
+
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
+
if Rails.version >= "4.2.0"
|
24
|
+
config.serve_static_files = false
|
25
|
+
else
|
26
|
+
config.serve_static_assets = false
|
27
|
+
end
|
17
28
|
|
18
|
-
#
|
19
|
-
|
29
|
+
# Compress JavaScripts and CSS.
|
30
|
+
config.assets.js_compressor = :uglifier
|
31
|
+
# config.assets.css_compressor = :sass
|
20
32
|
|
21
|
-
#
|
22
|
-
|
33
|
+
# Whether to fallback to assets pipeline if a precompiled asset is missed.
|
34
|
+
config.assets.compile = false
|
23
35
|
|
24
|
-
#
|
25
|
-
|
36
|
+
# Generate digests for assets URLs.
|
37
|
+
config.assets.digest = true
|
26
38
|
|
27
|
-
#
|
28
|
-
|
39
|
+
# Version of your assets, change this if you want to expire all your assets.
|
40
|
+
config.assets.version = '1.0'
|
41
|
+
|
42
|
+
# Specifies the header that your server uses for sending files.
|
43
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
44
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
45
|
+
|
46
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
47
|
+
# config.force_ssl = true
|
48
|
+
|
49
|
+
# Set to :debug to see everything in the log.
|
50
|
+
config.log_level = :info
|
51
|
+
|
52
|
+
# Prepend all log lines with the following tags.
|
53
|
+
# config.log_tags = [:subdomain, :uuid]
|
29
54
|
|
30
|
-
#
|
31
|
-
#
|
32
|
-
config.serve_static_assets = false
|
55
|
+
# Use a different logger for distributed setups.
|
56
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
33
57
|
|
34
|
-
#
|
58
|
+
# Use a different cache store in production.
|
59
|
+
# config.cache_store = :mem_cache_store
|
60
|
+
|
61
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
35
62
|
# config.action_controller.asset_host = "http://assets.example.com"
|
36
63
|
|
37
|
-
#
|
38
|
-
#
|
64
|
+
# Precompile additional assets.
|
65
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
66
|
+
# config.assets.precompile += %w( search.js )
|
39
67
|
|
40
|
-
#
|
41
|
-
#
|
68
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
69
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
70
|
+
# config.action_mailer.raise_delivery_errors = false
|
42
71
|
|
43
72
|
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
-
# the I18n.default_locale when a translation can not be found)
|
73
|
+
# the I18n.default_locale when a translation can not be found).
|
45
74
|
config.i18n.fallbacks = true
|
46
75
|
|
47
|
-
# Send deprecation notices to registered listeners
|
76
|
+
# Send deprecation notices to registered listeners.
|
48
77
|
config.active_support.deprecation = :notify
|
78
|
+
|
79
|
+
# Disable automatic flushing of the log to improve performance.
|
80
|
+
# config.autoflush_log = false
|
81
|
+
|
82
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
83
|
+
config.log_formatter = ::Logger::Formatter.new
|
49
84
|
end
|
@@ -1,35 +1,41 @@
|
|
1
1
|
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# The test environment is used exclusively to run your application's
|
5
|
-
# test suite.
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
6
|
# your test database is "scratch space" for the test suite and is wiped
|
7
|
-
# and recreated between test runs.
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
14
|
+
|
15
|
+
# Disable serving static files from the `/public` folder by default since
|
16
|
+
# Apache or NGINX already handles this.
|
17
|
+
if Rails.version >= "4.2.0"
|
18
|
+
config.serve_static_files = true
|
19
|
+
else
|
20
|
+
config.serve_static_assets = true
|
21
|
+
end
|
22
|
+
config.static_cache_control = "public, max-age=3600"
|
23
|
+
|
24
|
+
# Show full error reports and disable caching.
|
14
25
|
config.consider_all_requests_local = true
|
15
26
|
config.action_controller.perform_caching = false
|
16
27
|
|
17
|
-
# Raise exceptions instead of rendering exception templates
|
28
|
+
# Raise exceptions instead of rendering exception templates.
|
18
29
|
config.action_dispatch.show_exceptions = false
|
19
30
|
|
20
|
-
# Disable request forgery protection in test environment
|
21
|
-
config.action_controller.allow_forgery_protection
|
31
|
+
# Disable request forgery protection in test environment.
|
32
|
+
config.action_controller.allow_forgery_protection = false
|
22
33
|
|
23
34
|
# Tell Action Mailer not to deliver emails to the real world.
|
24
35
|
# The :test delivery method accumulates sent emails in the
|
25
36
|
# ActionMailer::Base.deliveries array.
|
26
37
|
config.action_mailer.delivery_method = :test
|
27
38
|
|
28
|
-
#
|
29
|
-
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
-
# like if you have constraints or database-specific column types
|
31
|
-
# config.active_record.schema_format = :sql
|
32
|
-
|
33
|
-
# Print deprecation notices to the stderr
|
39
|
+
# Print deprecation notices to the stderr.
|
34
40
|
config.active_support.deprecation = :stderr
|
35
41
|
end
|
@@ -10,12 +10,59 @@ describe GoogleVisualr::BaseChart do
|
|
10
10
|
describe "#initialize" do
|
11
11
|
it "works" do
|
12
12
|
@chart.data_table.should == @dt
|
13
|
+
@chart.version.should == GoogleVisualr::BaseChart::DEFAULT_VERSION
|
14
|
+
@chart.material.should == false
|
13
15
|
@chart.options.should == { "legend" => "Test Chart", "width" => 800, "is3D" => true }
|
14
16
|
end
|
17
|
+
|
18
|
+
it "accepts version attribute" do
|
19
|
+
@chart = GoogleVisualr::BaseChart.new(@dt, version: "1.1")
|
20
|
+
@chart.version.should == "1.1"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "accepts language attribute" do
|
24
|
+
@chart = GoogleVisualr::BaseChart.new(@dt, language: "ja")
|
25
|
+
@chart.language.should == "ja"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "accepts material attribute" do
|
29
|
+
@chart = GoogleVisualr::BaseChart.new(@dt, material: true)
|
30
|
+
@chart.material.should == true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#package_name" do
|
35
|
+
it "returns class name (without module) and downcased" do
|
36
|
+
@chart.package_name.should == "basechart"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#class_name" do
|
41
|
+
it "returns class name (without module)" do
|
42
|
+
@chart.class_name.should == "BaseChart"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#chart_class" do
|
47
|
+
it "returns 'charts' when material is true" do
|
48
|
+
@chart.material = true
|
49
|
+
@chart.chart_class.should == "charts"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns 'charts' when material is false" do
|
53
|
+
@chart.material = false
|
54
|
+
@chart.chart_class.should == "visualization"
|
55
|
+
end
|
15
56
|
end
|
16
57
|
|
17
58
|
describe "#chart_name" do
|
18
|
-
it "returns class name (less module)" do
|
59
|
+
it "returns class name (less module) when material is true" do
|
60
|
+
@chart.material = true
|
61
|
+
@chart.chart_name.should == "Base"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns class name (less module) when material is false" do
|
65
|
+
@chart.material = false
|
19
66
|
@chart.chart_name.should == "BaseChart"
|
20
67
|
end
|
21
68
|
end
|
@@ -51,12 +98,26 @@ describe GoogleVisualr::BaseChart do
|
|
51
98
|
js.should include("<script")
|
52
99
|
end
|
53
100
|
|
101
|
+
it "generates JS of a different locale" do
|
102
|
+
@chart.language = "ja"
|
103
|
+
|
104
|
+
js = @chart.to_js("body")
|
105
|
+
js.should == base_chart_js("body", "ja")
|
106
|
+
end
|
107
|
+
|
54
108
|
it "generates JS with listeners" do
|
55
109
|
@chart.add_listener("select", "function() {test_event(chart);}")
|
56
110
|
|
57
111
|
js = @chart.to_js("body")
|
58
112
|
js.should == base_chart_with_listener_js("body")
|
59
113
|
end
|
114
|
+
|
115
|
+
it "generates JS for material charts" do
|
116
|
+
@chart.material = true
|
117
|
+
|
118
|
+
js = @chart.to_js("body")
|
119
|
+
js.should == material_chart("body")
|
120
|
+
end
|
60
121
|
end
|
61
122
|
|
62
123
|
end
|
@@ -321,7 +321,9 @@ describe GoogleVisualr::DataTable do
|
|
321
321
|
|
322
322
|
it "returns a valid json string when there are apostrophes in v or f" do
|
323
323
|
cell = GoogleVisualr::DataTable::Cell.new( { :v => "I'm \"Winston\"", :f => "Winston<div style='color:red; font-style:italic'>Nice Guy</div>" } )
|
324
|
-
|
324
|
+
expected = "{v: \"I'm \\\"Winston\\\"\", f: \"Winston<div style='color:red; font-style:italic'>Nice Guy</div>\"}"
|
325
|
+
|
326
|
+
expect(normalize_javascript(cell.to_js)).to eq expected
|
325
327
|
end
|
326
328
|
end
|
327
329
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,6 +8,18 @@ require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
|
8
8
|
# Load Support Files
|
9
9
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
10
10
|
|
11
|
+
module JavaScriptHelper
|
12
|
+
def normalize_javascript(input)
|
13
|
+
dupped = input.dup
|
14
|
+
|
15
|
+
dupped.gsub!(/\\u003E/i, ">")
|
16
|
+
dupped.gsub!(/\\u003C/i, "<")
|
17
|
+
|
18
|
+
dupped
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
11
22
|
RSpec.configure do |config|
|
12
23
|
# some (optional) config here
|
24
|
+
include JavaScriptHelper
|
13
25
|
end
|
data/spec/support/common.rb
CHANGED
@@ -13,28 +13,27 @@ def data_table
|
|
13
13
|
GoogleVisualr::DataTable.new(:cols => @cols, :rows => @rows)
|
14
14
|
end
|
15
15
|
|
16
|
-
def base_chart(data_table=data_table)
|
16
|
+
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
|
-
|
21
|
-
|
22
|
-
js = "\n google.load('visualization','1', {packages: ['basechart'], callback: draw_#{div_class}});"
|
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}});"
|
23
22
|
js << "\n function draw_#{div_class}() {"
|
24
23
|
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}'));"
|
25
24
|
js << "\n chart.draw(data_table, {legend: \"Test Chart\", width: 800, is3D: true});"
|
26
25
|
js << "\n };"
|
27
26
|
end
|
28
27
|
|
29
|
-
def base_chart_js(div_class="div_class")
|
28
|
+
def base_chart_js(div_class = "div_class", language = "en")
|
30
29
|
js = "\n<script type='text/javascript'>"
|
31
|
-
js << base_chart_js_without_script_tag(div_class)
|
30
|
+
js << base_chart_js_without_script_tag(div_class, language)
|
32
31
|
js << "\n</script>"
|
33
32
|
end
|
34
33
|
|
35
|
-
def base_chart_with_listener_js(div_class="div_class")
|
34
|
+
def base_chart_with_listener_js(div_class = "div_class")
|
36
35
|
js = "\n<script type='text/javascript'>"
|
37
|
-
js << "\n google.load('visualization','1', {packages: ['basechart'], callback: draw_#{div_class}});"
|
36
|
+
js << "\n google.load('visualization', '1.0', {packages: ['basechart'], language: 'en', callback: draw_#{div_class}});"
|
38
37
|
js << "\n function draw_#{div_class}() {"
|
39
38
|
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}'));"
|
40
39
|
js << "\n google.visualization.events.addListener(chart, 'select', function() {test_event(chart);});"
|
@@ -42,3 +41,13 @@ def base_chart_with_listener_js(div_class="div_class")
|
|
42
41
|
js << "\n };"
|
43
42
|
js << "\n</script>"
|
44
43
|
end
|
44
|
+
|
45
|
+
def material_chart(div_class = "div_class")
|
46
|
+
js = "\n<script type='text/javascript'>"
|
47
|
+
js << "\n google.load('visualization', '1.0', {packages: ['basechart'], language: 'en', callback: draw_#{div_class}});"
|
48
|
+
js << "\n function draw_#{div_class}() {"
|
49
|
+
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
|
+
js << "\n chart.draw(data_table, {legend: \"Test Chart\", width: 800, is3D: true});"
|
51
|
+
js << "\n };"
|
52
|
+
js << "\n</script>"
|
53
|
+
end
|
metadata
CHANGED
@@ -1,57 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_visualr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Winston Teo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.3.5
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.3.5
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 2.14.1
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 2.14.1
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rails
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.2'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.2'
|
11
|
+
date: 2015-08-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
55
13
|
description: This Ruby gem, GoogleVisualr, is a wrapper around the Google Chart Tools
|
56
14
|
that allows anyone to create the same beautiful charts with just Ruby; you don't
|
57
15
|
have to write any JavaScript at all.
|
@@ -62,7 +20,7 @@ extensions: []
|
|
62
20
|
extra_rdoc_files: []
|
63
21
|
files:
|
64
22
|
- MIT-LICENSE
|
65
|
-
- README.
|
23
|
+
- README.md
|
66
24
|
- Rakefile
|
67
25
|
- lib/google_visualr.rb
|
68
26
|
- lib/google_visualr/app/helpers/view_helper.rb
|
@@ -75,12 +33,15 @@ files:
|
|
75
33
|
- lib/google_visualr/image/pie_chart.rb
|
76
34
|
- lib/google_visualr/image/spark_line.rb
|
77
35
|
- lib/google_visualr/interactive/annotated_time_line.rb
|
36
|
+
- lib/google_visualr/interactive/annotation_chart.rb
|
78
37
|
- lib/google_visualr/interactive/area_chart.rb
|
79
38
|
- lib/google_visualr/interactive/bar_chart.rb
|
80
39
|
- lib/google_visualr/interactive/bubble_chart.rb
|
40
|
+
- lib/google_visualr/interactive/calendar.rb
|
81
41
|
- lib/google_visualr/interactive/candlestick_chart.rb
|
82
42
|
- lib/google_visualr/interactive/column_chart.rb
|
83
43
|
- lib/google_visualr/interactive/combo_chart.rb
|
44
|
+
- lib/google_visualr/interactive/gantt_chart.rb
|
84
45
|
- lib/google_visualr/interactive/gauge.rb
|
85
46
|
- lib/google_visualr/interactive/geo_chart.rb
|
86
47
|
- lib/google_visualr/interactive/geo_map.rb
|
@@ -91,11 +52,13 @@ files:
|
|
91
52
|
- lib/google_visualr/interactive/motion_chart.rb
|
92
53
|
- lib/google_visualr/interactive/org_chart.rb
|
93
54
|
- lib/google_visualr/interactive/pie_chart.rb
|
55
|
+
- lib/google_visualr/interactive/sankey.rb
|
94
56
|
- lib/google_visualr/interactive/scatter_chart.rb
|
95
57
|
- lib/google_visualr/interactive/stepped_area_chart.rb
|
96
58
|
- lib/google_visualr/interactive/table.rb
|
97
59
|
- lib/google_visualr/interactive/timeline.rb
|
98
60
|
- lib/google_visualr/interactive/tree_map.rb
|
61
|
+
- lib/google_visualr/interactive/word_tree.rb
|
99
62
|
- lib/google_visualr/packages.rb
|
100
63
|
- lib/google_visualr/param_helpers.rb
|
101
64
|
- lib/google_visualr/version.rb
|
data/README.markdown
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
# GoogleVisualr
|
2
|
-
|
3
|
-
[<img src="https://secure.travis-ci.org/winston/google_visualr.png?branch=master" alt="Build Status" />](http://travis-ci.org/winston/google_visualr)
|
4
|
-
|
5
|
-
GoogleVisualr, is a wrapper around the [Google Chart Tools](http://code.google.com/apis/chart/interactive/docs/) that allows anyone to create beautiful charts with just plain Ruby. You don't have to write any JavaScript at all.
|
6
|
-
|
7
|
-
It's good for any Ruby (Rails/Sinatra) setup, and you can handle the entire charting logic in Ruby.
|
8
|
-
|
9
|
-
Please refer to the [GoogleVisualr API Reference site](http://googlevisualr.heroku.com/) for a complete list of Google charts that you can create with GoogleVisualr.
|
10
|
-
|
11
|
-
## tl:dr
|
12
|
-
|
13
|
-
* In your model or controller, write Ruby code to create your chart (e.g. Area Chart, Bar Chart etc).
|
14
|
-
* Configure your chart with any of the options as listed in Google's API Docs. E.g. [Area Chart](http://code.google.com/apis/chart/interactive/docs/gallery/areachart.html#Configuration_Options).
|
15
|
-
* In your view, call `chart.to_js(div_id)` and that will insert JavaScript into the final HTML output.
|
16
|
-
* You get your awesome Google chart, and you didn't write any JavaScript!
|
17
|
-
|
18
|
-
## Limitations
|
19
|
-
|
20
|
-
GoogleVisualr is created solely for the aim of simplifying the display of a chart, and not the interactions.
|
21
|
-
|
22
|
-
Hence, do note that GoogleVisualr is not a 100% complete wrapper for Google Chart Tools.
|
23
|
-
|
24
|
-
E.g., Methods and Events as described in Google's API Docs - for use after a chart has been rendered, are not implemented because they feel more natural being written as JavaScript functions, within the views or .js files.
|
25
|
-
|
26
|
-
## Install
|
27
|
-
|
28
|
-
Assuming you are on Rails 3, include the gem in your Gemfile.
|
29
|
-
|
30
|
-
gem "google_visualr", ">= 2.1"
|
31
|
-
|
32
|
-
## Basics
|
33
|
-
|
34
|
-
This is a basic implementation of the GoogleVisualr::DataTable and GoogleVisualr::AreaChart classes.
|
35
|
-
|
36
|
-
For detailed documentation and advanced implementations, please refer to the [GoogleVisualr API Reference](http://googlevisualr.heroku.com/) or read the source.
|
37
|
-
|
38
|
-
---
|
39
|
-
|
40
|
-
In your Rails layout, load Google Ajax API in the head tag, at the very top.
|
41
|
-
|
42
|
-
<script src='https://www.google.com/jsapi'></script>
|
43
|
-
|
44
|
-
In your Rails controller, initialize a GoogleVisualr::DataTable object with an empty constructor.
|
45
|
-
|
46
|
-
data_table = GoogleVisualr::DataTable.new
|
47
|
-
|
48
|
-
Populate data_table with column headers, and row values.
|
49
|
-
|
50
|
-
# Add Column Headers
|
51
|
-
data_table.new_column('string', 'Year' )
|
52
|
-
data_table.new_column('number', 'Sales')
|
53
|
-
data_table.new_column('number', 'Expenses')
|
54
|
-
|
55
|
-
# Add Rows and Values
|
56
|
-
data_table.add_rows([
|
57
|
-
['2004', 1000, 400],
|
58
|
-
['2005', 1170, 460],
|
59
|
-
['2006', 660, 1120],
|
60
|
-
['2007', 1030, 540]
|
61
|
-
])
|
62
|
-
|
63
|
-
Create a GoogleVisualr::AreaChart with data_table and configuration options.
|
64
|
-
|
65
|
-
option = { width: 400, height: 240, title: 'Company Performance' }
|
66
|
-
@chart = GoogleVisualr::Interactive::AreaChart.new(data_table, option)
|
67
|
-
|
68
|
-
In your Rails view, render the Google chart.
|
69
|
-
|
70
|
-
<div id='chart'></div>
|
71
|
-
<%= render_chart(@chart, 'chart') %>
|
72
|
-
|
73
|
-
## Listeners
|
74
|
-
|
75
|
-
For an example usage of `listeners`, please refer to [this comment](https://github.com/winston/google_visualr/issues/36#issuecomment-9880256).
|
76
|
-
|
77
|
-
Besides `listeners` you can now also redraw charts in your JavaScript maunally by calling `draw_<element id>()` function. See [this commit](https://github.com/winston/google_visualr/commit/e5554886bd83f56dd31bbc543fdcf1e24523776a) for more details.
|
78
|
-
|
79
|
-
## Support
|
80
|
-
|
81
|
-
Please submit all feedback, bugs and feature-requests to [GitHub Issues Tracker](http://github.com/winston/google_visualr/issues).
|
82
|
-
|
83
|
-
Feel free to fork the project, make improvements or bug fixes and submit pull requests (with tests!).
|
84
|
-
|
85
|
-
## Who's Using GoogleVisualr?
|
86
|
-
|
87
|
-
I would like to collect some data about who's using this Gem. [Please drop me a line](mailto:winstonyw+googlevisualr@gmail.com).
|
88
|
-
|
89
|
-
## Change Log
|
90
|
-
|
91
|
-
<em>Version 2.4.0</em>
|
92
|
-
|
93
|
-
* [Pull Request 75](https://github.com/winston/google_visualr/pull/75) Add Histogram chart.
|
94
|
-
|
95
|
-
<em>Version 2.3.0</em>
|
96
|
-
|
97
|
-
* [Issue 69](https://github.com/winston/google_visualr/pull/69) Support generating chart Javascript without `<script>` tag
|
98
|
-
* Split `base_chart#to_js` into 3 methods - `to_js`, `load_js` and `draw_js` which can be used on their own.
|
99
|
-
|
100
|
-
<em>Version 2.2.0</em>
|
101
|
-
|
102
|
-
* [Issue 64](https://github.com/winston/google_visualr/pull/64) Works with Turbolinks.
|
103
|
-
* [Issue 65](https://github.com/winston/google_visualr/pull/65) Add InteractiveTimeline chart.
|
104
|
-
|
105
|
-
<em>Version 2.1.9</em>
|
106
|
-
|
107
|
-
* [Issue 61](https://github.com/winston/google_visualr/issues/45) Add MIT license to gemspec.
|
108
|
-
|
109
|
-
<em>Version 2.1.8</em>
|
110
|
-
|
111
|
-
* [Issue 45](https://github.com/winston/google_visualr/issues/45) Support for redrawing chart from JS.
|
112
|
-
|
113
|
-
<em>Version 2.1.7</em>
|
114
|
-
|
115
|
-
* [Issue 56](https://github.com/winston/google_visualr/issues/56) Typecast to proper JSON strings.
|
116
|
-
|
117
|
-
<em>Version 2.1.6</em>
|
118
|
-
|
119
|
-
* [Issue 54](https://github.com/winston/google_visualr/issues/54) Allow apostrophes in labels.
|
120
|
-
* [Pull Request 55](https://github.com/winston/google_visualr/pull/55) Added support to accept BigDecimal as number.
|
121
|
-
|
122
|
-
<em>Version 2.1.5</em>
|
123
|
-
|
124
|
-
* [Pull Request 48](https://github.com/winston/google_visualr/pull/48) Fixed bug with Listener event registration.
|
125
|
-
|
126
|
-
<em>Version 2.1.4</em>
|
127
|
-
|
128
|
-
* [Pull Request 39](https://github.com/winston/google_visualr/pull/39) Added ability to use Listeners.
|
129
|
-
* [Pull Request 40](https://github.com/winston/google_visualr/pull/40) Allowed decoupling of class name and chart name.
|
130
|
-
|
131
|
-
<em>Version 2.1.3</em>
|
132
|
-
|
133
|
-
* Added support for Bubble Chart.
|
134
|
-
* [Pull Request 37](https://github.com/winston/google_visualr/pull/37) Added support for Stepped Area Chart.
|
135
|
-
|
136
|
-
<em>Version 2.1.2</em>
|
137
|
-
|
138
|
-
* [Pull Request 28](https://github.com/winston/google_visualr/pull/28) Removed InstanceMethods as it's deprecated in Rails 3.2.x.
|
139
|
-
* [Pull Request 26](https://github.com/winston/google_visualr/pull/26) Added 3 more image charts and #uri method to all image charts.
|
140
|
-
|
141
|
-
<em>Version 2.1.1</em>
|
142
|
-
|
143
|
-
* Added support for `role` and `pattern` attributes in `#new_column` and `#new_columns` methods.
|
144
|
-
|
145
|
-
<em>Version 2.1.0</em>
|
146
|
-
|
147
|
-
* Added `#render_chart` as a helper method in Rails views.
|
148
|
-
|
149
|
-
## Author
|
150
|
-
|
151
|
-
GoogleVisualr is maintained by [Winston Teo](mailto:winstonyw+googlevisualr@gmail.com).
|
152
|
-
|
153
|
-
Who is Winston Teo? [You should follow Winston on Twitter](http://www.twitter.com/winstonyw), or find out more on [WinstonYW](http://www.winstonyw.com) and [LinkedIn](http://sg.linkedin.com/in/winstonyw).
|
154
|
-
|
155
|
-
## License
|
156
|
-
|
157
|
-
Copyright © 2012 Winston Teo Yong Wei. Free software, released under the MIT license.
|