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-07-21 12:51:01 +00:00
|
|
|
var ctx = document.getElementById('volume').getContext("2d");
|
|
|
|
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: {
|
|
|
|
parsing: {
|
|
|
|
xAxisKey: 'date',
|
|
|
|
yAxisKey: 'value',
|
2022-07-21 12:50:51 +00:00
|
|
|
},
|
2022-07-21 12:51:01 +00:00
|
|
|
plugins: {
|
|
|
|
tooltip: {
|
|
|
|
callbacks: {
|
|
|
|
beforeFooter: function(context) {
|
|
|
|
return "Nick: " + full_data[context[0].dataIndex].nick;
|
|
|
|
},
|
|
|
|
footer: function(context) {
|
|
|
|
return "Msg: " + full_data[context[0].dataIndex].text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-21 12:50:51 +00:00
|
|
|
}
|
2022-07-21 12:51:01 +00:00
|
|
|
}
|
|
|
|
});
|