amcharts.rb 3.1.1.0.pre → 3.1.1.0
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.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/README.md +70 -6
- data/Rakefile +4 -0
- data/amcharts.rb.gemspec +10 -8
- data/app/assets/images/amcharts/loading.gif +0 -0
- data/app/assets/javascripts/amcharts.js +119 -0
- data/app/assets/stylesheets/amcharts.css +39 -0
- data/app/helpers/amcharts/amcharts_helper.rb +24 -0
- data/app/views/amcharts/_collection.erb +5 -0
- data/app/views/amcharts/_data.erb +10 -0
- data/app/views/amcharts/_legend.erb +4 -0
- data/app/views/amcharts/_listener.erb +1 -0
- data/app/views/amcharts/_object.erb +12 -0
- data/app/views/amcharts/_settings.erb +1 -0
- data/app/views/amcharts/_title.erb +1 -0
- data/app/views/amcharts/chart_builder.erb +36 -0
- data/lib/amcharts.rb +23 -3
- data/lib/amcharts/axis.rb +8 -0
- data/lib/amcharts/axis/category.rb +5 -0
- data/lib/amcharts/axis/value.rb +5 -0
- data/lib/amcharts/chart.rb +108 -0
- data/lib/amcharts/chart/funnel.rb +7 -0
- data/lib/amcharts/chart/gauge.rb +7 -0
- data/lib/amcharts/chart/pie.rb +15 -0
- data/lib/amcharts/chart/radar.rb +7 -0
- data/lib/amcharts/chart/rectangular.rb +22 -0
- data/lib/amcharts/chart/serial.rb +10 -0
- data/lib/amcharts/chart/xy.rb +7 -0
- data/lib/amcharts/chart_builder.rb +79 -0
- data/lib/amcharts/chart_builder/function.rb +7 -0
- data/lib/amcharts/cursor.rb +5 -0
- data/lib/amcharts/graph.rb +14 -0
- data/lib/amcharts/legend.rb +5 -0
- data/lib/amcharts/listener.rb +10 -0
- data/lib/amcharts/scroll_bar.rb +5 -0
- data/lib/amcharts/settings.rb +32 -0
- data/lib/amcharts/uses_settings.rb +10 -0
- data/lib/amcharts/version.rb +1 -1
- data/spec/chart/serial_spec.rb +5 -0
- data/spec/chart_spec.rb +17 -0
- data/vendor/assets/images/amcharts/eraserIcon.gif +0 -0
- data/vendor/assets/images/amcharts/eraserIconH.gif +0 -0
- data/vendor/assets/images/amcharts/pencilIcon.gif +0 -0
- data/vendor/assets/images/amcharts/pencilIconH.gif +0 -0
- data/vendor/assets/images/amcharts/xIcon.gif +0 -0
- data/vendor/assets/images/amcharts/xIconH.gif +0 -0
- data/vendor/assets/javascripts/amcharts/all.js +10 -0
- data/vendor/assets/javascripts/amcharts/amstock.js +86 -0
- data/vendor/assets/javascripts/amcharts/changeLog.txt +887 -0
- data/vendor/assets/javascripts/amcharts/licence.txt +16 -0
- data/vendor/assets/javascripts/amcharts/pie.js +1 -1
- data/vendor/assets/javascripts/amcharts/thirdPartySoftwareList.txt +11 -0
- data/vendor/assets/stylesheets/amcharts/style.css +58 -0
- metadata +81 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODVlZmZmZjJiZmUxOWU4NmYzYzg5NGYzNTM3ZWMyZjIzYzM0OWQ3Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjIxZTAwYTFkNmRlODhlODFiYjgwZDVkNjk1M2FhYjRkZWUwZmRiYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWNkNjlkMjVmZDRkM2EyZDc1NDk5MDQ3OGRkYWJjOWU3OTM1OWNkYjUzOTE2
|
10
|
+
OGJiZDljMGE2ZTc5YTJmMmU2NzA0ZDMwYmFiY2M1NWQxMTY4YzA4YTRiMzc3
|
11
|
+
ZDZjZGI1OGUyZTVmYjhiMWRjYjljZGE5OGQyMTJkYjU1ZGI2ODQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODhkNGVlNTM1ZjA5MTBhN2I1NzYwODAyOThmYjgwY2Q0MTMwNGVlOGZmMzgx
|
14
|
+
ZDA5MTYwZTIwYTc4ZTQ4OGIzMTg5YzdlNWZjYWU3MmVlNTBmNDU1NzlhOGUw
|
15
|
+
M2NmNGQ5MjA4YWMxNWI3OTFlYTRmMDFmNjViYTM0NmRlZTdkNmI=
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,69 @@
|
|
1
|
-
#
|
1
|
+
# AmCharts.rb
|
2
2
|
|
3
|
-
|
3
|
+
Ruby on Rails wrapper for creating AmCharts charts.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
A chart is represented by a subclass of `AmCharts::Chart` (ie. `Pie` or `Serial`), which is initialized with a data collection (should be an array
|
8
|
+
of homogeneous hashes), and some settings passed into a block:
|
9
|
+
|
10
|
+
chart = AmCharts::Chart::Serial.new(data) do |c|
|
11
|
+
add_title 'My Fancy Chart', size: 18
|
12
|
+
loading_indicator!
|
13
|
+
|
14
|
+
c.dimensions = '800x600'
|
15
|
+
|
16
|
+
legends.new do |l|
|
17
|
+
l.position = 'right'
|
18
|
+
l.value_text = '[[percents]]%'
|
19
|
+
end
|
20
|
+
|
21
|
+
scrollbar {}
|
22
|
+
end
|
23
|
+
|
24
|
+
The setup block accepts a number of methods for ease of setting up a chart, and accepts any other assignment method as a setting
|
25
|
+
that will be passed directly to AmCharts when the chart is rendered. Chart components including graphs, legends, axes, scrollbars and
|
26
|
+
cursors can also be added and configured using inner blocks. Listeners can also be defined in a similar manner.
|
27
|
+
|
28
|
+
Values in the setup block can be numeric or string literals (which will be passed along as is); symbols (which will be
|
29
|
+
given to `I18n.t` before being rendered); procs (which will be executed); or the `function()` method (which will act as
|
30
|
+
a literal javascript function).
|
31
|
+
|
32
|
+
An `AmCharts::Chart` object can then be rendered using the `amcharts` helper:
|
33
|
+
|
34
|
+
amcharts(chart, 'id-of-container')
|
35
|
+
|
36
|
+
If the container ID given doesn't already exist in the page, it will be automatically created before the chart is rendered
|
37
|
+
by AmCharts.
|
38
|
+
|
39
|
+
### Chart setup methods
|
40
|
+
* `add_title(text, options: {})`: Adds a title element to the chart. `options` can be used to specify `size`, `bold` (`true`
|
41
|
+
or `false`), `alpha` (`0..1`), and/or `color` (a hex color code).
|
42
|
+
* `loading_indicator!`: Displays a loading indicator over the chart until it has completed rendering. The indicator makes use of
|
43
|
+
an I18n key (`chart_data_loading`) and an image (`amcharts/loading.gif`) which both can be customized within your application.
|
44
|
+
* `detach_legend(div: true)`: Makes the legend (if present) render in a separate div. `div` can either be `true` (which will
|
45
|
+
cause the legend div to be given an ID the same as the main div, with a "_legend" suffix), or the ID you want to give the div.
|
46
|
+
* `dimensions=('widthxheight')`: Allows width and height to be specified in one line
|
47
|
+
|
48
|
+
### Notes about defining a chart
|
49
|
+
* Serial charts need to have their `graphs` defined on setup (this also allows multiple graphs to be defined; ie. for a multi-line chart).
|
50
|
+
Graphs are initialized with `(name, type)`, where `type` is a [type of graph](http://docs.amcharts.com/javascriptcharts/AmGraph#type)
|
51
|
+
that AmCharts is aware of (`:column`, `:line`, `:step`, etc.)
|
52
|
+
|
53
|
+
AmCharts::Chart::Serial.new(data) do
|
54
|
+
[:col1, :col2, :col3].each do |column|
|
55
|
+
graphs.new(column, :smoothedLine) do |g|
|
56
|
+
g.title = column
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
* Pie charts do not use `graphs`, as they get their values directly from the given data set.
|
61
|
+
|
62
|
+
## Using a Commercial AmCharts license
|
63
|
+
|
64
|
+
If you have purchased the commercial version of AmCharts, place the amcharts.js file it comes with inside a
|
65
|
+
`javascripts/amcharts` directory within `(app|lib|vendor)/assets`, so that it will be used instead of the free
|
66
|
+
version that is included in this gem.
|
4
67
|
|
5
68
|
## Installation
|
6
69
|
|
@@ -16,10 +79,6 @@ Or install it yourself as:
|
|
16
79
|
|
17
80
|
$ gem install amcharts.rb
|
18
81
|
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
TODO: Write usage instructions here
|
22
|
-
|
23
82
|
## Contributing
|
24
83
|
|
25
84
|
1. Fork it
|
@@ -27,3 +86,8 @@ TODO: Write usage instructions here
|
|
27
86
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
87
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
88
|
5. Create new Pull Request
|
89
|
+
|
90
|
+
## Acknowledgments
|
91
|
+
|
92
|
+
* Built upon the excellent [AmCharts Javascript V3](http://www.amcharts.com/javascript-charts/) charting package.
|
93
|
+
* Special thanks to [TalentNest](http://github.com/talentnest), who sponsored this gem's development.
|
data/Rakefile
CHANGED
data/amcharts.rb.gemspec
CHANGED
@@ -4,20 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'amcharts/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'amcharts.rb'
|
8
8
|
spec.version = AmCharts::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Daniel Vandersluis']
|
10
|
+
spec.email = ['dvandersluis@selfmgmt.com']
|
11
11
|
spec.description = %q{Ruby wrapper for Amcharts}
|
12
12
|
spec.summary = %q{Wrapper for Amcharts 3 Javascript charts}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/dvandersluis/amcharts.rb'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths =
|
19
|
+
spec.require_paths = %w(lib)
|
20
20
|
|
21
|
-
spec.
|
22
|
-
spec.
|
21
|
+
spec.add_dependency 'rails', '> 3.0.0'
|
22
|
+
spec.add_dependency 'collection_of', '>= 1.0.3'
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
23
25
|
end
|
Binary file
|
@@ -0,0 +1,119 @@
|
|
1
|
+
/*
|
2
|
+
*= require amcharts/amcharts
|
3
|
+
*/
|
4
|
+
|
5
|
+
// Add indexOf and getElementsByClassName methods
|
6
|
+
// See: http://stackoverflow.com/questions/13261506/getelementsbyclassname-in-ie8
|
7
|
+
(function() {
|
8
|
+
var indexOf = [].indexOf || function(prop) {
|
9
|
+
for (var i = 0; i < this.length; i++) {
|
10
|
+
if (this[i] === prop) return i;
|
11
|
+
}
|
12
|
+
return -1;
|
13
|
+
};
|
14
|
+
window.getElementsByClassName = function(className,context) {
|
15
|
+
if (context.getElementsByClassName) return context.getElementsByClassName(className);
|
16
|
+
var elems = document.querySelectorAll ? context.querySelectorAll("." + className) : (function() {
|
17
|
+
var all = context.getElementsByTagName("*"),
|
18
|
+
elements = [],
|
19
|
+
i = 0;
|
20
|
+
for (; i < all.length; i++) {
|
21
|
+
if (all[i].className && (" " + all[i].className + " ").indexOf(" " + className + " ") > -1 && indexOf.call(elements,all[i]) === -1) elements.push(all[i]);
|
22
|
+
}
|
23
|
+
return elements;
|
24
|
+
})();
|
25
|
+
return elems;
|
26
|
+
};
|
27
|
+
})();
|
28
|
+
|
29
|
+
function add_container_if_needed(id, width, height)
|
30
|
+
{
|
31
|
+
var container = document.getElementById(id);
|
32
|
+
|
33
|
+
if (!container)
|
34
|
+
{
|
35
|
+
container = document.createElement("DIV");
|
36
|
+
container.className = 'chart';
|
37
|
+
container.id = id;
|
38
|
+
container.style.width = width + 'px';
|
39
|
+
container.style.height = height + 'px';
|
40
|
+
|
41
|
+
// Add the container before the last script
|
42
|
+
var scripts = document.getElementsByTagName('script');
|
43
|
+
var this_script = scripts[scripts.length - 1];
|
44
|
+
this_script.parentNode.insertBefore(container, this_script);
|
45
|
+
}
|
46
|
+
|
47
|
+
return container;
|
48
|
+
}
|
49
|
+
|
50
|
+
function add_loading_indicator(container, width, height, message, image_path)
|
51
|
+
{
|
52
|
+
var wrapper = document.createElement("DIV"),
|
53
|
+
blanket = document.createElement("DIV"),
|
54
|
+
blanket_container = document.createElement("DIV"),
|
55
|
+
blanket_outer = document.createElement("DIV"),
|
56
|
+
blanket_inner = document.createElement("DIV"),
|
57
|
+
loading_div = document.createElement("DIV"),
|
58
|
+
loading_image = document.createElement("IMG"),
|
59
|
+
loading = document.createTextNode(message);
|
60
|
+
|
61
|
+
wrapper.className = 'chart-wrapper';
|
62
|
+
wrapper.style.width = width + 'px';
|
63
|
+
wrapper.style.minHeight = height + 'px';
|
64
|
+
|
65
|
+
blanket.className = 'chart-blanket';
|
66
|
+
|
67
|
+
loading_div.className = 'chart-loading';
|
68
|
+
loading_image.className = 'chart-loading-image';
|
69
|
+
loading_image.src = image_path;
|
70
|
+
|
71
|
+
container.parentNode.insertBefore(wrapper, container);
|
72
|
+
|
73
|
+
blanket_container.appendChild(blanket_outer)
|
74
|
+
blanket_outer.appendChild(blanket_inner);
|
75
|
+
blanket_inner.appendChild(loading_div);
|
76
|
+
loading_div.appendChild(loading);
|
77
|
+
blanket_inner.appendChild(loading_image);
|
78
|
+
|
79
|
+
blanket.appendChild(blanket_container);
|
80
|
+
wrapper.appendChild(blanket);
|
81
|
+
wrapper.appendChild(container);
|
82
|
+
}
|
83
|
+
|
84
|
+
function hide_loading_indicator(chart)
|
85
|
+
{
|
86
|
+
var container = chart.container.div;
|
87
|
+
var wrapper = container;
|
88
|
+
while ((" " + wrapper.className + " ").indexOf(" chart-wrapper ") < 0)
|
89
|
+
{
|
90
|
+
wrapper = wrapper.parentElement;
|
91
|
+
}
|
92
|
+
|
93
|
+
getElementsByClassName('chart-blanket', wrapper)[0].style.display = 'none';
|
94
|
+
}
|
95
|
+
|
96
|
+
function add_legend_div(id, main_div)
|
97
|
+
{
|
98
|
+
var legend = document.getElementById(id);
|
99
|
+
|
100
|
+
if (!legend)
|
101
|
+
{
|
102
|
+
legend = document.createElement("DIV");
|
103
|
+
legend.className = 'chart-legend';
|
104
|
+
legend.id = id;
|
105
|
+
legend.style.width = main_div.getWidth() + 'px';
|
106
|
+
|
107
|
+
var wrapper = main_div.parentNode;
|
108
|
+
if(main_div.nextSibling)
|
109
|
+
{
|
110
|
+
wrapper.insertBefore(legend, main_div.nextSibling);
|
111
|
+
}
|
112
|
+
else
|
113
|
+
{
|
114
|
+
wrapper.appendChild(legend);
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
return legend;
|
119
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
.chart-wrapper
|
2
|
+
{
|
3
|
+
position: relative;
|
4
|
+
}
|
5
|
+
|
6
|
+
.chart-wrapper .chart-blanket
|
7
|
+
{
|
8
|
+
width: 100%;
|
9
|
+
height: 100%;
|
10
|
+
position: absolute;
|
11
|
+
top: 0;
|
12
|
+
left: 0;
|
13
|
+
z-index: 10000;
|
14
|
+
background: white;
|
15
|
+
}
|
16
|
+
|
17
|
+
.chart-wrapper .chart-blanket > div
|
18
|
+
{
|
19
|
+
position: relative;
|
20
|
+
width: 100%;
|
21
|
+
height: 100%;
|
22
|
+
overflow-x: hidden;
|
23
|
+
}
|
24
|
+
|
25
|
+
.chart-wrapper .chart-blanket > div > div
|
26
|
+
{
|
27
|
+
float: left;
|
28
|
+
position: relative;
|
29
|
+
left: 50%;
|
30
|
+
top: 50%;
|
31
|
+
margin-top: -18px;
|
32
|
+
}
|
33
|
+
|
34
|
+
.chart-wrapper .chart-blanket > div > div > div
|
35
|
+
{
|
36
|
+
position: relative;
|
37
|
+
right: 50%;
|
38
|
+
text-align: center;
|
39
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module AmCharts
|
2
|
+
module AmChartsHelper
|
3
|
+
def amchart(chart, container)
|
4
|
+
# Load necessary JS and CSSfiles, without loading one more than once
|
5
|
+
@loaded_amchart_files ||= { js: [], css: []}
|
6
|
+
|
7
|
+
js_files = ['amcharts', "amcharts/#{chart.type}"] - @loaded_amchart_files[:js]
|
8
|
+
css_files = ['amcharts'] - @loaded_amchart_files[:css]
|
9
|
+
|
10
|
+
@loaded_amchart_files[:js] += js_files
|
11
|
+
@loaded_amchart_files[:css] += css_files
|
12
|
+
|
13
|
+
content_for(:javascript) { javascript_include_tag(*js_files) }
|
14
|
+
content_for(:stylesheets) { stylesheet_link_tag(*css_files) }
|
15
|
+
|
16
|
+
# Render the chart builder
|
17
|
+
builder = AmCharts::ChartBuilder.new(chart, self)
|
18
|
+
chart.container = container
|
19
|
+
javascript_tag do
|
20
|
+
builder.render_js('chart_builder', template_type: :file, locals: { chart: chart, container: container })
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% if chart.pie? %>
|
2
|
+
chart.valueField = '<%= chart.value_field %>';
|
3
|
+
chart.titleField = '<%= chart.title_field %>';
|
4
|
+
<% else %>
|
5
|
+
<%#= render(layout: 'amcharts/collection', object: chart.graphs, locals: { builder: builder, name: :graph, type: 'AmGraph' }) do |obj, var| %>
|
6
|
+
<%= builder.render_js('collection', template_type: :layout, object: chart.graphs, locals: { name: :graph, type: 'AmGraph' }) do |obj, var| %>
|
7
|
+
<%= var %>.valueField = '<%= obj.value_field %>';
|
8
|
+
<%= var %>.type = '<%= obj.type %>';
|
9
|
+
<% end %>
|
10
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
chart.addListener(<%= builder.to_js(type.to_s) %>, function() { return <%= method %>.apply(null, [chart]) });
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<% if object %>
|
2
|
+
<% var = local_assigns.fetch(:var, name) %>
|
3
|
+
<% method = local_assigns.fetch(:method, "add#{name.to_s.camelize}") %>
|
4
|
+
<% js_object = local_assigns.fetch(:js_object, "new AmCharts.#{local_assigns.fetch(:type, name.to_s.camelize)}") %>
|
5
|
+
|
6
|
+
var <%= var %> = <%= js_object %>;
|
7
|
+
<% builder.render_settings(object, var.to_s) %>
|
8
|
+
<%= yield(object, var) rescue nil %>
|
9
|
+
<% if method %>
|
10
|
+
chart.<%= method %>(<%= var %>);
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= name %>.<%= key.camelize(:lower) %> = <%= builder.to_js(value) %>;
|
@@ -0,0 +1 @@
|
|
1
|
+
chart.addTitle(<%= builder.to_js(title) %>, <%= builder.to_js(options[:size]) %>, <%= builder.to_js(options[:color]) %>, <%= builder.to_js(options[:alpha]) %>, <%= builder.to_js(options[:bold]) %>);
|
@@ -0,0 +1,36 @@
|
|
1
|
+
// If the container element doesn't already exist, create it
|
2
|
+
var container = add_container_if_needed('<%= container %>', <%= chart.width %>, <%= chart.height %>);
|
3
|
+
|
4
|
+
<% if chart.loading_indicator? %>
|
5
|
+
add_loading_indicator(container, <%= chart.width %>, <%= chart.height %>, <%= builder.to_js(:chart_data_loading) %>, '<%= escape_javascript asset_path('amcharts/loading.gif') %>');
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<% if chart.legend_div %>
|
9
|
+
add_legend_div('<%= chart.legend_div == true ? "#{container}_legend" : chart.legend_div %>', container);
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
AmCharts.ready(function() {
|
13
|
+
var chart_data = <%= builder.to_js(chart.data) %>;
|
14
|
+
var chart = new <%= chart.amchart_type %>;
|
15
|
+
|
16
|
+
chart.dataProvider = chart_data;
|
17
|
+
chart.categoryField = '<%= chart.category_field %>';
|
18
|
+
chart.pathToImages = '<%= escape_javascript asset_path('amcharts/') %>';
|
19
|
+
|
20
|
+
<% builder.render_settings(chart, 'chart') %>
|
21
|
+
|
22
|
+
<% builder.render_data %>
|
23
|
+
|
24
|
+
<% builder.render_legend %>
|
25
|
+
|
26
|
+
<% builder.render_component(chart.category_axis, name: :category_axis, js_object: 'chart.categoryAxis', method: false) %>
|
27
|
+
<% builder.render_component(chart.value_axes, name: :value_axis) %>
|
28
|
+
<% builder.render_component(chart.cursor, name: :chart_cursor) %>
|
29
|
+
<% builder.render_component(chart.scrollbar, name: :chart_scrollbar) %>
|
30
|
+
|
31
|
+
<% builder.render_title %>
|
32
|
+
|
33
|
+
<% builder.render_listeners %>
|
34
|
+
|
35
|
+
chart.write('<%= container %>');
|
36
|
+
});
|
data/lib/amcharts.rb
CHANGED
@@ -1,9 +1,29 @@
|
|
1
|
+
require 'collection_of'
|
1
2
|
require "amcharts/version"
|
3
|
+
require_relative '../app/helpers/amcharts/amcharts_helper'
|
2
4
|
|
3
5
|
module AmCharts
|
4
|
-
|
5
|
-
|
6
|
+
autoload :Axis, 'amcharts/axis'
|
7
|
+
autoload :Chart, 'amcharts/chart'
|
8
|
+
autoload :ChartBuilder, 'amcharts/chart_builder'
|
9
|
+
autoload :Cursor, 'amcharts/cursor'
|
10
|
+
autoload :Graph, 'amcharts/graph'
|
11
|
+
autoload :Legend, 'amcharts/legend'
|
12
|
+
autoload :Listener, 'amcharts/listener'
|
13
|
+
autoload :ScrollBar, 'amcharts/scroll_bar'
|
14
|
+
autoload :Settings, 'amcharts/settings'
|
15
|
+
autoload :UsesSettings, 'amcharts/uses_settings'
|
6
16
|
|
7
|
-
|
17
|
+
ActiveSupport::Inflector.inflections do |inflect|
|
18
|
+
inflect.acronym "AmCharts"
|
8
19
|
end
|
20
|
+
|
21
|
+
Engine = Class.new(::Rails::Engine) do
|
22
|
+
# Load the Amcharts helper when loading ActionView
|
23
|
+
initializer 'amcharts.action_controller' do |app|
|
24
|
+
ActiveSupport.on_load :action_controller do
|
25
|
+
helper AmCharts::AmChartsHelper
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end if defined?(Rails)
|
9
29
|
end
|