Skip to content

Commit

Permalink
Merge branch 'release/1.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Deshi Xiao committed Jul 24, 2011
2 parents 5bcdf07 + d9022c9 commit 2678fd0
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 50 deletions.
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@ LazyHighCharts
=======
LazyHighCharts is Rails 2.x/3.x Gem for displaying Highcharts graphs.

Compatibility:
lazy_high_charts 1.x is compatible with Rails 2.x/3.x

=======
### plugin support for rails 2.3.5 and rails 3

script/plugin install git://github.com/michelson/lazy_high_charts.git ##(for rails 2)

rails plugin install git://github.com/michelson/lazy_high_charts.git ##(for rails 3)

#HighStocks
LazyHighCharts now compatible with beta HighStock, http://www.highcharts.com/stock/demo/
### HighStocks
LazyHighCharts now compatible with beta HighStock, http://www.highcharts.com/stock/demo/

Usage
=======
About javascript Assets notes:
for Rails 2.x
for Rails 2.x/3.x
1.you need manually put jquery/highcharts js to public/javascript
2.modify your layout html
Sample Code:
Expand Down Expand Up @@ -54,7 +51,7 @@ Usage

@h = LazyHighCharts::HighChart.new('graph') do |f|
.....
f.x_axis(:categories => @days.reverse! , :labels=>{:rotation=>-45 , :align => 'right'})
f.xAxis(:categories => @days.reverse! , :labels=>{:rotation=>-45 , :align => 'right'})
f.chart({:defaultSeriesType=>"spline" , :renderTo => "myRenderArea" , :inverted => true})
.....

Expand All @@ -74,17 +71,13 @@ Usage
<%= "options.xAxis.labels.formatter = function() { return 'ho';}" %>
<%= "options.yAxis.labels.formatter = function() { return 'hey';}" %>
<%end %>



HighStock Support:

##just call HighChart Helper this way:

<%= high_stock("my_id", @h) %>


Option reference:

http://www.highcharts.com/ref/
Expand All @@ -97,6 +90,6 @@ Usage
Contributors
=======
LazyHighCharts gem is maintained by "Deshi Xiao":https://github.com/xiaods
git shortlog -n -s --no-merges
Run @git shortlog -n -s --no-merges@ to see the awesome.

Copyright (c) 2010 Miguel Michelson Martinez, released under the MIT license
15 changes: 7 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
require 'bundler'
Bundler::GemHelper.install_tasks
# encoding: utf-8
require 'rubygems'
require 'rake/dsl_definition'
require 'rake'
require 'rspec/core/rake_task'
require 'bundler'

desc 'Default: run specs.'
task :default => :spec

desc 'Run the specs'
if defined?(RSpec)
desc 'Test the Lazy_high_charts gem.'
RSpec::Core::RakeTask.new('spec') do |t|
t.pattern = FileList['spec/**/*_spec.rb']
end
desc 'Test the Lazy_high_charts gem.'
RSpec::Core::RakeTask.new('spec') do |t|
t.pattern = FileList['spec/**/*_spec.rb']
end
4 changes: 2 additions & 2 deletions lazy_high_charts.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Gem::Specification.new do |s|
s.authors = ['Miguel Michelson Martinez','Deshi Xiao']
s.email = ['miguelmichelson@gmail.com','xiaods@gmail.com']
s.homepage = "https://github.com/xiaods/lazy_high_charts"
s.summary = "lazy higcharts plugin for rails"
s.description = "use highcharts js libary to visualization your data plugin for rails"
s.summary = "lazy higcharts gem for rails"
s.description = "use highcharts js libary to visualization your data by rubygem/rails"

s.extra_rdoc_files = [ "README.md", "CHANGELOG.md" ]
s.rdoc_options = [ "--charset=UTF-8" ]
Expand Down
7 changes: 4 additions & 3 deletions lib/lazy_high_charts/high_chart.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module LazyHighCharts
class HighChart
CANVAS_DEFAULT_HTML_OPTIONS = { :style => "height: 300px, width:615px" }
SERIES_OPTIONS = %w(lines points bars shadowSize colors)

