Angular 1.5 Two-Way Binding
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-chart.js/1.0.0-alpha8/angular-chart.js"></script>
<div ng-app="myApp" ng-controller="mainController">
<canvas id="bar" class="chart chart-bar"
chart-data="data" chart-labels="labels" chart-series="series" chart-colors="colors" chart-options="options"></canvas>
</div>
JavaScript
var app = angular.module('myApp', ["chart.js"]);
app.controller('mainController', function($scope) {
$scope.labels = ['sun', 'moon', 'mars', 'venus'];
$scope.series = ['sun', 'moon', 'mars', 'venus'];
$scope.data = [
[20, 0, 0, 0],
[0, 10, 0, 0],
[0, 0, 40, 0],
[0, 0, 0, 30]
];
$scope.colors = [
{
backgroundColor: '#645',
borderWidth: 0
},
{
backgroundColor: '#E64',
borderWidth: 0
},
{
backgroundColor: '#97F',
borderWidth: 0
},
{
backgroundColor: '#24D',
borderWidth: 0
}
];
$scope.options = {
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
if(tooltipItem.yLabel) {
return ' ' + tooltipItem.yLabel
}
}
}
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
}
}],
xAxes: [{
stacked:true,
}]
}
};
});