Bitcharts¶ ↑
Usage¶ ↑
Mount Engine in routes.rb
¶ ↑
mount Bitcharts::Engine => "/bitcharts"
Generate a chart¶ ↑
rails g bitcharts:chart user_logins # or a scoped chart: rails g bitcharts:scoped_chart user_logins
Implement chart’s value method ¶ ↑
Change the generated method in app/charts/user_logins_chart.rb
:
def value(date_range) User::Login.where(created_at: date_range).count end
Add canvas to your view¶ ↑
<%= bitchart 'user_logins', from: 7.days.ago, to: Date.today %>
Check Bitcharts::ApplicationHelper
for all available options.
Add Javascript¶ ↑
Require Javascript in your applications Javascript or load it dynamically in your view when needed:
<%= javascript_include_tag 'bitcharts/default' %>
If you don’t use jQuery already use bitcharts/full
instead.
Authorization¶ ↑
rails g bitcharts:install
This generates an initializer that shows you how to authorize with CanCan(Can) based on the chart’s class name. Adopt it as needed.