attr_accessor :data, :options, :placeholder, :html_options
Expand All @@ -24,11 +25,11 @@ def initialize(canvas = nil, html_opts = {})
def defaults_options
self.title({ :text=>"example test title from highcharts gem"})
self.legend({ :layout=>"vertical", :style=>{} })
self.x_axis({})
self.y_axis({ :title=> {:text=> nil}, :labels=>{} })
self.xAxis({})
self.yAxis({ :title=> {:text=> nil}, :labels=>{} })
self.tooltip({ :enabled=>true })
self.credits({ :enabled => false})
self.plot_options({ :areaspline => { } })
self.plotOptions({ :areaspline => { } })
self.chart({ :defaultSeriesType=>nil , :renderTo => nil})
self.subtitle({})
end
Expand Down
20 changes: 10 additions & 10 deletions lib/lazy_high_charts/layout_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ def high_graph(placeholder, object, &block)
chart: #{object.options[:chart].to_json},
title: #{object.options[:title].to_json},
legend: #{object.options[:legend].to_json},
xAxis: #{object.options[:x_axis].to_json},
yAxis: #{object.options[:y_axis].to_json},
xAxis: #{object.options[:xAxis].to_json},
yAxis: #{object.options[:yAxis].to_json},
tooltip: #{object.options[:tooltip].to_json},
credits: #{object.options[:credits].to_json},
plotOptions: #{object.options[:plot_options].to_json},
plotOptions: #{object.options[:plotOptions].to_json},
series: #{object.data.to_json},
subtitle: #{object.options[:subtitle].to_json}
};
// 2. Add callbacks (non-JSON compliant)
#{capture(&block) if block_given?}
#{capture(&block) if block_given?}
// 3. Build the chart
var chart = new Highcharts.Chart(options);
var chart = new Highcharts.Chart(options);
});
</script>
EOJS
Expand All @@ -57,19 +57,19 @@ def high_graph_stock(placeholder, object, &block)
chart: #{object.options[:chart].to_json},
title: #{object.options[:title].to_json},
legend: #{object.options[:legend].to_json},
xAxis: #{object.options[:x_axis].to_json},
yAxis: #{object.options[:y_axis].to_json},
xAxis: #{object.options[:xAxis].to_json},
yAxis: #{object.options[:yAxis].to_json},
tooltip: #{object.options[:tooltip].to_json},
credits: #{object.options[:credits].to_json},
plotOptions: #{object.options[:plot_options].to_json},
plotOptions: #{object.options[:plotOptions].to_json},
series: #{object.data.to_json},
subtitle: #{object.options[:subtitle].to_json}
};
// 2. Add callbacks (non-JSON compliant)
#{capture(&block) if block_given?}
#{capture(&block) if block_given?}
// 3. Build the chart
var chart = new Highcharts.StockChart(options);
var chart = new Highcharts.StockChart(options);
});
</script>
EOJS
Expand Down
2 changes: 1 addition & 1 deletion lib/lazy_high_charts/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module LazyHighCharts
VERSION = "1.1.2"
VERSION = "1.1.3"
end
22 changes: 9 additions & 13 deletions spec/high_chart_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

Record = Struct.new(:frequency, :amplitude)


describe "HighChart" do
before(:each) do
@collection = [Record.new(1,15), Record.new(2,30), Record.new(4,40)]
Expand All @@ -15,8 +14,6 @@
@flot = LazyHighCharts::HighChart.new(@placeholder, @html_options) {|chart| chart.options = @options }
end



# this is almost all flotomatic stuff
describe "initialization" do
it "should take an optional 'placeholder' argument" do
Expand All @@ -30,16 +27,15 @@

it "should set options by default" do
LazyHighCharts::HighChart.new.options.should == {
:plot_options=>{:areaspline=>{}},
:x_axis=>{},
:chart=>{:defaultSeriesType=>nil, :renderTo=>nil},
:y_axis=>{:title=>{:text=>nil},
:labels=>{}},
:title=>{:text=>"example test title from highcharts gem"},
:subtitle=>{},
:credits=>{:enabled=>false},
:legend=>{:layout=>"vertical", :style=>{}},
:tooltip=>{:enabled=>true}}
:title=>{:text=>"example test title from highcharts gem"},
:legend=>{:layout=>"vertical", :style=>{}},
:xAxis=>{},
:yAxis=>{:title=>{:text=>nil}, :labels=>{}},
:tooltip=>{:enabled=>true},
:credits=>{:enabled=>false},
:plotOptions=>{:areaspline=>{}},
:chart=>{:defaultSeriesType=>nil, :renderTo=>nil},
:subtitle=>{}}
end

it "should set data empty by default" do
Expand Down
19 changes: 18 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,24 @@

require 'webrat'
require 'rspec'
Rspec.configure do |config|
# RSpec 1.x and 2.x compatibility
if defined?(RSpec)
RSPEC_NAMESPACE = RSPEC_CONFIGURER = RSpec
elsif defined?(Spec)
RSPEC_NAMESPACE = Spec
RSPEC_CONFIGURER = Spec::Runner
else
begin
require 'rspec'
RSPEC_NAMESPACE = RSPEC_CONFIGURER = Rspec
rescue LoadError
require 'spec'
RSPEC_NAMESPACE = Spec
RSPEC_CONFIGURER = Spec::Runner
end
end

RSPEC_CONFIGURER.configure do |config|
config.include ActionView::Helpers
config.include Webrat::Matchers
end
Expand Down

0 comments on commit 2678fd0

Please sign in to comment.