-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcryptosent-embed.html
More file actions
94 lines (89 loc) · 3.52 KB
/
cryptosent-embed.html
File metadata and controls
94 lines (89 loc) · 3.52 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CryptoSent Chart</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns"></script>
<script src="https://cdn.jsdelivr.net/npm/papaparse@5.4.1/papaparse.min.js"></script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
background: #ffffff;
padding: 15px;
}
.chart-wrapper {
position: relative;
height: 280px;
}
.loading {
text-align: center;
padding: 50px;
color: #57606a;
}
</style>
</head>
<body>
<div id="loading" class="loading">Loading...</div>
<div id="content" style="display: none;">
<div class="chart-wrapper">
<canvas id="sentimentChart"></canvas>
</div>
</div>
<script>
const CSV_URL = 'https://raw.githubusercontent.com/ronming1303/CryptoSent_Pipeline/master/data/processed/cryptosent.csv';
async function init() {
try {
const response = await fetch(CSV_URL);
const csvText = await response.text();
const result = Papa.parse(csvText, { header: true, dynamicTyping: true, skipEmptyLines: true });
// Filter to last 6 months
const sixMonthsAgo = new Date();
sixMonthsAgo.setMonth(sixMonthsAgo.getMonth() - 6);
const data = result.data.filter(d => new Date(d.date) >= sixMonthsAgo);
document.getElementById('loading').style.display = 'none';
document.getElementById('content').style.display = 'block';
new Chart(document.getElementById('sentimentChart'), {
type: 'line',
data: {
labels: data.map(d => d.date),
datasets: [{
label: 'CryptoSent',
data: data.map(d => ({ x: d.date, y: d.CryptoSent })),
borderColor: '#0969da',
backgroundColor: 'rgba(9, 105, 218, 0.1)',
fill: true,
tension: 0.3,
pointRadius: 0
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: false }
},
scales: {
x: {
type: 'time',
time: { unit: 'month' },
ticks: { color: '#57606a' },
grid: { color: '#d0d7de' }
},
y: {
ticks: { color: '#57606a' },
grid: { color: '#d0d7de' }
}
}
}
});
} catch (error) {
document.getElementById('loading').textContent = 'Failed to load data';
}
}
init();
</script>
</body>
</html>