2022-07-21 12:50:51 +00:00
|
|
|
function loadJson(selector) {
|
|
|
|
return JSON.parse(document.querySelector(selector).getAttribute('data-json'));
|
2022-07-21 12:51:01 +00:00
|
|
|
}
|
2022-07-21 12:50:51 +00:00
|
|
|
var jsonData = loadJson('#jsonData');
|
2022-07-21 12:51:01 +00:00
|
|
|
var full_data = jsonData.map((item) => item);
|
2022-07-21 12:50:51 +00:00
|
|
|
|
2022-08-27 17:14:52 +00:00
|
|
|
var ctx = document.getElementById('sentiment-chart').getContext("2d");
|
2022-07-21 12:51:01 +00:00
|
|
|
new Chart(ctx, {
|
|
|
|
type: 'line',
|
|
|
|
data: {
|
2022-07-21 12:50:51 +00:00
|
|
|
datasets: [
|
2022-07-21 12:51:01 +00:00
|
|
|
{
|
|
|
|
label: "Sentiment",
|
|
|
|
fill: false,
|
2022-07-21 12:50:51 +00:00
|
|
|
backgroundColor: 'black',
|
|
|
|
borderColor: 'lightblue',
|
2022-07-21 12:51:01 +00:00
|
|
|
tension: 0.3,
|
|
|
|
data: full_data,
|
|
|
|
spanGaps: true,
|
|
|
|
}
|
|
|
|
],
|
|
|
|
},
|
|
|
|
options: {
|
2022-07-21 12:51:22 +00:00
|
|
|
responsive: true,
|
|
|
|
maintainAspectRatio: false,
|
2022-07-21 12:51:01 +00:00
|
|
|
parsing: {
|
|
|
|
xAxisKey: 'date',
|
|
|
|
yAxisKey: 'value',
|
2022-07-21 12:50:51 +00:00
|
|
|
},
|
2022-07-21 12:51:01 +00:00
|
|
|
plugins: {
|
|
|
|
tooltip: {
|
|
|
|
callbacks: {
|
|
|
|
footer: function(context) {
|
2022-08-27 16:47:33 +00:00
|
|
|
var foot = "Text: " + full_data[context[0].dataIndex].text + "\n";
|
|
|
|
foot += "Nick: " + full_data[context[0].dataIndex].nick + "\n";
|
|
|
|
foot += "Channel: " + full_data[context[0].dataIndex].channel + "\n";
|
|
|
|
foot += "Net: " + full_data[context[0].dataIndex].net;
|
|
|
|
return foot;
|
2022-07-21 12:51:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-21 12:50:51 +00:00
|
|
|
}
|
2022-07-21 12:51:01 +00:00
|
|
|
}
|
|
|
|
});
|