lazy_high_charts 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/Gemfile +6 -0
- data/README.md +126 -84
- data/Rakefile +6 -3
- data/lazy_high_charts.gemspec +1 -6
- data/lib/lazy_high_charts.rb +1 -0
- data/lib/lazy_high_charts/core_ext/string.rb +12 -0
- data/lib/lazy_high_charts/layout_helper.rb +43 -57
- data/lib/lazy_high_charts/version.rb +1 -1
- data/lib/tasks/charts_tasks.rake +23 -0
- data/spec/high_chart_spec.rb +5 -0
- data/spec/lazy_high_charts_spec.rb +61 -11
- data/spec/spec_helper.rb +3 -0
- metadata +37 -67
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,103 +1,145 @@
|
|
1
|
-
LazyHighCharts
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
# LazyHighCharts
|
2
|
+
|
3
|
+
Easily displaying Highcharts graphs with gem style.
|
4
|
+
[![Build Status](https://secure.travis-ci.org/michelson/lazy_high_charts.png)](http://travis-ci.org/michelson/lazy_high_charts)
|
5
|
+
|
6
|
+
## Now Support Rails 2.x/3.x,Happy useful
|
7
|
+
|
8
|
+
### Installation instructions for Rails 3
|
9
|
+
|
10
|
+
### Installing it by rubygems
|
11
|
+
To install it, you just need to add it to your Gemfile:
|
12
|
+
gem 'lazy_high_charts'
|
13
|
+
|
14
|
+
And then run this to install the javascript files:
|
15
|
+
rails g lazy_high_charts:install
|
16
|
+
|
17
|
+
### Installing it as a plugin for rails 2.3.5 and rails 3
|
18
|
+
|
9
19
|
script/plugin install git://github.com/michelson/lazy_high_charts.git ##(for rails 2)
|
10
|
-
|
20
|
+
|
11
21
|
rails plugin install git://github.com/michelson/lazy_high_charts.git ##(for rails 3)
|
12
22
|
|
13
23
|
### HighStocks
|
14
24
|
LazyHighCharts now compatible with beta HighStock, http://www.highcharts.com/stock/demo/
|
15
25
|
|
16
|
-
Usage
|
17
|
-
=======
|
18
|
-
About javascript Assets notes:
|
19
|
-
for Rails 2.x/3.x
|
20
|
-
1.you need manually put jquery/highcharts js to public/javascript
|
21
|
-
2.modify your layout html
|
22
|
-
Sample Code:
|
23
|
-
<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" %>
|
24
|
-
<%= javascript_include_tag :high_charts %>
|
25
|
-
3. add gem name in your config/environment.rb
|
26
|
-
config.gem "lazy_high_charts"
|
27
|
-
4.done!
|
28
|
-
|
29
|
-
For Rails 3.x
|
30
|
-
In your Gemfile, add this line:
|
31
|
-
gem 'lazy_high_charts'
|
32
|
-
|
33
|
-
For Rails 3.1
|
34
|
-
In your Gemfile, add this line:
|
35
|
-
gem 'lazy_high_charts', '~> 1.1.5'
|
36
|
-
then execuate command:
|
37
|
-
Rails g lazy_high_charts:install
|
38
|
-
|
39
|
-
Usage in Controller:
|
40
|
-
|
41
|
-
@h = LazyHighCharts::HighChart.new('graph') do |f|
|
42
|
-
f.options[:chart][:defaultSeriesType] = "area"
|
43
|
-
f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9])
|
44
|
-
f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9] )
|
45
|
-
end
|
46
|
-
|
26
|
+
## Usage
|
47
27
|
|
48
|
-
|
49
|
-
|
50
|
-
@h = LazyHighCharts::HighChart.new('graph') do |f|
|
51
|
-
.....
|
52
|
-
f.options[:chart][:defaultSeriesType] = "area"
|
53
|
-
f.options[:chart][:inverted] = true
|
54
|
-
f.options[:legend][:layout] = "horizontal"
|
55
|
-
f.options[:xAxis][:categories] = ["uno" ,"dos" , "tres" , "cuatro"]
|
56
|
-
......
|
28
|
+
About javascript Assets notes:
|
57
29
|
|
58
|
-
|
30
|
+
### For Rails 2.x/3.0.x
|
31
|
+
|
32
|
+
1. you need manually put jquery/highcharts js to public/javascript
|
33
|
+
2. modify your layout html
|
34
|
+
Sample Code:
|
35
|
+
````
|
36
|
+
<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" %>
|
37
|
+
<%= javascript_include_tag :high_charts %>
|
38
|
+
````
|
39
|
+
|
40
|
+
3. add gem name in your config/environment.rb
|
41
|
+
````
|
42
|
+
config.gem "lazy_high_charts"
|
43
|
+
````
|
44
|
+
4. Done!
|
45
|
+
|
46
|
+
### For Rails 3.1
|
47
|
+
In your Gemfile, add this line:
|
48
|
+
````
|
49
|
+
gem 'lazy_high_charts', '~> 1.1.5'
|
50
|
+
````
|
51
|
+
then execuate command:
|
52
|
+
````
|
53
|
+
Rails g lazy_high_charts:install
|
54
|
+
````
|
55
|
+
|
56
|
+
### Usage in Controller:
|
57
|
+
````
|
58
|
+
@h = LazyHighCharts::HighChart.new('graph') do |f|
|
59
|
+
f.options[:chart][:defaultSeriesType] = "area"
|
60
|
+
f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9])
|
61
|
+
f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9] )
|
62
|
+
end
|
63
|
+
````
|
64
|
+
|
65
|
+
Without overriding entire option , (only change a specific option index):
|
66
|
+
|
67
|
+
````
|
68
|
+
@h = LazyHighCharts::HighChart.new('graph') do |f|
|
69
|
+
#.....
|
70
|
+
f.options[:chart][:defaultSeriesType] = "area"
|
71
|
+
f.options[:chart][:inverted] = true
|
72
|
+
f.options[:legend][:layout] = "horizontal"
|
73
|
+
f.options[:xAxis][:categories] = ["uno" ,"dos" , "tres" , "cuatro"]
|
74
|
+
#......
|
75
|
+
````
|
76
|
+
|
77
|
+
Overriding entire option:
|
78
|
+
|
79
|
+
````
|
80
|
+
@h = LazyHighCharts::HighChart.new('graph') do |f|
|
81
|
+
#.....
|
82
|
+
f.xAxis(:categories => @days.reverse! , :labels=>{:rotation=>-45 , :align => 'right'})
|
83
|
+
f.chart({:defaultSeriesType=>"spline" , :renderTo => "myRenderArea" , :inverted => true})
|
84
|
+
#.....
|
85
|
+
````
|
86
|
+
|
87
|
+
|
88
|
+
Usage in layout:
|
89
|
+
````
|
90
|
+
<%= javascript_include_tag :high_charts %>
|
91
|
+
````
|
92
|
+
|
93
|
+
Usage in view:
|
94
|
+
````
|
95
|
+
<%= high_chart("my_id", @h) %>
|
96
|
+
````
|
97
|
+
|
98
|
+
You can pass in additional javascript into to the view with a block, this will be executed before the high chart is called
|
99
|
+
|
100
|
+
````
|
101
|
+
<%= high_chart("my_id", @h) do |c| %>
|
102
|
+
alert('hello')
|
103
|
+
<%end %>
|
104
|
+
````
|
105
|
+
To include javascript function calls or callbacks you can use the js_code method on your string`"function".js_code`:
|
106
|
+
|
107
|
+
````
|
108
|
+
f.options[:plotOptions] = {
|
109
|
+
:column => { :events => { :click => %|function() { window.location = "http://www.highcharts.com" }|.js_code } }
|
110
|
+
}
|
111
|
+
````
|
112
|
+
|
59
113
|
|
60
|
-
|
61
|
-
.....
|
62
|
-
f.xAxis(:categories => @days.reverse! , :labels=>{:rotation=>-45 , :align => 'right'})
|
63
|
-
f.chart({:defaultSeriesType=>"spline" , :renderTo => "myRenderArea" , :inverted => true})
|
64
|
-
.....
|
114
|
+
## HighStock Support:
|
65
115
|
|
116
|
+
Just call HighChart Helper this way:
|
117
|
+
````
|
118
|
+
<%= high_stock("my_id", @h) %>
|
119
|
+
````
|
66
120
|
|
67
|
-
|
68
|
-
|
69
|
-
<%= javascript_include_tag :high_charts %>
|
70
|
-
|
71
|
-
Usage in view:
|
72
|
-
|
73
|
-
<%= high_chart("my_id", @h) %>
|
74
|
-
|
75
|
-
Passing formatting options in the view to the helper block , because all the helper options declared in the controller are converted in strict/valid json (quoted key); so we need to extend the json object with some js.
|
76
|
-
|
77
|
-
<%= high_chart("my_id", @h) do |c| %>
|
78
|
-
<%= "options.tooltip.formatter = function() { return '<b>HEY!!!'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y +' units';}" %>
|
79
|
-
<%= "options.xAxis.labels.formatter = function() { return 'ho';}" %>
|
80
|
-
<%= "options.yAxis.labels.formatter = function() { return 'hey';}" %>
|
81
|
-
<%end %>
|
121
|
+
## Option reference:
|
82
122
|
|
83
|
-
|
123
|
+
http://www.highcharts.com/ref/
|
84
124
|
|
85
|
-
|
125
|
+
## HighCharts License:
|
86
126
|
|
87
|
-
|
127
|
+
http://www.highcharts.com/license
|
128
|
+
|
88
129
|
|
89
|
-
|
130
|
+
## Contributing
|
90
131
|
|
91
|
-
|
132
|
+
We're open to any contribution. It has to be tested properly though.
|
92
133
|
|
93
|
-
|
94
|
-
|
95
|
-
|
134
|
+
* [Fork](http://help.github.com/forking/) the project
|
135
|
+
* Do your changes and commit them to your repository
|
136
|
+
* Test your changes. We won't accept any untested contributions (except if they're not testable).
|
137
|
+
* Create an [issue](https://github.com/michelson/lazy_high_charts/issues) with a link to your commits.
|
96
138
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
LazyHighCharts gem is maintained by "Deshi Xiao":https://github.com/xiaods
|
101
|
-
Run @git shortlog -n -s --no-merges@ to see the awesome.
|
139
|
+
## Maintainers
|
140
|
+
* Miguel Michelson Martinez ([github/michelson]https://github.com/michelson)
|
141
|
+
* Deshi Xiao ([github/xiaods]https://github.com/xiaods)
|
102
142
|
|
103
|
-
|
143
|
+
## License
|
144
|
+
* Copyright 2011 Deshi Xiao,MIT License
|
145
|
+
* Copyright (c) 2010 Miguel Michelson Martinez, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'rubygems'
|
3
|
-
require 'rake/dsl_definition'
|
4
3
|
require 'rake'
|
5
4
|
require 'rspec/core/rake_task'
|
6
5
|
require 'bundler'
|
7
6
|
|
8
|
-
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
desc 'Default: run unit specs.'
|
9
10
|
task :default => :spec
|
10
11
|
|
11
|
-
desc 'Test the
|
12
|
+
desc 'Test the lazy_high_charts plugin.'
|
12
13
|
RSpec::Core::RakeTask.new('spec') do |t|
|
13
14
|
t.pattern = FileList['spec/**/*_spec.rb']
|
14
15
|
end
|
16
|
+
|
17
|
+
|
data/lazy_high_charts.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
#require File.expand_path("../lib/lazy_high_charts/version", __FILE__)
|
3
2
|
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
4
3
|
require 'lazy_high_charts/version'
|
5
4
|
|
@@ -20,16 +19,12 @@ Gem::Specification.new do |s|
|
|
20
19
|
|
21
20
|
s.add_dependency "bundler", "~> 1.0"
|
22
21
|
|
23
|
-
s.add_development_dependency "webrat","~> 0.7"
|
24
|
-
s.add_development_dependency "rspec", "~> 2.0"
|
25
|
-
s.add_development_dependency "rails", "~> 3.0"
|
26
|
-
|
27
22
|
s.description = <<-DESC
|
28
23
|
lazy_high_charts is a Rails 3.x gem for displaying Highcharts graphs.
|
29
24
|
DESC
|
30
25
|
|
31
26
|
s.files = `git ls-files`.split("\n")
|
32
27
|
s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
|
33
|
-
s.require_path = 'lib'
|
28
|
+
s.require_path = 'lib'
|
34
29
|
|
35
30
|
end
|
data/lib/lazy_high_charts.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), *%w[lazy_high_charts core_ext string])
|
1
2
|
require File.join(File.dirname(__FILE__), *%w[lazy_high_charts high_chart])
|
2
3
|
require File.join(File.dirname(__FILE__), *%w[lazy_high_charts layout_helper])
|
3
4
|
require File.join(File.dirname(__FILE__), *%w[lazy_high_charts railtie]) if defined?(::Rails::Railtie)
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
module LazyHighCharts
|
3
4
|
module LayoutHelper
|
4
|
-
|
5
|
+
|
5
6
|
def high_chart(placeholder, object , &block)
|
6
7
|
object.html_options.merge!({:id=>placeholder})
|
7
8
|
object.options[:chart][:renderTo] = placeholder
|
8
9
|
high_graph(placeholder,object , &block).concat(content_tag("div","", object.html_options))
|
9
10
|
end
|
10
|
-
|
11
|
+
|
11
12
|
def high_stock(placeholder, object , &block)
|
12
13
|
object.html_options.merge!({:id=>placeholder})
|
13
14
|
object.options[:chart][:renderTo] = placeholder
|
@@ -15,72 +16,57 @@ module LazyHighCharts
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def high_graph(placeholder, object, &block)
|
18
|
-
|
19
|
-
<script type="text/javascript">
|
20
|
-
jQuery(function() {
|
21
|
-
// 1. Define JSON options
|
22
|
-
var options = {
|
23
|
-
chart: #{object.options[:chart].to_json},
|
24
|
-
title: #{object.options[:title].to_json},
|
25
|
-
legend: #{object.options[:legend].to_json},
|
26
|
-
xAxis: #{object.options[:xAxis].to_json},
|
27
|
-
yAxis: #{object.options[:yAxis].to_json},
|
28
|
-
tooltip: #{object.options[:tooltip].to_json},
|
29
|
-
credits: #{object.options[:credits].to_json},
|
30
|
-
plotOptions: #{object.options[:plotOptions].to_json},
|
31
|
-
series: #{object.data.to_json},
|
32
|
-
subtitle: #{object.options[:subtitle].to_json}
|
33
|
-
};
|
34
|
-
|
35
|
-
// 2. Add callbacks (non-JSON compliant)
|
36
|
-
#{capture(&block) if block_given?}
|
37
|
-
// 3. Build the chart
|
38
|
-
var chart = new Highcharts.Chart(options);
|
39
|
-
});
|
40
|
-
</script>
|
41
|
-
EOJS
|
42
|
-
|
43
|
-
if defined?(raw)
|
44
|
-
return raw(graph)
|
45
|
-
else
|
46
|
-
return graph
|
47
|
-
end
|
48
|
-
|
19
|
+
build_html_output("Chart", placeholder, object, &block)
|
49
20
|
end
|
50
21
|
|
51
22
|
def high_graph_stock(placeholder, object, &block)
|
23
|
+
build_html_output("StockChart", placeholder, object, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
def build_html_output(type, placeholder, object, &block)
|
27
|
+
options_collection = [ generate_json_from_hash(object.options) ]
|
28
|
+
|
29
|
+
options_collection << %|"series": #{object.data.to_json}|
|
30
|
+
|
52
31
|
graph =<<-EOJS
|
53
32
|
<script type="text/javascript">
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
series: #{object.data.to_json},
|
66
|
-
subtitle: #{object.options[:subtitle].to_json}
|
67
|
-
};
|
68
|
-
|
69
|
-
// 2. Add callbacks (non-JSON compliant)
|
70
|
-
#{capture(&block) if block_given?}
|
71
|
-
// 3. Build the chart
|
72
|
-
var chart = new Highcharts.StockChart(options);
|
73
|
-
});
|
74
|
-
</script>
|
33
|
+
(function() {
|
34
|
+
var onload = window.onload;
|
35
|
+
window.onload = function(){
|
36
|
+
if (typeof onload == "function") onload();
|
37
|
+
var options, chart;
|
38
|
+
options = { #{options_collection.join(',')} };
|
39
|
+
#{capture(&block) if block_given?}
|
40
|
+
chart = new Highcharts.#{type}(options);
|
41
|
+
};
|
42
|
+
})()
|
43
|
+
</script>
|
75
44
|
EOJS
|
76
|
-
|
45
|
+
|
77
46
|
if defined?(raw)
|
78
47
|
return raw(graph)
|
79
48
|
else
|
80
49
|
return graph
|
81
50
|
end
|
82
|
-
|
83
|
-
end
|
84
51
|
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def generate_json_from_hash hash
|
57
|
+
hash.each_pair.map do |key, value|
|
58
|
+
k = key.to_s.camelize.gsub!(/\b\w/) { $&.downcase }
|
59
|
+
if value.is_a? Hash
|
60
|
+
%|"#{k}": { #{generate_json_from_hash(value)} }|
|
61
|
+
else
|
62
|
+
if value.respond_to?(:js_code) && value.js_code?
|
63
|
+
%|"#{k}": #{value}|
|
64
|
+
else
|
65
|
+
%|"#{k}": #{value.to_json}|
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end.flatten.join(',')
|
69
|
+
end
|
70
|
+
|
85
71
|
end
|
86
72
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# desc "Explaining what the task does"
|
2
|
+
# task :lazy_highcharts do
|
3
|
+
# # Task goes here
|
4
|
+
# end
|
5
|
+
namespace :lazy_high_charts do
|
6
|
+
desc 'Installs required swf in public/ and javascript files to the public/javascripts directory.'
|
7
|
+
task :install do
|
8
|
+
puts "Copying files..."
|
9
|
+
dir = "javascripts"
|
10
|
+
["excanvas.compiled.js", "highcharts.js"].each do |js_file|
|
11
|
+
dest_file = File.join(::Rails.root.to_s, "public", dir, js_file)
|
12
|
+
src_file = File.join(::Rails.root.to_s + "/vendor/plugins/lazy_high_charts" , dir, js_file)
|
13
|
+
FileUtils.cp_r(src_file, dest_file)
|
14
|
+
end
|
15
|
+
puts "Files copied - Installation complete!"
|
16
|
+
end
|
17
|
+
desc 'Removes the javascripts for the plugin.'
|
18
|
+
task :remove do
|
19
|
+
%w{excanvas.compiled.js highcharts.js}.collect { |f|
|
20
|
+
FileUtils.rm ::Rails.root.to_s + "/public/javascripts/" + f unless !f.nil? }
|
21
|
+
puts "Files removed - Finished!"
|
22
|
+
end
|
23
|
+
end
|
data/spec/high_chart_spec.rb
CHANGED
@@ -52,6 +52,11 @@ describe "HighChart" do
|
|
52
52
|
chart = LazyHighCharts::HighChart.new {|f| f.options[:legend][:layout] = "horizontal" }
|
53
53
|
chart.options[:legend][:layout].should == "horizontal"
|
54
54
|
end
|
55
|
+
|
56
|
+
it "should take a block setting attributes" do
|
57
|
+
chart = LazyHighCharts::HighChart.new {|f| f.options[:range_selector] = {}; f.options[:range_selector][:selected] = 1}
|
58
|
+
chart.options[:range_selector][:selected].should == 1
|
59
|
+
end
|
55
60
|
|
56
61
|
it "should change a block data without overriding options" do
|
57
62
|
chart = LazyHighCharts::HighChart.new('graph') do |f|
|
@@ -11,7 +11,7 @@ describe HighChartsHelper do
|
|
11
11
|
@data = "data"
|
12
12
|
@options = "options"
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
describe "layout_helper" do
|
16
16
|
it "should return a div with an id of high_chart object" do
|
17
17
|
hc = LazyHighCharts::HighChart.new("placeholder", :class => 'stylin')
|
@@ -23,33 +23,83 @@ describe HighChartsHelper do
|
|
23
23
|
high_chart(hc.placeholder, hc).should have_selector('script')
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
describe "high_chart_graph" do
|
28
28
|
describe "ready function" do
|
29
29
|
it "should be a javascript script" do
|
30
30
|
high_chart(@placeholder, @chart).should have_selector('script', :type => 'text/javascript')
|
31
|
-
high_chart(@placeholder, @chart).should match(
|
31
|
+
high_chart(@placeholder, @chart).should match(/}\)\(\)/)
|
32
32
|
end
|
33
33
|
|
34
|
-
it "should
|
35
|
-
high_chart(@placeholder, @chart).should
|
34
|
+
it "should assign to the onload event" do
|
35
|
+
high_chart(@placeholder, @chart).should include('window.onload = function(){')
|
36
|
+
end
|
37
|
+
it "should call any existing onload function" do
|
38
|
+
high_chart(@placeholder, @chart).should match(/onload = window.onload;/)
|
39
|
+
high_chart(@placeholder, @chart).should match(/if \(typeof onload == "function"\)\s*onload\(\)/)
|
36
40
|
end
|
37
41
|
end
|
38
42
|
describe "initialize HighChart" do
|
43
|
+
it "should set variables `chart` `options`" do
|
44
|
+
high_chart(@placeholder, @chart).should include('var options, chart;')
|
45
|
+
end
|
39
46
|
it "should set Chart data" do
|
40
|
-
high_chart(@placeholder, @chart).should match(/
|
41
|
-
end
|
47
|
+
high_chart(@placeholder, @chart).should match(/chart\s+=\s+new\s+Highcharts.Chart/)
|
48
|
+
end
|
42
49
|
|
43
|
-
it "should set chart renderTo" do
|
44
|
-
high_chart(@placeholder, @chart).should match(
|
50
|
+
it "should set chart renderTo" do
|
51
|
+
high_chart(@placeholder, @chart).should match(/"renderTo": "placeholder"/)
|
45
52
|
end
|
46
|
-
|
53
|
+
|
47
54
|
it "should set Chart Stock" do
|
48
|
-
high_stock(@placeholder, @chart).should match(/
|
55
|
+
high_stock(@placeholder, @chart).should match(/chart\s+=\s+new\s+Highcharts.StockChart/)
|
49
56
|
end
|
50
57
|
end
|
51
58
|
|
52
59
|
end
|
60
|
+
|
61
|
+
|
62
|
+
it "should take a block setting attributes" do
|
63
|
+
chart = LazyHighCharts::HighChart.new {|f|
|
64
|
+
f.options[:rangeSelector] = {:selected=>1};
|
65
|
+
f.series(:type =>"spline",
|
66
|
+
:name =>"Historias",
|
67
|
+
:pointInterval => (1.day.to_i * 1000) ,
|
68
|
+
:pointStart => (Time.now.to_i * 1000),
|
69
|
+
:data => [0,1,2,3,5,6,0,7]
|
70
|
+
)
|
71
|
+
}
|
72
|
+
chart.options[:rangeSelector][:selected].should == 1
|
73
|
+
high_chart(@placeholder, chart).should match(/rangeSelector/)
|
74
|
+
high_chart(@placeholder, chart).should match(/xAxis/)
|
75
|
+
high_chart(@placeholder, chart).should match(/yAxis/)
|
76
|
+
high_chart(@placeholder, chart).should match(/series/)
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
it "should take a block setting attributes" do
|
82
|
+
chart = LazyHighCharts::HighChart.new {|f|
|
83
|
+
f.others(:foo =>"bar")
|
84
|
+
}
|
85
|
+
high_chart(@placeholder, chart).should match(/foo/)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should allow js code as attribute" do
|
89
|
+
chart = LazyHighCharts::HighChart.new {|f|
|
90
|
+
f.options[:foo] = "function () { alert('hello') }".js_code
|
91
|
+
}
|
53
92
|
|
93
|
+
high_chart(@placeholder, chart).should match(/"foo": function \(\) { alert\('hello'\) }/)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should convert keys to proper format" do
|
97
|
+
chart = LazyHighCharts::HighChart.new {|f|
|
98
|
+
f.options[:foo_bar] = { :bar_foo => "someattrib"}
|
99
|
+
}
|
100
|
+
|
101
|
+
high_chart(@placeholder, chart).should match(/fooBar/)
|
102
|
+
high_chart(@placeholder, chart).should match(/barFoo/)
|
103
|
+
end
|
54
104
|
|
55
105
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,12 +9,15 @@ require 'action_view'
|
|
9
9
|
require 'action_controller'
|
10
10
|
require 'rails'
|
11
11
|
#require 'action_mailer'
|
12
|
+
require "active_support/core_ext"
|
13
|
+
|
12
14
|
|
13
15
|
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/lazy_high_charts'))
|
14
16
|
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/lazy_high_charts/layout_helper'))
|
15
17
|
|
16
18
|
require 'webrat'
|
17
19
|
require 'rspec'
|
20
|
+
|
18
21
|
# RSpec 1.x and 2.x compatibility
|
19
22
|
if defined?(RSpec)
|
20
23
|
RSPEC_NAMESPACE = RSPEC_CONFIGURER = RSpec
|
metadata
CHANGED
@@ -1,75 +1,46 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazy_high_charts
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.6
|
4
5
|
prerelease:
|
5
|
-
version: 1.1.5
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Miguel Michelson Martinez
|
9
9
|
- Deshi Xiao
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
dependencies:
|
17
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2012-06-25 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
18
16
|
name: bundler
|
19
|
-
|
20
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
21
18
|
none: false
|
22
|
-
requirements:
|
19
|
+
requirements:
|
23
20
|
- - ~>
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version:
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.0'
|
26
23
|
type: :runtime
|
27
|
-
version_requirements: *id001
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: webrat
|
30
|
-
prerelease: false
|
31
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
-
none: false
|
33
|
-
requirements:
|
34
|
-
- - ~>
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: "0.7"
|
37
|
-
type: :development
|
38
|
-
version_requirements: *id002
|
39
|
-
- !ruby/object:Gem::Dependency
|
40
|
-
name: rspec
|
41
|
-
prerelease: false
|
42
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: "2.0"
|
48
|
-
type: :development
|
49
|
-
version_requirements: *id003
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: rails
|
52
24
|
prerelease: false
|
53
|
-
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
26
|
none: false
|
55
|
-
requirements:
|
27
|
+
requirements:
|
56
28
|
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
version:
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.0'
|
31
|
+
description: ! ' lazy_high_charts is a Rails 3.x gem for displaying Highcharts
|
32
|
+
graphs.
|
33
|
+
|
34
|
+
'
|
35
|
+
email:
|
63
36
|
- miguelmichelson@gmail.com
|
64
37
|
- xiaods@gmail.com
|
65
38
|
executables: []
|
66
|
-
|
67
39
|
extensions: []
|
68
|
-
|
69
|
-
extra_rdoc_files:
|
40
|
+
extra_rdoc_files:
|
70
41
|
- README.md
|
71
42
|
- CHANGELOG.md
|
72
|
-
files:
|
43
|
+
files:
|
73
44
|
- .gitignore
|
74
45
|
- .rspec
|
75
46
|
- CHANGELOG.md
|
@@ -82,41 +53,40 @@ files:
|
|
82
53
|
- lazy_high_charts.gemspec
|
83
54
|
- lib/generators/lazy_high_charts/install/install_generator.rb
|
84
55
|
- lib/lazy_high_charts.rb
|
56
|
+
- lib/lazy_high_charts/core_ext/string.rb
|
85
57
|
- lib/lazy_high_charts/high_chart.rb
|
86
58
|
- lib/lazy_high_charts/layout_helper.rb
|
87
59
|
- lib/lazy_high_charts/railtie.rb
|
88
60
|
- lib/lazy_high_charts/version.rb
|
61
|
+
- lib/tasks/charts_tasks.rake
|
89
62
|
- rails/init.rb
|
90
63
|
- spec/high_chart_spec.rb
|
91
64
|
- spec/lazy_high_charts_spec.rb
|
92
65
|
- spec/spec_helper.rb
|
93
|
-
has_rdoc: true
|
94
66
|
homepage: https://github.com/xiaods/lazy_high_charts
|
95
67
|
licenses: []
|
96
|
-
|
97
68
|
post_install_message:
|
98
|
-
rdoc_options:
|
69
|
+
rdoc_options:
|
99
70
|
- --charset=UTF-8
|
100
|
-
require_paths:
|
71
|
+
require_paths:
|
101
72
|
- lib
|
102
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
74
|
none: false
|
104
|
-
requirements:
|
105
|
-
- -
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version:
|
108
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
80
|
none: false
|
110
|
-
requirements:
|
81
|
+
requirements:
|
111
82
|
- - ~>
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
version:
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '1.3'
|
114
85
|
requirements: []
|
115
|
-
|
116
86
|
rubyforge_project:
|
117
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.8.24
|
118
88
|
signing_key:
|
119
89
|
specification_version: 3
|
120
90
|
summary: lazy higcharts gem for rails
|
121
91
|
test_files: []
|
122
|
-
|
92
|
+
has_rdoc:
|