Skip to content

Instantly share code, notes, and snippets.

@altilunium
Created November 20, 2022 05:52
Show Gist options
  • Save altilunium/46334cf6d2a5d7e4676e637e16c7459a to your computer and use it in GitHub Desktop.
Save altilunium/46334cf6d2a5d7e4676e637e16c7459a to your computer and use it in GitHub Desktop.
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="nyaa"></div>
</body>
<script src="https://cdn.plot.ly/plotly-2.16.1.min.js"></script>
<script type='text/javascript' src='tweets.js'></script>
<script>
var hours = []
function blah(i){
var t = i.tweet.created_at
t = t.split(" ")
t = t[3].split(":")
hours.push(t[0])
}
nya.forEach(blah)
console.log(hours)
let counter = {};
for (element of hours.flat()) {
if (counter[element]) {
counter[element] += 1;
} else {
counter[element] = 1;
}
};
console.log(counter);
var items = Object.keys(counter).map(function(key) {
return [key, counter[key]];
});
items.forEach(function(i){
i[0] = (parseInt(i[0]) + 7) % 24
console.log(i)
})
items.sort(function(first, second) {
return first[0] - second[0];
});
console.log(items)
var x = []
var y = []
items.forEach(function(i){
x.push(i[0])
y.push(i[1])
})
var data = [
{
x: x,
y: y,
type: 'bar'
}
];
var layout = {
xaxis: {showticklabels:true,type:'category'},
}
Plotly.newPlot('nyaa', data,layout);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment