Skip to content

Commit 314a6d7

Browse files
committed
Update README.md
1 parent 807f290 commit 314a6d7

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2121
//= 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{:style => "height:450; width:600;"}
55+
56+
57+
Visit: http://www.chartjs.org/docs/ for more Chart.js usage

0 commit comments

Comments
 (0)