-
Notifications
You must be signed in to change notification settings - Fork 0
/
line-db-php.js
75 lines (60 loc) · 1.44 KB
/
line-db-php.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
$(document).ready(function() {
/**
* call the data.php file to fetch the result from db table.
*/
$.ajax({
url : "http://localhost/retail_enterprise/sales_data.php",
type : "GET",
success : function(data){
console.log(data);
console.log("success");
var score = {
Sales : [],
Customer: [],
};
var len = data.length;
for (var i = 0; i < len; i++) {
score.Sales.push(data[i].transaction_amount);
score.Customer.push(data[i].customer_id);
}
//get canvas
var ctx = $("#line-chartcanvas");
var data = {
labels : score.Customer,
datasets : [
{
label : "Sales",
data : score.Sales,
backgroundColor : "blue",
borderColor : "lightblue",
fill : false,
lineTension : 0,
pointRadius : 5
},
]
};
var options = {
title : {
display : true,
position : "top",
text : "Line Graph",
fontSize : 18,
fontColor : "#111"
},
legend : {
display : true,
position : "bottom"
}
};
var chart = new Chart( ctx, {
type : "line",
data : data,
options : options
} );
},
error : function(data) {
console.log("error");
console.log(data);
}
});
});