Create static/js/chart.js
Browse files- app/static/js/chart.js +24 -0
app/static/js/chart.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
document.addEventListener("DOMContentLoaded", function () {
|
| 2 |
+
const ctx = document.getElementById('sentimentChart').getContext('2d');
|
| 3 |
+
const sentimentData = JSON.parse(document.getElementById('sentimentData').textContent);
|
| 4 |
+
|
| 5 |
+
new Chart(ctx, {
|
| 6 |
+
type: 'line',
|
| 7 |
+
data: {
|
| 8 |
+
labels: sentimentData.dates,
|
| 9 |
+
datasets: [{
|
| 10 |
+
label: 'Sentiment Trend',
|
| 11 |
+
data: sentimentData.scores,
|
| 12 |
+
borderColor: '#0073e6',
|
| 13 |
+
fill: false
|
| 14 |
+
}]
|
| 15 |
+
},
|
| 16 |
+
options: {
|
| 17 |
+
scales: {
|
| 18 |
+
y: {
|
| 19 |
+
beginAtZero: true
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
});
|
| 24 |
+
});
|