├── lib ├── nvd3-rails.rb └── nvd3 │ ├── rails │ ├── version.rb │ └── engine.rb │ └── rails.rb ├── vendor └── assets │ ├── stylesheets │ └── nvd3-rails.css │ └── javascripts │ ├── set-nvd3-env.js.erb │ └── nvd3-rails.js ├── .gitmodules ├── nvd3-rails.gemspec └── README.md /lib/nvd3-rails.rb: -------------------------------------------------------------------------------- 1 | require 'nvd3/rails' 2 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/nvd3-rails.css: -------------------------------------------------------------------------------- 1 | /* 2 | *= require ../javascripts/nvd3/src/nv.d3.css 3 | */ 4 | -------------------------------------------------------------------------------- /lib/nvd3/rails/version.rb: -------------------------------------------------------------------------------- 1 | module NVD3 2 | module Rails 3 | VERSION = "0.0.1" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/nvd3/rails/engine.rb: -------------------------------------------------------------------------------- 1 | module NVD3 2 | module Rails 3 | class Engine < ::Rails::Engine 4 | end 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vendor/assets/javascripts/nvd3"] 2 | path = vendor/assets/javascripts/nvd3 3 | url = git://github.com/adeven/nvd3.git 4 | -------------------------------------------------------------------------------- /lib/nvd3/rails.rb: -------------------------------------------------------------------------------- 1 | require 'nvd3/rails/engine' 2 | require 'nvd3/rails/version' 3 | 4 | module NVD3 5 | module Rails 6 | 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/set-nvd3-env.js.erb: -------------------------------------------------------------------------------- 1 | /** 2 | set nv.dev according to Rails.env 3 | */ 4 | 5 | window.nv.dev = <%= Rails.env.development? ? true : false %> 6 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/nvd3-rails.js: -------------------------------------------------------------------------------- 1 | //= require ./nvd3/lib/d3.v2 2 | //= require ./nvd3/lib/fisheye 3 | //= require ./nvd3/src/core 4 | //= require ./nvd3/src/tooltip 5 | //= require ./nvd3/src/utils.js 6 | //= require_tree ./nvd3/src/models 7 | //= require set-nvd3-env.js.erb 8 | -------------------------------------------------------------------------------- /nvd3-rails.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | require File.expand_path('../lib/nvd3/rails/version', __FILE__) 3 | 4 | Gem::Specification.new do |s| 5 | s.name = "nvd3-rails" 6 | s.version = NVD3::Rails::VERSION 7 | s.platform = Gem::Platform::RUBY 8 | s.authors = ["Manuel Knie"] 9 | s.email = ["manuel@adeven.com"] 10 | s.homepage = "http://adeven.com" 11 | s.summary = "Use nvd3 with Rails 3" 12 | s.description = "This gem provides nvd3 for your Rails 3 application." 13 | 14 | s.required_rubygems_version = ">= 1.3.6" 15 | 16 | s.add_dependency "railties", ">= 3.2.0", "< 5.0" 17 | 18 | s.files = `git ls-files`.split("\n") 19 | s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } 20 | s.require_path = 'lib' 21 | end 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NVD3 Rails - reusable charts for rails 3 2 | 3 | ## Install 4 | 5 | To include nvd3-rails into your rails project add 6 | 7 | gem "nvd3-rails", :git => "git@github.com:adeven/nvd3-rails.git", :submodules => true 8 | 9 | To your Projects Gemfile. 10 | 11 | To add the necessary javascript files into your asset pipeline add 12 | 13 | //= require nvd3-rails 14 | 15 | in ```app/assets/javascripts/application.js``` 16 | 17 | also add 18 | 19 | *= require nvd3-rails 20 | 21 | in ```app/assets/stylesheets/application.css``` 22 | 23 | Note as of today nvd3 clutters the model naming e.g. lineWithFisheyeChart.js and lineChart.js export their model both as lineChart. 24 | If you only need a subset of models e.g. lineChart you can add 25 | 26 | //= require nvd3/lib/d3.v2 27 | //= require nvd3/src/core 28 | //= require nvd3/src/tooltip 29 | //= require nvd3/src/utils.js 30 | //= require nvd3/src/models/lineChart 31 | //= require nvd3/src/models/legend.js 32 | //= require nvd3/src/models/axis.js 33 | //= require nvd3/src/models/scatter.js 34 | //= require nvd3/src/models/line.js 35 | 36 | to your ```application.js``` 37 | 38 | ## Contribution Guide 39 | 40 | ### Updating Submodules 41 | 42 | The repository uses submodules following are the steps to manually get the submodules: 43 | 44 | git clone https://github.com/adeven/nvd3-rails.git 45 | cd nvd3-rails 46 | git submodule init 47 | git submodule update 48 | 49 | Or: 50 | 51 | git clone https://github.com/adeven/nvd3-rails.git 52 | cd nvd3-rails 53 | git submodule update --init 54 | 55 | Or: 56 | 57 | git clone --recursive https://github.com/adeven/nvd3-rails.git 58 | cd nvd3-rails 59 | 60 | 61 | If you want to work inside a submodule, it is possible, but first you need to checkout a branch: 62 | 63 | cd vendor/assets/javascripts/nvd3 64 | git checkout master 65 | 66 | After you've committed your changes to the submodule, you'll update the nvd3-rails project to point to the new commit, but remember to push the submodule changes before pushing the new nvd3-rails commit: 67 | 68 | cd vendor/assets/javascripts/nvd3 69 | git push origin master 70 | cd .. 71 | git add vendor/assets/javascripts/nvd3 72 | git commit 73 | 74 | ### cleaning 75 | 76 | If you want to purge your working directory back to the status of upstream, following commands can be used (remember everything you've worked on is gone after these): 77 | 78 | git reset --hard upstream/master 79 | git clean -fdx 80 | 81 | ### Using a local copy during development 82 | 83 | Nvd3-rails gets added as a Rails::Engine to your project. 84 | 85 | Generally during development you want your main application to include a local development copy of your engine. 86 | You should be able to add gem groups for each Rails environment to your Gemfile, like this: 87 | 88 | ```ruby 89 | group :development do 90 | gem "nvd3-rails", :path => "../nvd3-rails" 91 | end 92 | 93 | group :production do 94 | gem "nvd3-rails", :git => "git://github.com/adeven/nvd3-rails.git" 95 | end 96 | ``` 97 | 98 | In Bundler 1.1 and earlier, that generates this error message: "You cannot specify the same gem twice coming from different sources." 99 | This should be fixed in 1.2 https://github.com/carlhuda/bundler/issues/751 100 | 101 | There are several work arounds for this, however I sugest to update to the latest version of bundle. 102 | --------------------------------------------------------------------------------