Project

bitcharts

0.0
No release in over 3 years
Low commit activity in last 3 years
Solid chart framework to use Chart.js with Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3

Runtime

 Project Readme

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.