-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhelpers.js
More file actions
83 lines (81 loc) · 2.24 KB
/
helpers.js
File metadata and controls
83 lines (81 loc) · 2.24 KB
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
var dataRef = new Firebase("https://scorching-fire-1875.firebaseio.com/");
dataRef.limit(20).on("child_added", importFromFirebase);
function importFromFirebase(snapshot){
analyzeSentimentValue(snapshot.val());
};
// Highcharts spline handler
$(function () {
$(document).ready(function() {
Highcharts.setOptions({
global: {
useUTC: false
}
});
var chart;
$('#spline').highcharts({
chart: {
type: 'spline',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
load: function() {
var series = this.series[0];
setInterval(function() {
var x = (new Date()).getTime(), // current time
y = metrics.positivePerSecond-metrics.negativePerSecond;
series.addPoint([x, y], true, true);
}, 3000);
}
}
},
title: {
text: 'Twitter Sentiment Analysis'
},
xAxis: {
title: {
text: 'Time',
},
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Sentiment Rate'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
Highcharts.numberFormat(this.y, 2);
}
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'Sentiment Rate',
data: (function() {
var data = [],
time = (new Date()).getTime(),
i;
for (i = -10; i <= 0; i++) {
data.push({
x: time + i * 1000,
y: 0
});
}
return data;
})()
}]
});
});
});