fullscreen_lazy_high_charts 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage*
4
+ doc
5
+ rdoc
6
+ pkg
7
+ tmp
8
+ tags
9
+ rerun.txt
10
+ Gemfile.lock
11
+ .bundle
12
+ *.gem
13
+
14
+ lazy_high_charts-1.1.5.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format=progress
3
+
data/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ * Jul 14, 2011
2
+ add support rails 3.1 rc4 now
3
+
4
+ * Jul 13, 2011
5
+ HighStock support
6
+ remove some defaults
7
+
8
+ Jan 31, 2011
9
+ * backwards compatibility for rails 2.3.x in rendering callbacks options
10
+
11
+ Nov 30,2010
12
+ * dumped to gem 0.0.1
13
+
14
+ Sep 13,2010
15
+ * truely support rails 3.0(returning is deprecate function,use tap) deshi(xiaods@gmail.com)
16
+
17
+ Sep 14,2010
18
+ * update codebase to support rails3.0 and rspec2
19
+
20
+ Oct 8,2010
21
+ * update rake.it works now!
22
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in lazy_high_charts.gemspec
4
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008-2010 Miguel Michelson Martinez
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,103 @@
1
+ LazyHighCharts
2
+ =======
3
+ LazyHighCharts is Rails 2.x/3.x Gem for displaying Highcharts graphs.
4
+
5
+ Now Support Rails 3.1 rc4 stable branch,Happy useful
6
+ =======
7
+ ### plugin support for rails 2.3.5 and rails 3
8
+
9
+ script/plugin install git://github.com/michelson/lazy_high_charts.git ##(for rails 2)
10
+
11
+ rails plugin install git://github.com/michelson/lazy_high_charts.git ##(for rails 3)
12
+
13
+ ### HighStocks
14
+ LazyHighCharts now compatible with beta HighStock, http://www.highcharts.com/stock/demo/
15
+
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
+
47
+
48
+ Without overriding entire option , (only change a specific option index):
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
+ ......
57
+
58
+ Overriding entire option:
59
+
60
+ @h = LazyHighCharts::HighChart.new('graph') do |f|
61
+ .....
62
+ f.xAxis(:categories => @days.reverse! , :labels=>{:rotation=>-45 , :align => 'right'})
63
+ f.chart({:defaultSeriesType=>"spline" , :renderTo => "myRenderArea" , :inverted => true})
64
+ .....
65
+
66
+
67
+ Usage in layout:
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 %>
82
+
83
+ HighStock Support:
84
+
85
+ ##just call HighChart Helper this way:
86
+
87
+ <%= high_stock("my_id", @h) %>
88
+
89
+ Option reference:
90
+
91
+ http://www.highcharts.com/ref/
92
+
93
+ HighCharts License:
94
+
95
+ http://www.highcharts.com/license
96
+
97
+
98
+ Contributors
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.
102
+
103
+ Copyright (c) 2010 Miguel Michelson Martinez, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+ require 'rake/dsl_definition'
4
+ require 'rake'
5
+ require 'rspec/core/rake_task'
6
+ require 'bundler'
7
+
8
+ desc 'Default: run specs.'
9
+ task :default => :spec
10
+
11
+ desc 'Test the Lazy_high_charts gem.'
12
+ RSpec::Core::RakeTask.new('spec') do |t|
13
+ t.pattern = FileList['spec/**/*_spec.rb']
14
+ end
@@ -0,0 +1 @@
1
+ Autotest.add_discovery { "rspec2" }
data/init.rb ADDED
@@ -0,0 +1,5 @@
1
+ # coding: utf-8
2
+ require 'lazy_high_charts'
3
+ require 'lazy_high_charts/layout_helper'
4
+ ActionView::Helpers::AssetTagHelper.register_javascript_expansion :high_charts => ["highcharts"]
5
+ ActionView::Base.send :include, LazyHighCharts::LayoutHelper
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #require File.expand_path("../lib/lazy_high_charts/version", __FILE__)
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
+ require 'lazy_high_charts/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "fullscreen_lazy_high_charts"
8
+ s.version = LazyHighCharts::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ['Miguel Michelson Martinez','Deshi Xiao', 'Drew Baumann']
11
+ s.email = ['miguelmichelson@gmail.com','xiaods@gmail.com']
12
+ s.homepage = "https://github.com/xiaods/lazy_high_charts"
13
+ s.summary = "lazy higcharts gem for rails -- Modified for Fullscreen, Inc. use."
14
+ s.description = "use highcharts js libary to visualization your data by rubygem/rails"
15
+
16
+ s.extra_rdoc_files = [ "README.md", "CHANGELOG.md" ]
17
+ s.rdoc_options = [ "--charset=UTF-8" ]
18
+
19
+ s.required_rubygems_version = "~> 1.3"
20
+
21
+ s.add_dependency "bundler", "~> 1.0"
22
+
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
+ s.description = <<-DESC
28
+ lazy_high_charts is a Rails 3.x gem for displaying Highcharts graphs.
29
+ DESC
30
+
31
+ s.files = `git ls-files`.split("\n")
32
+ s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
33
+ s.require_path = 'lib'
34
+
35
+ end
@@ -0,0 +1,17 @@
1
+ module LazyHighCharts
2
+ class InstallGenerator < Rails::Generators::Base
3
+ desc "This generator install highcharts javascripts"
4
+
5
+ def install_highcharts(opts = nil)
6
+ say_status("installing", "Highcharts javascript (github STOCK branch)", :green)
7
+ if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR >= 1
8
+ get "http://highcharts.com/js/highstock.js","app/assets/javascripts/highcharts.js"
9
+ else
10
+ get "https://raw.github.com/highslide-software/highcharts.com/stock/js/highcharts.src.js","public/javascripts/highcharts.js"
11
+ end
12
+ rescue OpenURI::HTTPError
13
+ say_status("warning", "could not find Highcharts javascript file", :yellow)
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), *%w[lazy_high_charts high_chart])
2
+ require File.join(File.dirname(__FILE__), *%w[lazy_high_charts layout_helper])
3
+ require File.join(File.dirname(__FILE__), *%w[lazy_high_charts railtie]) if defined?(::Rails::Railtie)
4
+
5
+ module LazyHighCharts
6
+
7
+ end
@@ -0,0 +1,82 @@
1
+ module LazyHighCharts
2
+ class HighChart
3
+ CANVAS_DEFAULT_HTML_OPTIONS = { :style => "height: 300px, width:615px" }
4
+ SERIES_OPTIONS = %w(lines points bars shadowSize colors)
5
+
6
+ attr_accessor :data, :options, :placeholder, :html_options
7
+ alias :canvas :placeholder
8
+ alias :canvas= :placeholder=
9
+
10
+ def initialize(canvas = nil, html_opts = {})
11
+
12
+ @collection_filter = nil
13
+ self.tap do |high_chart|
14
+ high_chart.data ||= []
15
+ high_chart.options ||= {}
16
+ high_chart.defaults_options
17
+ high_chart.html_options = html_opts.reverse_merge(CANVAS_DEFAULT_HTML_OPTIONS)
18
+ high_chart.canvas = canvas if canvas
19
+ yield high_chart if block_given?
20
+ end
21
+ end
22
+
23
+ # title: legend: xAxis: yAxis: tooltip: credits: :plotOptions
24
+
25
+ def defaults_options
26
+ self.title({ :text=>"example test title from highcharts gem"})
27
+ self.legend({ :layout=>"vertical", :style=>{} })
28
+ self.xAxis({})
29
+ self.yAxis({ :title=> {:text=> nil}, :labels=>{} })
30
+ self.tooltip({ :enabled=>true })
31
+ self.credits({ :enabled => false})
32
+ self.plotOptions({ :areaspline => { } })
33
+ self.chart({ :defaultSeriesType=>"areaspline" , :renderTo => nil})
34
+ self.subtitle({})
35
+ end
36
+
37
+
38
+ # Pass other methods through to the javascript high_chart object.
39
+ #
40
+ # For instance: <tt>high_chart.grid(:color => "#699")</tt>
41
+ #
42
+ def method_missing(meth, opts = {})
43
+ merge_options meth, opts
44
+ end
45
+
46
+ # Add a simple series to the graph:
47
+ #
48
+ # data = [[0,5], [1,5], [2,5]]
49
+ # @high_chart.series :name=>'Updated', :data=>data
50
+ # @high_chart.series :name=>'Updated', :data=>[5, 1, 6, 1, 5, 4, 9]
51
+ #
52
+ def series(opts = {})
53
+ @data ||= []
54
+ if opts.blank?
55
+ @data << series_options.merge(:name => label, :data => d)
56
+ else
57
+ @data << opts.merge(:name => opts[:name], :data => opts[:data])
58
+ end
59
+ end
60
+
61
+ private
62
+
63
+ def series_options
64
+ @options.reject {|k,v| SERIES_OPTIONS.include?(k.to_s) == false}
65
+ end
66
+
67
+ def merge_options(name, opts)
68
+ @options.merge! name => opts
69
+ end
70
+
71
+ def arguments_to_options(args)
72
+ if args.blank?
73
+ {:show => true}
74
+ elsif args.is_a? Array
75
+ args.first
76
+ else
77
+ args
78
+ end
79
+ end
80
+
81
+ end
82
+ end
@@ -0,0 +1,90 @@
1
+ # coding: utf-8
2
+ module LazyHighCharts
3
+ module LayoutHelper
4
+
5
+ def high_chart(placeholder, object ,id="nil", &block)
6
+ object.html_options.merge!({:id=>placeholder})
7
+ object.options[:chart][:renderTo] = placeholder
8
+ high_graph(placeholder,object ,id, &block).concat(content_tag("div","", object.html_options))
9
+ end
10
+
11
+ def high_stock(placeholder, object , &block)
12
+ object.html_options.merge!({:id=>placeholder})
13
+ object.options[:chart][:renderTo] = placeholder
14
+ high_graph_stock(placeholder,object , &block).concat(content_tag("div","", object.html_options))
15
+ end
16
+
17
+ def high_graph(placeholder, object, id, &block)
18
+ graph =<<-EOJS
19
+ <script type="text/javascript">
20
+ var global_chart_#{id};
21
+
22
+
23
+ jQuery(function() {
24
+ // 1. Define JSON options
25
+ var options = {
26
+ chart: #{object.options[:chart].to_json},
27
+ title: #{object.options[:title].to_json},
28
+ legend: #{object.options[:legend].to_json},
29
+ xAxis: #{object.options[:xAxis].to_json},
30
+ yAxis: #{object.options[:yAxis].to_json},
31
+ tooltip: #{object.options[:tooltip].to_json},
32
+ credits: #{object.options[:credits].to_json},
33
+ plotOptions: #{object.options[:plotOptions].to_json},
34
+ series: #{object.data.to_json},
35
+ subtitle: #{object.options[:subtitle].to_json}
36
+ };
37
+
38
+ // 2. Add callbacks (non-JSON compliant)
39
+ #{capture(&block) if block_given?}
40
+ // 3. Build the chart
41
+ console.log(global_chart_#{id})
42
+ global_chart_#{id} = new Highcharts.Chart(options);
43
+ });
44
+ </script>
45
+ EOJS
46
+
47
+ if defined?(raw)
48
+ return raw(graph)
49
+ else
50
+ return graph
51
+ end
52
+
53
+ end
54
+
55
+ def high_graph_stock(placeholder, object, &block)
56
+ graph =<<-EOJS
57
+ <script type="text/javascript">
58
+ jQuery(function() {
59
+ // 1. Define JSON options
60
+ var options = {
61
+ chart: #{object.options[:chart].to_json},
62
+ title: #{object.options[:title].to_json},
63
+ legend: #{object.options[:legend].to_json},
64
+ xAxis: #{object.options[:xAxis].to_json},
65
+ yAxis: #{object.options[:yAxis].to_json},
66
+ tooltip: #{object.options[:tooltip].to_json},
67
+ credits: #{object.options[:credits].to_json},
68
+ plotOptions: #{object.options[:plotOptions].to_json},
69
+ series: #{object.data.to_json},
70
+ subtitle: #{object.options[:subtitle].to_json}
71
+ };
72
+
73
+ // 2. Add callbacks (non-JSON compliant)
74
+ #{capture(&block) if block_given?}
75
+ // 3. Build the chart
76
+ var chart = new Highcharts.StockChart(options);
77
+ });
78
+ </script>
79
+ EOJS
80
+
81
+ if defined?(raw)
82
+ return raw(graph)
83
+ else
84
+ return graph
85
+ end
86
+
87
+ end
88
+
89
+ end
90
+ end
@@ -0,0 +1,20 @@
1
+ require 'lazy_high_charts'
2
+ require 'lazy_high_charts/layout_helper.rb'
3
+
4
+ require 'rails'
5
+
6
+ module LazyHighCharts
7
+
8
+ class Railtie < ::Rails::Railtie
9
+ config.before_configuration do
10
+ config.action_view.javascript_expansions[:high_charts] = %w(highcharts)
11
+ end
12
+
13
+ initializer 'lazy_high_charts.initialize' do
14
+ ActiveSupport.on_load(:action_view) do
15
+ include LazyHighCharts::LayoutHelper
16
+ end
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,3 @@
1
+ module LazyHighCharts
2
+ VERSION = "1.1.6"
3
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "init"))
@@ -0,0 +1,105 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ Record = Struct.new(:frequency, :amplitude)
4
+
5
+ describe "HighChart" do
6
+ before(:each) do
7
+ @collection = [Record.new(1,15), Record.new(2,30), Record.new(4,40)]
8
+ @data = [ [1,15], [2,30], [4,40]]
9
+
10
+ @placeholder = "placeholder"
11
+ @html_options = {:class => "stylin"}
12
+ @options = {:bars => {:show => true}}
13
+
14
+ @flot = LazyHighCharts::HighChart.new(@placeholder, @html_options) {|chart| chart.options = @options }
15
+ end
16
+
17
+ # this is almost all flotomatic stuff
18
+ describe "initialization" do
19
+ it "should take an optional 'placeholder' argument" do
20
+ LazyHighCharts::HighChart.new(@placeholder).placeholder.should == @placeholder
21
+ LazyHighCharts::HighChart.new.placeholder.should == nil
22
+ end
23
+
24
+ it "should take an optional html_options argument (defaulting to 300px height)" do
25
+ LazyHighCharts::HighChart.new(@html_options).placeholder.should == @html_options
26
+ end
27
+
28
+ it "should set options by default" do
29
+ LazyHighCharts::HighChart.new.options.should == {
30
+ :title=>{:text=>"example test title from highcharts gem"},
31
+ :legend=>{:layout=>"vertical", :style=>{}},
32
+ :xAxis=>{},
33
+ :yAxis=>{:title=>{:text=>nil}, :labels=>{}},
34
+ :tooltip=>{:enabled=>true},
35
+ :credits=>{:enabled=>false},
36
+ :plotOptions=>{:areaspline=>{}},
37
+ :chart=>{:defaultSeriesType=>"areaspline", :renderTo=>nil},
38
+ :subtitle=>{}}
39
+ end
40
+
41
+ it "should set data empty by default" do
42
+ LazyHighCharts::HighChart.new.data.should == []
43
+ end
44
+
45
+ it "should take a block setting attributes" do
46
+ chart = LazyHighCharts::HighChart.new {|f| f.data = @data ; f.options = @options }
47
+ chart.data.should == @data
48
+ chart.options.should == @options
49
+ end
50
+
51
+ it "should take a block setting attributes" do
52
+ chart = LazyHighCharts::HighChart.new {|f| f.options[:legend][:layout] = "horizontal" }
53
+ chart.options[:legend][:layout].should == "horizontal"
54
+ end
55
+
56
+ it "should change a block data without overriding options" do
57
+ chart = LazyHighCharts::HighChart.new('graph') do |f|
58
+ f.series(:name=>'John', :data=>[3, 20])
59
+ f.series(:name=>'Jane',:data=> [1, 3] )
60
+ # without overriding
61
+ f.options[:chart][:defaultSeriesType] = "area"
62
+ f.options[:chart][:inverted] = true
63
+ f.options[:legend][:layout] = "horizontal"
64
+ f.options[:xAxis][:categories] = ["uno" ,"dos" , "tres" , "cuatro"]
65
+ end
66
+ chart.data.should == [{:name=>"John", :data=>[3, 20]}, {:name=>"Jane", :data=>[1, 3]}]
67
+ chart.options[:legend][:layout].should == "horizontal"
68
+ chart.options[:xAxis][:categories].should == ["uno" ,"dos" , "tres" , "cuatro"]
69
+ chart.options[:chart][:defaultSeriesType].should == "area"
70
+ chart.options[:chart][:inverted].should == true
71
+ end
72
+
73
+ it "should change a block data with overriding entire options" do
74
+ chart = LazyHighCharts::HighChart.new('graph') do |f|
75
+ f.series(:name=>'John', :data=>[3, 20])
76
+ f.series(:name=>'Jane', :data=>[1, 3] )
77
+ f.title({ :text=>"example test title from controller"})
78
+ # without overriding
79
+ f.xAxis(:categories => ["uno" ,"dos" , "tres" , "cuatro"] , :labels=>{:rotation=>-45 , :align => 'right'})
80
+ f.chart({:defaultSeriesType=>"spline" , :renderTo => "myRenderArea" , :inverted => true})
81
+ end
82
+ chart.options[:xAxis][:categories].should == ["uno" ,"dos" , "tres" , "cuatro"]
83
+ chart.options[:xAxis][:labels][:rotation].should == -45
84
+ chart.options[:xAxis][:labels][:align].should == "right"
85
+ chart.options[:chart][:defaultSeriesType].should == "spline"
86
+ chart.options[:chart][:renderTo].should == "myRenderArea"
87
+ chart.options[:chart][:inverted].should == true
88
+ end
89
+
90
+ it "should have subtitles" do
91
+ chart = LazyHighCharts::HighChart.new('graph') do |f|
92
+ f.series(:name=>'John',:data=> [3, 20])
93
+ f.series(:name=>'Jane', :data=>[1, 3] )
94
+ f.title({ :text=>"example test title from controller"})
95
+ # without overriding
96
+ f.x_axis(:categories => ["uno" ,"dos" , "tres" , "cuatro"] , :labels=>{:rotation=>-45 , :align => 'right'})
97
+ f.chart({:defaultSeriesType=>"spline" , :renderTo => "myRenderArea" , :inverted => true})
98
+ f.subtitle({:text=>"Bar"})
99
+ end
100
+ chart.options[:subtitle][:text].should == "Bar"
101
+ end
102
+
103
+ end
104
+
105
+ end
@@ -0,0 +1,55 @@
1
+ # coding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe HighChartsHelper do
5
+ include LazyHighCharts::LayoutHelper
6
+
7
+ before(:each) do
8
+ @class = "stylin"
9
+ @placeholder = "placeholder"
10
+ @chart = LazyHighCharts::HighChart.new(@placeholder)
11
+ @data = "data"
12
+ @options = "options"
13
+ end
14
+
15
+ describe "layout_helper" do
16
+ it "should return a div with an id of high_chart object" do
17
+ hc = LazyHighCharts::HighChart.new("placeholder", :class => 'stylin')
18
+ high_chart(hc.placeholder, hc).should have_selector('div', :id => hc.placeholder, :class => 'stylin')
19
+ end
20
+
21
+ it "should return a script" do
22
+ hc = LazyHighCharts::HighChart.new("placeholder")
23
+ high_chart(hc.placeholder, hc).should have_selector('script')
24
+ end
25
+ end
26
+
27
+ describe "high_chart_graph" do
28
+ describe "ready function" do
29
+ it "should be a javascript script" do
30
+ high_chart(@placeholder, @chart).should have_selector('script', :type => 'text/javascript')
31
+ high_chart(@placeholder, @chart).should match(/\}\s*\)\s*;/)
32
+ end
33
+
34
+ it "should generate generate ready function (no conflict with prototype)" do
35
+ high_chart(@placeholder, @chart).should match(/jQuery\(function\(\)\s*\{/)
36
+ end
37
+ end
38
+ describe "initialize HighChart" do
39
+ it "should set Chart data" do
40
+ high_chart(@placeholder, @chart).should match(/var\s+chart\s+=\s+new\s+Highcharts.Chart/)
41
+ end
42
+
43
+ it "should set chart renderTo" do
44
+ high_chart(@placeholder, @chart).should match(/\"renderTo\":\"placeholder\"/)
45
+ end
46
+
47
+ it "should set Chart Stock" do
48
+ high_stock(@placeholder, @chart).should match(/var\s+chart\s+=\s+new\s+Highcharts.StockChart/)
49
+ end
50
+ end
51
+
52
+ end
53
+
54
+
55
+ end
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ Bundler.setup
5
+
6
+ require 'active_support'
7
+ require 'action_pack'
8
+ require 'action_view'
9
+ require 'action_controller'
10
+ require 'rails'
11
+ #require 'action_mailer'
12
+
13
+ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/lazy_high_charts'))
14
+ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/lazy_high_charts/layout_helper'))
15
+
16
+ require 'webrat'
17
+ require 'rspec'
18
+ # RSpec 1.x and 2.x compatibility
19
+ if defined?(RSpec)
20
+ RSPEC_NAMESPACE = RSPEC_CONFIGURER = RSpec
21
+ elsif defined?(Spec)
22
+ RSPEC_NAMESPACE = Spec
23
+ RSPEC_CONFIGURER = Spec::Runner
24
+ else
25
+ begin
26
+ require 'rspec'
27
+ RSPEC_NAMESPACE = RSPEC_CONFIGURER = Rspec
28
+ rescue LoadError
29
+ require 'spec'
30
+ RSPEC_NAMESPACE = Spec
31
+ RSPEC_CONFIGURER = Spec::Runner
32
+ end
33
+ end
34
+
35
+ RSPEC_CONFIGURER.configure do |config|
36
+ config.include ActionView::Helpers
37
+ config.include Webrat::Matchers
38
+ end
39
+
40
+ module HighChartsHelper
41
+ include ActionView::Helpers::TagHelper
42
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fullscreen_lazy_high_charts
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.1.6
6
+ platform: ruby
7
+ authors:
8
+ - Miguel Michelson Martinez
9
+ - Deshi Xiao
10
+ - Drew Baumann
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2011-09-07 00:00:00 -07:00
16
+ default_executable:
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: bundler
20
+ prerelease: false
21
+ requirement: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: "1.0"
27
+ type: :runtime
28
+ version_requirements: *id001
29
+ - !ruby/object:Gem::Dependency
30
+ name: webrat
31
+ prerelease: false
32
+ requirement: &id002 !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: "0.7"
38
+ type: :development
39
+ version_requirements: *id002
40
+ - !ruby/object:Gem::Dependency
41
+ name: rspec
42
+ prerelease: false
43
+ requirement: &id003 !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: "2.0"
49
+ type: :development
50
+ version_requirements: *id003
51
+ - !ruby/object:Gem::Dependency
52
+ name: rails
53
+ prerelease: false
54
+ requirement: &id004 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ version: "3.0"
60
+ type: :development
61
+ version_requirements: *id004
62
+ description: " lazy_high_charts is a Rails 3.x gem for displaying Highcharts graphs.\n"
63
+ email:
64
+ - miguelmichelson@gmail.com
65
+ - xiaods@gmail.com
66
+ executables: []
67
+
68
+ extensions: []
69
+
70
+ extra_rdoc_files:
71
+ - README.md
72
+ - CHANGELOG.md
73
+ files:
74
+ - .gitignore
75
+ - .rspec
76
+ - CHANGELOG.md
77
+ - Gemfile
78
+ - MIT-LICENSE
79
+ - README.md
80
+ - Rakefile
81
+ - autotest/discover.rb
82
+ - init.rb
83
+ - lazy_high_charts-1.1.5.gem
84
+ - lazy_high_charts.gemspec
85
+ - lib/generators/lazy_high_charts/install/install_generator.rb
86
+ - lib/lazy_high_charts.rb
87
+ - lib/lazy_high_charts/high_chart.rb
88
+ - lib/lazy_high_charts/layout_helper.rb
89
+ - lib/lazy_high_charts/railtie.rb
90
+ - lib/lazy_high_charts/version.rb
91
+ - rails/init.rb
92
+ - spec/high_chart_spec.rb
93
+ - spec/lazy_high_charts_spec.rb
94
+ - spec/spec_helper.rb
95
+ has_rdoc: true
96
+ homepage: https://github.com/xiaods/lazy_high_charts
97
+ licenses: []
98
+
99
+ post_install_message:
100
+ rdoc_options:
101
+ - --charset=UTF-8
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: "0"
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ~>
114
+ - !ruby/object:Gem::Version
115
+ version: "1.3"
116
+ requirements: []
117
+
118
+ rubyforge_project:
119
+ rubygems_version: 1.6.2
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: lazy higcharts gem for rails -- Modified for Fullscreen, Inc. use.
123
+ test_files: []
124
+