Skip to content

Instantly share code, notes, and snippets.

@rd13
Created June 3, 2013 15:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rd13/5698860 to your computer and use it in GitHub Desktop.
Save rd13/5698860 to your computer and use it in GitHub Desktop.
Rails / AngularJS / Chart.js - Line chart example directive
app = angular.module('Main', [])
app.directive("chart", ->
return (scope,element,attrs) ->
data =
labels: ["January", "February", "March", "April", "May", "June", "July"]
datasets: [
fillColor: "rgba(220,220,220,0.5)"
strokeColor: "rgba(220,220,220,1)"
pointColor: "rgba(220,220,220,1)"
pointStrokeColor: "#fff"
data: [65, 59, 90, 81, 56, 55, 40]
,
fillColor: "rgba(151,187,205,0.5)"
strokeColor: "rgba(151,187,205,1)"
pointColor: "rgba(151,187,205,1)"
pointStrokeColor: "#fff"
data: [28, 48, 40, 19, 96, 27, 100]
]
ctx = element[0].getContext("2d")
new Chart(ctx).Line(data)
)
gem 'angularjs-rails'
gem 'chart-js-rails'
<canvas width="600" height="400" chart></canvas>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment