-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
123 lines (113 loc) · 3.3 KB
/
scripts.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
$(document).ready(function(){
// console.log("Hello");
$.ajax({
url : "http://localhost/data_collection/get_data.php",
type : "GET",
success : function(data){
data = JSON.parse(data);
var userid = [];
var facebook_follower = [];
var twitter_follower = [];
var googleplus_follower = [];
for(var i in data) {
userid.push("UserID " + data[i].userid);
facebook_follower.push(data[i].facebook);
twitter_follower.push(data[i].twitter);
googleplus_follower.push(data[i].googleplus);
}
var chartdata = {
labels: userid,
datasets: [
{
label: "facebook",
fill: false,
lineTension: 0.1,
backgroundColor: "rgba(59, 89, 152, 0.75)",
borderColor: "rgba(59, 89, 152, 1)",
pointHoverBackgroundColor: "rgba(59, 89, 152, 1)",
pointHoverBorderColor: "rgba(59, 89, 152, 1)",
data: facebook_follower
},
{
label: "twitter",
fill: false,
lineTension: 0.1,
backgroundColor: "rgba(29, 202, 255, 0.75)",
borderColor: "rgba(29, 202, 255, 1)",
pointHoverBackgroundColor: "rgba(29, 202, 255, 1)",
pointHoverBorderColor: "rgba(29, 202, 255, 1)",
data: twitter_follower
},
{
label: "googleplus",
fill: false,
lineTension: 0.1,
backgroundColor: "rgba(211, 72, 54, 0.75)",
borderColor: "rgba(211, 72, 54, 1)",
pointHoverBackgroundColor: "rgba(211, 72, 54, 1)",
pointHoverBorderColor: "rgba(211, 72, 54, 1)",
data: googleplus_follower
}
]
};
var ctx = $("#mycanvas");
var LineGraph = new Chart(ctx, {
type: 'line',
data: chartdata
});
},
error : function(data) {
}
});
});
// var svgWidth = 500;
// var svgHeight = 300;
//
// var svg = d3.select('svg')
// .attr("width", svgWidth)
// .attr("height", svgHeight)
// .attr("class", "bar-chart");
//
// var dataset = [80, 100, 56, 120, 180, 30, 40, 120, 160];
//
// var barPadding = 5;
// var barWidth = (svgWidth / dataset.length);
//
// var barChart = svg.selectAll("rect")
// .data(dataset)
// .enter()
// .append("rect")
// .attr("y", function(d) {
// return svgHeight - d
// })
// .attr("height", function(d) {
// return d;
// })
// .attr("width", barWidth - barPadding)
// .attr("transform", function (d, i) {
// var translate = [barWidth * i, 0];
// return "translate("+ translate +")";
// });
// /////////////////////////////////
//
// chart = {
// const svg = d3.create("svg")
// .attr("viewBox", [0, 0, width, height]);
//
// svg.append("g")
// .call(xAxis);
//
// svg.append("g")
// .call(yAxis);
//
// svg.append("path")
// .datum(data)
// .attr("fill", "none")
// .attr("stroke", "steelblue")
// .attr("stroke-width", 1.5)
// .attr("stroke-linejoin", "round")
// .attr("stroke-linecap", "round")
// .attr("d", line);
//
// return svg.node();
// }