Skip to content

Commit 713efa2

Browse files
author
Keith Walsh
committed
2 parents 4abf0d3 + a824082 commit 713efa2

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Chart.Js for Rails
1+
# Chart.js for Rails
22

33
Integrate Chart.js into Rails Asset Pipeline
44

@@ -16,10 +16,42 @@ Or install it yourself as:
1616

1717
$ gem install chart-js-rails
1818

19-
In your application.js file, add
19+
Add this to your application.js file:
2020

21-
//= require chart
21+
//= require chart
2222

2323
## Usage
2424

25-
Visit: http://www.chartjs.org/docs/ for general Chart.js usage
25+
Example Line Chart (coffeescript/haml):
26+
27+
app.js.coffee:
28+
29+
jQuery ->
30+
data = {
31+
labels : ["January","February","March","April","May","June","July"],
32+
datasets : [
33+
{
34+
fillColor : "rgba(220,220,220,0.5)",
35+
strokeColor : "rgba(220,220,220,1)",
36+
pointColor : "rgba(220,220,220,1)",
37+
pointStrokeColor : "#fff",
38+
data : [65,59,90,81,56,55,40]
39+
},
40+
{
41+
fillColor : "rgba(151,187,205,0.5)",
42+
strokeColor : "rgba(151,187,205,1)",
43+
pointColor : "rgba(151,187,205,1)",
44+
pointStrokeColor : "#fff",
45+
data : [28,48,40,19,96,27,100]
46+
}
47+
]
48+
}
49+
50+
myNewChart = new Chart($("#canvas").get(0).getContext("2d")).Line(data)
51+
52+
index.haml.html:
53+
54+
%canvas#canvas{:height => "450", :width => "600"}
55+
56+
57+
Visit: http://www.chartjs.org/docs/ for more Chart.js usage

0 commit comments

Comments
 (0)