Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
rails 3 gem for make highcharts graph, works in rails 3.0
Ruby
branch: master

This branch is 1 commit ahead, 119 commits behind xiaods:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
autotest
lib
rails
spec
.gitignore
.rspec
CHANGELOG.md
Gemfile
MIT-LICENSE
README.md
Rakefile
init.rb
lazy_high_charts.gemspec

README.md

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/

Usage

About javascript Assets notes: for Rails 2.x 1.you need manually put jquery/highcharts js to public/javascript 2.modify your layout html Sample Code: <%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" %> <%= javascript_include_tag :high_charts %>

  1. add gem name in your config/environment.rb config.gem "lazy_high_charts" 4.done!

    For Rails 3.x In your Gemfile, add this line: gem 'lazy_high_charts'

    Usage in Controller:

    @h = LazyHighCharts::HighChart.new('graph') do |f| f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9]) f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9] ) end

    Without overriding entire option , (only change a specific option index):

    @h = LazyHighCharts::HighChart.new('graph') do |f| ..... f.options[:chart][:defaultSeriesType] = "area" f.options[:chart][:inverted] = true f.options[:legend][:layout] = "horizontal" f.options[:xAxis][:categories] = ["uno" ,"dos" , "tres" , "cuatro"] ......

    Overriding entire option:

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

    Usage in layout:

    <%= javascript_include_tag :high_charts %>

    Usage in view:

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

    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.

    <%= high_chart("my_id", @h) do |c| %>
          <%= "options.tooltip.formatter = function() { return '<b>HEY!!!'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y +' units';}" %>
          <%= "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/

    HighCharts License:

    http://www.highcharts.com/license

Contributors

LazyHighCharts gem is maintained by "Deshi Xiao":https://github.com/xiaods

git shortlog -n -s --no-merges

Copyright (c) 2010 Miguel Michelson Martinez, released under the MIT license

Something went wrong with that request. Please try again.