Use the rgraph chart/graph library with the Rails asset pipeline.
Installation
Include the gem in your application's Gemfile:
gem 'rgraph-rails', '~> 6.14'
And then execute:
$ bundle
Usage
In your application.js
, include the core RGraph file
//= require RGraph.common.core
Just below that, include one or more graph types you'd like to use. For example:
//= require RGraph.hprogress.js
Then add a simple graph
// example.coffee
$(window).load ->
hprogress = new RGraph.HProgress({
id: 'cvs',
min: 50,
max: 100,
value: 85
}).draw()
And finally the canvas that will contain the graph
# example.html.haml
%canvas#cvs{:height => "100", :width => "600"}
[No canvas support]
For detailed documentation concerning the types of graphs/charts and all other available options, please see the official docs.
Run locally
After checking out the repo, run bin/setup
to install dependencies. Then, run bundle exec rspec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
Versioning
rgraph itself doesn't use semantic versioning (and therefore neither does this gem; it keeps the same version as the library so that it's less confusing) - you can find out about breaking changes by release on the Backwards Compatibility section on the official site.
Issues
If your query concerns the library itself, see the official support forum. If it is about this gem in particular, raise an issue.
Contributing
Bug reports and pull requests are welcome. Contributors are expected to adhere to the Contributor Covenant code of conduct.
License
MIT