lazy_high_charts 1.2.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ * Aug 31, 2012
2
+ 1. Correct highchart js location
3
+ [issue#74](https://github.com/michelson/lazy_high_charts/issues/74)
4
+ 2. support series data add javascript event
5
+ [issue#73](https://github.com/michelson/lazy_high_charts/issues/73)
6
+ 3. remove default html options.
7
+ [issue#72](https://github.com/michelson/lazy_high_charts/issues/72)
8
+
1
9
  * Aug 26, 2012
2
10
  1. Troy Anderson (laptop) <troy@tlainvestments.com>
3
11
  Added ability to supply an array of axes or other objects and still use .js_code within the array of hashes.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "http://ruby.taobao.org"
2
2
 
3
3
  # Specify your gem's dependencies in lazy_high_charts.gemspec
4
4
  gemspec
@@ -7,4 +7,8 @@ group :test, :development do # This causes the plugins to NOT load
7
7
  gem 'webrat','~> 0.7'
8
8
  gem 'rspec', '~> 2.0'
9
9
  gem 'rails'
10
+ gem 'ZenTest'
11
+ gem 'autotest'
10
12
  end
13
+
14
+
data/README.md CHANGED
@@ -4,9 +4,8 @@ Easily displaying Highcharts graphs with gem style.
4
4
  [![Build Status](https://secure.travis-ci.org/michelson/lazy_high_charts.png)](http://travis-ci.org/michelson/lazy_high_charts)
5
5
 
6
6
  ## Notice
7
-
8
- lasted version: 1.2.0
9
- Thanks for Troy & David
7
+ latest version: 1.2.2
8
+ [ChangeLog](https://github.com/xiaods/lazy_high_charts/blob/master/CHANGELOG.md)
10
9
 
11
10
  ### Installation instructions for Rails 3
12
11
 
@@ -17,7 +16,7 @@ To install it, you just need to add it to your Gemfile:
17
16
  And then run this to install the javascript files:
18
17
  rails g lazy_high_charts:install
19
18
 
20
- ### Installing it as a plugin for rails 2.3.5 and rails 3
19
+ ### Installing it as a plugin for rails 2.3.x
21
20
 
22
21
  script/plugin install git://github.com/michelson/lazy_high_charts.git ##(for rails 2)
23
22
 
@@ -30,6 +29,12 @@ And then run this to install the javascript files:
30
29
 
31
30
  About javascript Assets notes:
32
31
 
32
+ ### For Rails 3.2.x
33
+ 1. add your highcart js to app/assets/javascripts/application.js
34
+ ````
35
+ //= require highcharts
36
+ ````
37
+
33
38
  ### For Rails 2.x/3.0.x
34
39
 
35
40
  1. you need manually put jquery/highcharts js to public/javascript
@@ -129,10 +134,15 @@ We're open to any contribution. It has to be tested properly though.
129
134
  * Test your changes. We won't accept any untested contributions (except if they're not testable).
130
135
  * Create an [issue](https://github.com/michelson/lazy_high_charts/issues) with a link to your commits.
131
136
 
137
+ Contributer List:
138
+ * [Troy Anderson](https://github.com/troya2)
139
+ * [David Biehl](https://github.com/lazylodr)
140
+
141
+ Thanks for Troy & David
132
142
  ## Maintainers
133
- * Miguel Michelson Martinez ([github/michelson]https://github.com/michelson)
134
- * Deshi Xiao ([github/xiaods]https://github.com/xiaods)
143
+ * Miguel Michelson Martinez [github/michelson](https://github.com/michelson)
144
+ * Deshi Xiao [github/xiaods](https://github.com/xiaods)
135
145
 
136
146
  ## License
137
- * Copyright 2011 Deshi Xiao,MIT License
147
+ * Copyright (c) 2011,2012 Deshi Xiao,released under the MIT license
138
148
  * Copyright (c) 2010 Miguel Michelson Martinez, released under the MIT license
@@ -1,17 +1,17 @@
1
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', 'vendor/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)
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(code.highcharts.com/stock version)", :green)
7
+ if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR >= 1
8
+ get "http://code.highcharts.com/stock/highstock.js", "vendor/assets/javascripts/highcharts.js"
9
+ else
10
+ get "http://code.highcharts.com/stock/highstock.js","public/javascripts/highcharts.js"
14
11
  end
15
-
12
+ rescue OpenURI::HTTPError
13
+ say_status("warning", "could not find Highcharts javascript file", :yellow)
16
14
  end
15
+
16
+ end
17
17
  end
@@ -1,7 +1,6 @@
1
1
  module LazyHighCharts
2
2
  class HighChart
3
- CANVAS_DEFAULT_HTML_OPTIONS = { :style => "height: 300px; width:615px" }
4
- SERIES_OPTIONS = %w(lines points bars shadowSize colors)
3
+ SERIES_OPTIONS = %w(data dataParser dataURL index legendIndex name stack type xAxis yAxis)
5
4
 
6
5
  attr_accessor :data, :options, :placeholder, :html_options
7
6
  alias :canvas :placeholder
@@ -14,14 +13,13 @@ module LazyHighCharts
14
13
  high_chart.data ||= []
15
14
  high_chart.options ||= {}
16
15
  high_chart.defaults_options
17
- high_chart.html_options = html_opts.reverse_merge(CANVAS_DEFAULT_HTML_OPTIONS)
16
+ high_chart.html_options ||={}
18
17
  high_chart.canvas = canvas if canvas
19
18
  yield high_chart if block_given?
20
19
  end
21
20
  end
22
21
 
23
22
  # title: legend: xAxis: yAxis: tooltip: credits: :plotOptions
24
-
25
23
  def defaults_options
26
24
  self.title({ :text=>"example test title from highcharts gem"})
27
25
  self.legend({ :layout=>"vertical", :style=>{} })
@@ -30,7 +28,7 @@ module LazyHighCharts
30
28
  self.tooltip({ :enabled=>true })
31
29
  self.credits({ :enabled => false})
32
30
  self.plotOptions({ :areaspline => { } })
33
- self.chart({ :defaultSeriesType=>"areaspline" , :renderTo => nil})
31
+ self.chart({ :defaultSeriesType=>"line" , :renderTo => nil})
34
32
  self.subtitle({})
35
33
  end
36
34
 
@@ -38,7 +36,6 @@ module LazyHighCharts
38
36
  # Pass other methods through to the javascript high_chart object.
39
37
  #
40
38
  # For instance: <tt>high_chart.grid(:color => "#699")</tt>
41
- #
42
39
  def method_missing(meth, opts = {})
43
40
  merge_options meth, opts
44
41
  end
@@ -48,12 +45,9 @@ module LazyHighCharts
48
45
  # data = [[0,5], [1,5], [2,5]]
49
46
  # @high_chart.series :name=>'Updated', :data=>data
50
47
  # @high_chart.series :name=>'Updated', :data=>[5, 1, 6, 1, 5, 4, 9]
51
- #
52
48
  def series(opts = {})
53
49
  @data ||= []
54
- if opts.blank?
55
- @data << series_options.merge(:name => label, :data => d)
56
- else
50
+ if not opts.empty?
57
51
  @data << opts.merge(:name => opts[:name], :data => opts[:data])
58
52
  end
59
53
  end
@@ -25,8 +25,7 @@ module LazyHighCharts
25
25
 
26
26
  def build_html_output(type, placeholder, object, &block)
27
27
  options_collection = [ generate_json_from_hash(object.options) ]
28
-
29
- options_collection << %|"series": #{object.data.to_json}|
28
+ options_collection << %|"series": [#{generate_json_from_array(object.data)}]|
30
29
 
31
30
  core_js =<<-EOJS
32
31
  var options, chart;
@@ -57,7 +56,6 @@ module LazyHighCharts
57
56
  EOJS
58
57
  end
59
58
 
60
-
61
59
  if defined?(raw)
62
60
  return raw(graph)
63
61
  else
@@ -1,3 +1,3 @@
1
1
  module LazyHighCharts
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.2"
3
3
  end
@@ -34,7 +34,7 @@ describe "HighChart" do
34
34
  :tooltip=>{:enabled=>true},
35
35
  :credits=>{:enabled=>false},
36
36
  :plotOptions=>{:areaspline=>{}},
37
- :chart=>{:defaultSeriesType=>"areaspline", :renderTo=>nil},
37
+ :chart=>{:defaultSeriesType=>"line", :renderTo=>nil},
38
38
  :subtitle=>{}}
39
39
  end
40
40
 
@@ -12,10 +12,9 @@ describe HighChartsHelper do
12
12
  @options = "options"
13
13
  end
14
14
 
15
- describe "layout_helper" do
15
+ context "layout_helper" do
16
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')
17
+ high_chart(@placeholder, @chart).should have_selector('div', :id => @placeholder)
19
18
  end
20
19
 
21
20
  it "should return a script" do
@@ -24,7 +23,7 @@ describe HighChartsHelper do
24
23
  end
25
24
  end
26
25
 
27
- describe "high_chart_graph" do
26
+ context "high_chart_graph" do
28
27
  describe "ready function" do
29
28
  it "should be a javascript script" do
30
29
  high_chart(@placeholder, @chart).should have_selector('script', :type => 'text/javascript')
@@ -115,4 +114,21 @@ describe HighChartsHelper do
115
114
  high_chart(@placeholder,chart).should match(/"formatter": function\(\) {return this.value \+ ' W';}/)
116
115
  end
117
116
 
117
+ it "should support js_code in Individual data label for each point" do
118
+ chart = LazyHighCharts::HighChart.new {|f|
119
+ f.series(
120
+ :data => [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, {
121
+ :dataLabels => {:enabled => true,
122
+ :align => 'left',
123
+ :x => 10,
124
+ :y => 4,
125
+ :style => {:fontWeight => 'bold'},
126
+ :formatter => "function() { return this.x; }".js_code
127
+ },
128
+ :y => 54.4}
129
+ ])
130
+ }
131
+ high_chart(@placeholder,chart).should match(/"formatter": function\(\) {\ return this.x;\ }/)
132
+ end
133
+
118
134
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_high_charts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-26 00:00:00.000000000 Z
13
+ date: 2012-08-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -58,7 +58,6 @@ files:
58
58
  - lib/lazy_high_charts/layout_helper.rb
59
59
  - lib/lazy_high_charts/railtie.rb
60
60
  - lib/lazy_high_charts/version.rb
61
- - lib/tasks/charts_tasks.rake
62
61
  - rails/init.rb
63
62
  - spec/high_chart_spec.rb
64
63
  - spec/lazy_high_charts_spec.rb
@@ -89,3 +88,4 @@ signing_key:
89
88
  specification_version: 3
90
89
  summary: lazy higcharts gem for rails
91
90
  test_files: []
91
+ has_rdoc:
@@ -1,23 +0,0 @@
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