-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
55 lines (34 loc) · 1.17 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Created by Happy on 28/03/17.
*/
(function(){
var app = angular.module('app', []);
app.controller('loanCtrl', function($scope) {
$scope.loanAmount = 0;
$scope.interest=0;
$scope.repay=0;
$scope.showGraph = false;
$scope.submitForm = function() {
// check to make sure the form is completely valid
if ($scope.userForm.$valid) {
var c = document.getElementById("graphAreaCanvas");
var ctx = c.getContext("2d");
ctx.translate(10,200);
ctx.font = "20px Arial";
var height1 = 200;
ctx.rect( 0, 0, 80, height1);
ctx.fillStyle = "red";
ctx.fill();
var height = 250 - ($scope.interest/200)*100;
ctx.beginPath();
ctx.rect(100, 0, 80, $scope.interest);
ctx.fill();
ctx.textAlign = "center";
ctx.fillText("Interest",80, height*1.1);
ctx.fillStyle = "blue";
ctx.fill();
$scope.showGraph =true;
}
};
});
})();