NVD3 Rails - reusable charts for rails 3
To include nvd3-rails into your rails project add
gem "nvd3-rails", :git => "email@example.com:adeven/nvd3-rails.git", :submodules => true
To your Projects Gemfile.
//= require nvd3-rails
*= require nvd3-rails
Note as of today nvd3 clutters the model naming e.g. lineWithFisheyeChart.js and lineChart.js export their model both as lineChart. If you only need a subset of models e.g. lineChart you can add
//= require nvd3/lib/d3.v2 //= require nvd3/src/core //= require nvd3/src/tooltip //= require nvd3/src/utils.js //= require nvd3/src/models/lineChart //= require nvd3/src/models/legend.js //= require nvd3/src/models/axis.js //= require nvd3/src/models/scatter.js //= require nvd3/src/models/line.js
The repository uses submodules following are the steps to manually get the submodules:
git clone https://github.com/adeven/nvd3-rails.git cd nvd3-rails git submodule init git submodule update
git clone https://github.com/adeven/nvd3-rails.git cd nvd3-rails git submodule update --init
git clone --recursive https://github.com/adeven/nvd3-rails.git cd nvd3-rails
If you want to work inside a submodule, it is possible, but first you need to checkout a branch:
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:
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):
git reset --hard upstream/master git clean -fdx
Using a local copy during development
Nvd3-rails gets added as a Rails::Engine to your project.
Generally during development you want your main application to include a local development copy of your engine. You should be able to add gem groups for each Rails environment to your Gemfile, like this:
group :development do gem "nvd3-rails", :path => "../nvd3-rails" end group :production do gem "nvd3-rails", :git => "git://github.com/adeven/nvd3-rails.git" end
In Bundler 1.1 and earlier, that generates this error message: "You cannot specify the same gem twice coming from different sources." This should be fixed in 1.2 https://github.com/carlhuda/bundler/issues/751
There are several work arounds for this, however I sugest to update to the latest version of bundle.