-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplineCharts.js
More file actions
98 lines (81 loc) · 1.96 KB
/
splineCharts.js
File metadata and controls
98 lines (81 loc) · 1.96 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//https://cdn.rawgit.com/ZNClub-PA-ML-AI/Sentiment-analysis-using-Business-News/95e16a9b/REL_score_open.json
/*
Spline Chart
Highcharts | TODO
*/
// $.getJSON('https://cdn.rawgit.com/ZNClub-PA-ML-AI/Sentiment-analysis-using-Business-News/95e16a9b/REL_score_open.json', function(data) {
$.getJSON('https://raw.githubusercontent.com/ZNClub-PA-ML-AI/Sentiment-analysis-using-Business-News/master/data/json/NSE-REL.json',
function(data) {
var map = data.score;
var response=[];
for (var key in map) {
if (map.hasOwnProperty(key)) {
//console.log(key + " -> " + map[key]);
//split date ie key
var dates = key.split('-');
if(dates[0]=='2015'){
console.log("2015");
continue;
}
//adjust month
var m = dates[1];
m = parseInt(m) - 1;
m = m.toString()
if (m.length == 1) {
m = "0" + m;
}
var dateUTC = Date.UTC(dates[0],m,dates[2]);
var score = map[key];
var temp=[dateUTC,score];
//console.log(temp);
response.push(temp);
}
}
console.log(response);
Highcharts.chart('spline-container-1', {
chart: {
type: 'spline',
zoomType: 'x'
},
title: {
text: 'Market News Sentimental Graph'
},
subtitle: {
text: 'Sentiment-analysis-using-Business-News'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { // don't display the dummy year
month: '%e. %b',
year: '%b'
},
title: {
text: 'Months'
}
},
yAxis: {
title: {
text: 'Sentimental Score'
},
min: -0.30
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: '{point.x:%e. %b}: {point.y:.3f} value'
},
plotOptions: {
spline: {
marker: {
enabled: true
}
}
},
series: [{
name: 'RELIANCE',
// Define the data points. All series have a dummy year
// of 1970/71 in order to be compared on the same x axis. Note
// that in JavaScript, months start at 0 for January, 1 for February etc.
data: response
}]
});
});