-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustCityChart.js
76 lines (63 loc) · 1.5 KB
/
custCityChart.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
75
$(document).ready(function() {
/**
* call the data.php file to fetch the result from db table.
*/
$.ajax({
url : "http://localhost/retail_enterprise/custCitydata.php",
type : "GET",
success : function(data){
console.log(data);
console.log("success");
var dataP = {
Id : [],
City : [],
countOfCustomers: [],
};
var len = data.length;
for (var i = 0; i < len; i++) {
dataP.Id.push((i+1));
dataP.City.push(data[i].address);
dataP.countOfCustomers.push(data[i].custCount);
}
//get canvas
var ctx = $("#line-cityCust");
var data = {
labels : dataP.City,
datasets : [
{
label : "City",
data : dataP.countOfCustomers,
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 fucking.");
console.log(data);
}
}
);
});