lazy_high_charts 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -12
- data/Rakefile +7 -8
- data/lazy_high_charts.gemspec +2 -2
- data/lib/lazy_high_charts/high_chart.rb +4 -3
- data/lib/lazy_high_charts/layout_helper.rb +10 -10
- data/lib/lazy_high_charts/version.rb +1 -1
- data/spec/high_chart_spec.rb +9 -13
- data/spec/spec_helper.rb +18 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -2,9 +2,6 @@ LazyHighCharts
|
|
2
2
|
=======
|
3
3
|
LazyHighCharts is Rails 2.x/3.x Gem for displaying Highcharts graphs.
|
4
4
|
|
5
|
-
Compatibility:
|
6
|
-
lazy_high_charts 1.x is compatible with Rails 2.x/3.x
|
7
|
-
|
8
5
|
=======
|
9
6
|
### plugin support for rails 2.3.5 and rails 3
|
10
7
|
|
@@ -12,13 +9,13 @@ lazy_high_charts 1.x is compatible with Rails 2.x/3.x
|
|
12
9
|
|
13
10
|
rails plugin install git://github.com/michelson/lazy_high_charts.git ##(for rails 3)
|
14
11
|
|
15
|
-
|
16
|
-
|
12
|
+
### HighStocks
|
13
|
+
LazyHighCharts now compatible with beta HighStock, http://www.highcharts.com/stock/demo/
|
17
14
|
|
18
15
|
Usage
|
19
16
|
=======
|
20
17
|
About javascript Assets notes:
|
21
|
-
for Rails 2.x
|
18
|
+
for Rails 2.x/3.x
|
22
19
|
1.you need manually put jquery/highcharts js to public/javascript
|
23
20
|
2.modify your layout html
|
24
21
|
Sample Code:
|
@@ -54,7 +51,7 @@ Usage
|
|
54
51
|
|
55
52
|
@h = LazyHighCharts::HighChart.new('graph') do |f|
|
56
53
|
.....
|
57
|
-
f.
|
54
|
+
f.xAxis(:categories => @days.reverse! , :labels=>{:rotation=>-45 , :align => 'right'})
|
58
55
|
f.chart({:defaultSeriesType=>"spline" , :renderTo => "myRenderArea" , :inverted => true})
|
59
56
|
.....
|
60
57
|
|
@@ -74,9 +71,6 @@ Usage
|
|
74
71
|
<%= "options.xAxis.labels.formatter = function() { return 'ho';}" %>
|
75
72
|
<%= "options.yAxis.labels.formatter = function() { return 'hey';}" %>
|
76
73
|
<%end %>
|
77
|
-
|
78
|
-
|
79
|
-
|
80
74
|
|
81
75
|
HighStock Support:
|
82
76
|
|
@@ -84,7 +78,6 @@ Usage
|
|
84
78
|
|
85
79
|
<%= high_stock("my_id", @h) %>
|
86
80
|
|
87
|
-
|
88
81
|
Option reference:
|
89
82
|
|
90
83
|
http://www.highcharts.com/ref/
|
@@ -97,6 +90,6 @@ Usage
|
|
97
90
|
Contributors
|
98
91
|
=======
|
99
92
|
LazyHighCharts gem is maintained by "Deshi Xiao":https://github.com/xiaods
|
100
|
-
git shortlog -n -s --no-merges
|
93
|
+
Run @git shortlog -n -s --no-merges@ to see the awesome.
|
101
94
|
|
102
95
|
Copyright (c) 2010 Miguel Michelson Martinez, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake/dsl_definition'
|
3
4
|
require 'rake'
|
4
5
|
require 'rspec/core/rake_task'
|
6
|
+
require 'bundler'
|
5
7
|
|
6
8
|
desc 'Default: run specs.'
|
7
9
|
task :default => :spec
|
8
10
|
|
9
|
-
desc '
|
10
|
-
|
11
|
-
|
12
|
-
RSpec::Core::RakeTask.new('spec') do |t|
|
13
|
-
t.pattern = FileList['spec/**/*_spec.rb']
|
14
|
-
end
|
11
|
+
desc 'Test the Lazy_high_charts gem.'
|
12
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
13
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
15
14
|
end
|
data/lazy_high_charts.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.authors = ['Miguel Michelson Martinez','Deshi Xiao']
|
11
11
|
s.email = ['miguelmichelson@gmail.com','xiaods@gmail.com']
|
12
12
|
s.homepage = "https://github.com/xiaods/lazy_high_charts"
|
13
|
-
s.summary = "lazy higcharts
|
14
|
-
s.description = "use highcharts js libary to visualization your data
|
13
|
+
s.summary = "lazy higcharts gem for rails"
|
14
|
+
s.description = "use highcharts js libary to visualization your data by rubygem/rails"
|
15
15
|
|
16
16
|
s.extra_rdoc_files = [ "README.md", "CHANGELOG.md" ]
|
17
17
|
s.rdoc_options = [ "--charset=UTF-8" ]
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module LazyHighCharts
|
2
2
|
class HighChart
|
3
|
+
CANVAS_DEFAULT_HTML_OPTIONS = { :style => "height: 300px, width:615px" }
|
3
4
|
SERIES_OPTIONS = %w(lines points bars shadowSize colors)
|
4
5
|
|
5
6
|
attr_accessor :data, :options, :placeholder, :html_options
|
@@ -24,11 +25,11 @@ module LazyHighCharts
|
|
24
25
|
def defaults_options
|
25
26
|
self.title({ :text=>"example test title from highcharts gem"})
|
26
27
|
self.legend({ :layout=>"vertical", :style=>{} })
|
27
|
-
self.
|
28
|
-
self.
|
28
|
+
self.xAxis({})
|
29
|
+
self.yAxis({ :title=> {:text=> nil}, :labels=>{} })
|
29
30
|
self.tooltip({ :enabled=>true })
|
30
31
|
self.credits({ :enabled => false})
|
31
|
-
self.
|
32
|
+
self.plotOptions({ :areaspline => { } })
|
32
33
|
self.chart({ :defaultSeriesType=>nil , :renderTo => nil})
|
33
34
|
self.subtitle({})
|
34
35
|
end
|
@@ -23,19 +23,19 @@ module LazyHighCharts
|
|
23
23
|
chart: #{object.options[:chart].to_json},
|
24
24
|
title: #{object.options[:title].to_json},
|
25
25
|
legend: #{object.options[:legend].to_json},
|
26
|
-
xAxis: #{object.options[:
|
27
|
-
yAxis: #{object.options[:
|
26
|
+
xAxis: #{object.options[:xAxis].to_json},
|
27
|
+
yAxis: #{object.options[:yAxis].to_json},
|
28
28
|
tooltip: #{object.options[:tooltip].to_json},
|
29
29
|
credits: #{object.options[:credits].to_json},
|
30
|
-
plotOptions: #{object.options[:
|
30
|
+
plotOptions: #{object.options[:plotOptions].to_json},
|
31
31
|
series: #{object.data.to_json},
|
32
32
|
subtitle: #{object.options[:subtitle].to_json}
|
33
33
|
};
|
34
34
|
|
35
35
|
// 2. Add callbacks (non-JSON compliant)
|
36
|
-
|
36
|
+
#{capture(&block) if block_given?}
|
37
37
|
// 3. Build the chart
|
38
|
-
|
38
|
+
var chart = new Highcharts.Chart(options);
|
39
39
|
});
|
40
40
|
</script>
|
41
41
|
EOJS
|
@@ -57,19 +57,19 @@ module LazyHighCharts
|
|
57
57
|
chart: #{object.options[:chart].to_json},
|
58
58
|
title: #{object.options[:title].to_json},
|
59
59
|
legend: #{object.options[:legend].to_json},
|
60
|
-
xAxis: #{object.options[:
|
61
|
-
yAxis: #{object.options[:
|
60
|
+
xAxis: #{object.options[:xAxis].to_json},
|
61
|
+
yAxis: #{object.options[:yAxis].to_json},
|
62
62
|
tooltip: #{object.options[:tooltip].to_json},
|
63
63
|
credits: #{object.options[:credits].to_json},
|
64
|
-
plotOptions: #{object.options[:
|
64
|
+
plotOptions: #{object.options[:plotOptions].to_json},
|
65
65
|
series: #{object.data.to_json},
|
66
66
|
subtitle: #{object.options[:subtitle].to_json}
|
67
67
|
};
|
68
68
|
|
69
69
|
// 2. Add callbacks (non-JSON compliant)
|
70
|
-
|
70
|
+
#{capture(&block) if block_given?}
|
71
71
|
// 3. Build the chart
|
72
|
-
|
72
|
+
var chart = new Highcharts.StockChart(options);
|
73
73
|
});
|
74
74
|
</script>
|
75
75
|
EOJS
|
data/spec/high_chart_spec.rb
CHANGED
@@ -2,7 +2,6 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
|
3
3
|
Record = Struct.new(:frequency, :amplitude)
|
4
4
|
|
5
|
-
|
6
5
|
describe "HighChart" do
|
7
6
|
before(:each) do
|
8
7
|
@collection = [Record.new(1,15), Record.new(2,30), Record.new(4,40)]
|
@@ -15,8 +14,6 @@ describe "HighChart" do
|
|
15
14
|
@flot = LazyHighCharts::HighChart.new(@placeholder, @html_options) {|chart| chart.options = @options }
|
16
15
|
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
17
|
# this is almost all flotomatic stuff
|
21
18
|
describe "initialization" do
|
22
19
|
it "should take an optional 'placeholder' argument" do
|
@@ -30,16 +27,15 @@ describe "HighChart" do
|
|
30
27
|
|
31
28
|
it "should set options by default" do
|
32
29
|
LazyHighCharts::HighChart.new.options.should == {
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:tooltip=>{:enabled=>true}}
|
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=>nil, :renderTo=>nil},
|
38
|
+
:subtitle=>{}}
|
43
39
|
end
|
44
40
|
|
45
41
|
it "should set data empty by default" do
|
data/spec/spec_helper.rb
CHANGED
@@ -15,7 +15,24 @@ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/lazy_high_cha
|
|
15
15
|
|
16
16
|
require 'webrat'
|
17
17
|
require 'rspec'
|
18
|
-
|
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|
|
19
36
|
config.include ActionView::Helpers
|
20
37
|
config.include Webrat::Matchers
|
21
38
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: lazy_high_charts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.1.
|
5
|
+
version: 1.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Miguel Michelson Martinez
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-07-
|
14
|
+
date: 2011-07-24 00:00:00 +08:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -117,6 +117,6 @@ rubyforge_project:
|
|
117
117
|
rubygems_version: 1.6.2
|
118
118
|
signing_key:
|
119
119
|
specification_version: 3
|
120
|
-
summary: lazy higcharts
|
120
|
+
summary: lazy higcharts gem for rails
|
121
121
|
test_files: []
|
122
122
|
|