@@ -16,10 +16,42 @@ Or install it yourself as:
16
16
17
17
$ gem install chart-js-rails
18
18
19
- In your application.js file, add
19
+ Add this to your application.js file:
20
20
21
21
//= require chart
22
22
23
23
## Usage
24
24
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