Skip to content

Instantly share code, notes, and snippets.

@FOLLGAD
Last active May 10, 2021 06:33
Show Gist options
  • Select an option

  • Save FOLLGAD/6c821b174f38d932e6ef0bb1d78900ad to your computer and use it in GitHub Desktop.

Select an option

Save FOLLGAD/6c821b174f38d932e6ef0bb1d78900ad to your computer and use it in GitHub Desktop.
Scrape planetminecraft total player count to get an overview of when most people are active to time server updates
// get the stat count from planetminecraft.com
const cheerio = require("cheerio")
const fetch = require("node-fetch")
const fs = require("fs")
const getTheStat = () => {
fetch("https://www.planetminecraft.com/resources/servers/")
.then(res => res.text())
.then(html => {
let planet = cheerio.load(html),
players = planet(".statistics > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(1) > span:nth-child(1)").text().replace(",", "")
const data = require("./data.json")
data.times.push({
players: parseInt(players),
timestamp: new Date()
})
fs.writeFile("./data.json", JSON.stringify(data), err => {
if (err) {
console.error(err)
} else {
console.log("Successfully fetched and wrote")
}
})
})
}
getTheStat()
setInterval(getTheStat, 5*60*1000) // five minutes
<!DOCTYPE html>
<html>
<body>
<canvas id="myChart"></canvas>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.bundle.min.js"></script>
<script>
let chart
function newChart(data, min, max) {
if (chart) chart.destroy()
let ctx = document.getElementById("myChart").getContext('2d');
chart = new Chart(ctx, {
type: 'line',
data: {
datasets: [{
label: '# of Players',
data: data,
}]
},
options: {
scales: {
xAxes: [{
type: 'time',
time: {
displayFormats: {
'millisecond': 'HH:mm',
'second': 'HH:mm',
'minute': 'HH:mm',
'hour': 'ddd HH:mm',
'day': 'DD HH:mm',
'week': 'YYYY MM DD HH:mm',
'month': 'YYYY MM DD HH:mm',
'year': 'YYYY MM DD HH:mm',
},
max,
min
}
}]
},
tooltips: {
mode: 'x'
}
}
});
}
loop()
function loop() {
let data = {"times":[{"players":6803,"timestamp":"2019-02-22T18:15:18.523Z"},{"players":6698,"timestamp":"2019-02-22T18:20:19.046Z"},{"players":6716,"timestamp":"2019-02-22T18:25:18.370Z"},{"players":6761,"timestamp":"2019-02-22T18:30:18.482Z"},{"players":6818,"timestamp":"2019-02-22T18:35:19.151Z"},{"players":6864,"timestamp":"2019-02-22T18:38:50.113Z"},{"players":6895,"timestamp":"2019-02-22T18:43:49.351Z"},{"players":6872,"timestamp":"2019-02-22T18:46:09.806Z"},{"players":6865,"timestamp":"2019-02-22T18:51:10.557Z"},{"players":6817,"timestamp":"2019-02-22T18:56:09.742Z"},{"players":6857,"timestamp":"2019-02-22T19:01:09.914Z"},{"players":6868,"timestamp":"2019-02-22T19:06:09.762Z"},{"players":6829,"timestamp":"2019-02-22T19:11:09.790Z"},{"players":6770,"timestamp":"2019-02-22T19:16:09.972Z"},{"players":6703,"timestamp":"2019-02-22T19:21:09.766Z"},{"players":6729,"timestamp":"2019-02-22T19:26:09.922Z"},{"players":6737,"timestamp":"2019-02-22T19:31:09.736Z"},{"players":6729,"timestamp":"2019-02-22T19:36:09.742Z"},{"players":6756,"timestamp":"2019-02-22T19:41:10.517Z"},{"players":6679,"timestamp":"2019-02-22T19:46:09.803Z"},{"players":6702,"timestamp":"2019-02-22T19:51:09.865Z"},{"players":6725,"timestamp":"2019-02-22T19:56:09.646Z"},{"players":6802,"timestamp":"2019-02-22T20:01:09.743Z"},{"players":6870,"timestamp":"2019-02-22T20:06:09.640Z"},{"players":6906,"timestamp":"2019-02-22T20:11:09.788Z"},{"players":6947,"timestamp":"2019-02-22T20:16:09.781Z"},{"players":6978,"timestamp":"2019-02-22T20:21:09.850Z"},{"players":6977,"timestamp":"2019-02-22T20:26:09.962Z"},{"players":6954,"timestamp":"2019-02-22T20:31:09.823Z"},{"players":6924,"timestamp":"2019-02-22T20:36:09.766Z"},{"players":6899,"timestamp":"2019-02-22T20:41:09.800Z"},{"players":6956,"timestamp":"2019-02-22T20:46:09.865Z"},{"players":6949,"timestamp":"2019-02-22T20:51:09.785Z"},{"players":6998,"timestamp":"2019-02-22T20:56:09.821Z"},{"players":6988,"timestamp":"2019-02-22T21:01:09.777Z"},{"players":7025,"timestamp":"2019-02-22T21:06:09.786Z"},{"players":6918,"timestamp":"2019-02-22T21:11:09.794Z"},{"players":6937,"timestamp":"2019-02-22T21:16:09.926Z"},{"players":6901,"timestamp":"2019-02-22T21:21:10.511Z"},{"players":6996,"timestamp":"2019-02-22T21:26:09.810Z"},{"players":7040,"timestamp":"2019-02-22T21:31:09.813Z"},{"players":7046,"timestamp":"2019-02-22T21:36:09.944Z"},{"players":7055,"timestamp":"2019-02-22T21:41:09.796Z"},{"players":7039,"timestamp":"2019-02-22T21:46:09.821Z"},{"players":7142,"timestamp":"2019-02-22T21:51:09.762Z"},{"players":7089,"timestamp":"2019-02-22T21:56:09.796Z"},{"players":7138,"timestamp":"2019-02-22T22:01:09.815Z"},{"players":7121,"timestamp":"2019-02-22T22:06:09.815Z"},{"players":7151,"timestamp":"2019-02-22T22:11:09.812Z"},{"players":7127,"timestamp":"2019-02-22T22:16:09.818Z"},{"players":7046,"timestamp":"2019-02-22T22:21:10.004Z"},{"players":7078,"timestamp":"2019-02-22T22:26:09.876Z"},{"players":7103,"timestamp":"2019-02-22T22:31:10.481Z"},{"players":7095,"timestamp":"2019-02-22T22:36:10.510Z"},{"players":7250,"timestamp":"2019-02-22T22:41:10.479Z"},{"players":7286,"timestamp":"2019-02-22T22:46:09.993Z"},{"players":7260,"timestamp":"2019-02-22T22:51:09.806Z"},{"players":7313,"timestamp":"2019-02-22T22:56:09.843Z"},{"players":7388,"timestamp":"2019-02-22T23:01:10.648Z"},{"players":7436,"timestamp":"2019-02-22T23:06:09.814Z"},{"players":7412,"timestamp":"2019-02-22T23:11:09.790Z"},{"players":7360,"timestamp":"2019-02-22T23:16:09.826Z"},{"players":7277,"timestamp":"2019-02-22T23:21:09.856Z"},{"players":7200,"timestamp":"2019-02-22T23:26:09.881Z"},{"players":7141,"timestamp":"2019-02-22T23:31:09.825Z"},{"players":7215,"timestamp":"2019-02-22T23:36:10.548Z"},{"players":7116,"timestamp":"2019-02-22T23:41:09.802Z"},{"players":7175,"timestamp":"2019-02-22T23:46:09.864Z"},{"players":7098,"timestamp":"2019-02-22T23:51:09.850Z"},{"players":7086,"timestamp":"2019-02-22T23:56:09.799Z"},{"players":7096,"timestamp":"2019-02-23T00:01:12.513Z"},{"players":6176,"timestamp":"2019-02-23T09:39:38.620Z"},{"players":6133,"timestamp":"2019-02-23T09:44:38.711Z"},{"players":6135,"timestamp":"2019-02-23T09:49:38.542Z"},{"players":6182,"timestamp":"2019-02-23T09:54:38.558Z"},{"players":6222,"timestamp":"2019-02-23T09:59:39.323Z"},{"players":6280,"timestamp":"2019-02-23T10:04:38.507Z"},{"players":6302,"timestamp":"2019-02-23T10:09:38.547Z"},{"players":6382,"timestamp":"2019-02-23T10:14:38.582Z"},{"players":6384,"timestamp":"2019-02-23T10:19:38.732Z"},{"players":6424,"timestamp":"2019-02-23T10:24:38.508Z"},{"players":6437,"timestamp":"2019-02-23T10:29:38.675Z"},{"players":6406,"timestamp":"2019-02-23T10:34:38.554Z"},{"players":6416,"timestamp":"2019-02-23T10:39:38.564Z"},{"players":6439,"timestamp":"2019-02-23T10:44:38.556Z"},{"players":6462,"timestamp":"2019-02-23T10:49:39.338Z"},{"players":6503,"timestamp":"2019-02-23T10:54:39.295Z"},{"players":6480,"timestamp":"2019-02-23T10:59:39.244Z"},{"players":6467,"timestamp":"2019-02-23T11:04:38.700Z"},{"players":6472,"timestamp":"2019-02-23T11:09:38.506Z"},{"players":6478,"timestamp":"2019-02-23T11:14:38.550Z"},{"players":6501,"timestamp":"2019-02-23T11:19:38.538Z"},{"players":6488,"timestamp":"2019-02-23T11:24:38.599Z"},{"players":6526,"timestamp":"2019-02-23T11:29:39.207Z"},{"players":6501,"timestamp":"2019-02-23T11:34:38.551Z"},{"players":6630,"timestamp":"2019-02-23T11:39:38.507Z"},{"players":6651,"timestamp":"2019-02-23T11:44:38.611Z"},{"players":6700,"timestamp":"2019-02-23T11:49:38.519Z"},{"players":6735,"timestamp":"2019-02-23T11:54:38.542Z"},{"players":6869,"timestamp":"2019-02-23T11:59:38.558Z"},{"players":6981,"timestamp":"2019-02-23T12:04:38.572Z"},{"players":7059,"timestamp":"2019-02-23T12:09:38.543Z"},{"players":7146,"timestamp":"2019-02-23T12:14:38.683Z"},{"players":7124,"timestamp":"2019-02-23T12:19:38.625Z"},{"players":7183,"timestamp":"2019-02-23T12:24:39.279Z"},{"players":7263,"timestamp":"2019-02-23T12:29:39.305Z"},{"players":7236,"timestamp":"2019-02-23T12:34:38.596Z"},{"players":7252,"timestamp":"2019-02-23T12:39:38.540Z"},{"players":7270,"timestamp":"2019-02-23T12:44:38.677Z"},{"players":7267,"timestamp":"2019-02-23T12:49:39.234Z"},{"players":7340,"timestamp":"2019-02-23T12:54:39.422Z"},{"players":7409,"timestamp":"2019-02-23T12:59:38.724Z"},{"players":7332,"timestamp":"2019-02-23T13:04:38.397Z"},{"players":7428,"timestamp":"2019-02-23T13:09:38.556Z"},{"players":7391,"timestamp":"2019-02-23T13:14:38.543Z"},{"players":7493,"timestamp":"2019-02-23T13:19:38.617Z"},{"players":7473,"timestamp":"2019-02-23T13:24:38.513Z"},{"players":7498,"timestamp":"2019-02-23T13:29:38.563Z"},{"players":7524,"timestamp":"2019-02-23T13:34:38.510Z"},{"players":7457,"timestamp":"2019-02-23T13:39:39.332Z"},{"players":7443,"timestamp":"2019-02-23T13:44:38.785Z"},{"players":7487,"timestamp":"2019-02-23T13:49:38.727Z"},{"players":7594,"timestamp":"2019-02-23T13:54:39.058Z"},{"players":7668,"timestamp":"2019-02-23T13:59:38.591Z"},{"players":7667,"timestamp":"2019-02-23T14:04:38.628Z"},{"players":7794,"timestamp":"2019-02-23T14:09:39.284Z"},{"players":7757,"timestamp":"2019-02-23T14:14:38.595Z"},{"players":7788,"timestamp":"2019-02-23T14:19:38.528Z"},{"players":7807,"timestamp":"2019-02-23T14:24:38.721Z"},{"players":7765,"timestamp":"2019-02-23T14:29:38.547Z"},{"players":7573,"timestamp":"2019-02-23T14:34:39.320Z"},{"players":7430,"timestamp":"2019-02-23T14:39:38.530Z"},{"players":7496,"timestamp":"2019-02-23T14:44:38.572Z"},{"players":7472,"timestamp":"2019-02-23T14:49:38.516Z"},{"players":7536,"timestamp":"2019-02-23T14:54:38.661Z"},{"players":7758,"timestamp":"2019-02-23T14:59:38.591Z"},{"players":7841,"timestamp":"2019-02-23T15:04:38.657Z"},{"players":7867,"timestamp":"2019-02-23T15:09:38.688Z"},{"players":7945,"timestamp":"2019-02-23T15:14:38.634Z"},{"players":7966,"timestamp":"2019-02-23T15:19:38.607Z"},{"players":8049,"timestamp":"2019-02-23T15:24:38.698Z"},{"players":8077,"timestamp":"2019-02-23T15:29:38.532Z"},{"players":8109,"timestamp":"2019-02-23T15:34:38.677Z"},{"players":8100,"timestamp":"2019-02-23T15:39:38.543Z"},{"players":8121,"timestamp":"2019-02-23T15:44:38.712Z"},{"players":8141,"timestamp":"2019-02-23T15:49:38.661Z"},{"players":8169,"timestamp":"2019-02-23T15:54:39.329Z"},{"players":8195,"timestamp":"2019-02-23T15:59:38.648Z"},{"players":8171,"timestamp":"2019-02-23T16:04:38.601Z"},{"players":8243,"timestamp":"2019-02-23T16:09:38.557Z"},{"players":8306,"timestamp":"2019-02-23T16:14:38.719Z"},{"players":8284,"timestamp":"2019-02-23T16:19:38.573Z"},{"players":8391,"timestamp":"2019-02-23T16:24:38.636Z"},{"players":8408,"timestamp":"2019-02-23T16:29:39.086Z"},{"players":8422,"timestamp":"2019-02-23T16:34:38.787Z"},{"players":8443,"timestamp":"2019-02-23T16:39:38.687Z"},{"players":8500,"timestamp":"2019-02-23T16:44:38.571Z"},{"players":8477,"timestamp":"2019-02-23T16:49:38.682Z"},{"players":8431,"timestamp":"2019-02-23T16:54:38.649Z"},{"players":8505,"timestamp":"2019-02-23T16:59:38.652Z"},{"players":8553,"timestamp":"2019-02-23T17:04:38.564Z"},{"players":8557,"timestamp":"2019-02-23T17:09:38.622Z"},{"players":8519,"timestamp":"2019-02-23T17:14:38.600Z"},{"players":8568,"timestamp":"2019-02-23T17:19:38.578Z"},{"players":8478,"timestamp":"2019-02-23T17:24:39.297Z"},{"players":8447,"timestamp":"2019-02-23T17:29:38.736Z"},{"players":8451,"timestamp":"2019-02-23T17:34:38.623Z"},{"players":8490,"timestamp":"2019-02-23T17:39:38.549Z"},{"players":8479,"timestamp":"2019-02-23T17:44:38.591Z"},{"players":8511,"timestamp":"2019-02-23T17:49:38.667Z"},{"players":8496,"timestamp":"2019-02-23T17:54:38.603Z"},{"players":8567,"timestamp":"2019-02-23T17:59:38.667Z"},{"players":8654,"timestamp":"2019-02-23T18:04:38.569Z"},{"players":8672,"timestamp":"2019-02-23T18:09:38.755Z"},{"players":8652,"timestamp":"2019-02-23T18:14:38.858Z"},{"players":8584,"timestamp":"2019-02-23T18:19:38.670Z"},{"players":8541,"timestamp":"2019-02-23T18:24:38.840Z"},{"players":8655,"timestamp":"2019-02-23T18:29:38.684Z"},{"players":8714,"timestamp":"2019-02-23T18:34:38.879Z"},{"players":8762,"timestamp":"2019-02-23T18:39:39.467Z"},{"players":8708,"timestamp":"2019-02-23T18:44:38.804Z"},{"players":8669,"timestamp":"2019-02-23T18:49:38.693Z"},{"players":8702,"timestamp":"2019-02-23T18:54:38.730Z"},{"players":8639,"timestamp":"2019-02-23T18:59:38.895Z"},{"players":8777,"timestamp":"2019-02-23T19:04:39.002Z"},{"players":8716,"timestamp":"2019-02-23T19:09:38.661Z"},{"players":8736,"timestamp":"2019-02-23T19:14:38.799Z"},{"players":8656,"timestamp":"2019-02-23T19:19:38.590Z"},{"players":8671,"timestamp":"2019-02-23T19:24:38.570Z"},{"players":8608,"timestamp":"2019-02-23T19:29:38.963Z"},{"players":8479,"timestamp":"2019-02-23T19:34:38.710Z"},{"players":8520,"timestamp":"2019-02-23T19:39:38.616Z"},{"players":8571,"timestamp":"2019-02-23T19:44:38.634Z"},{"players":8584,"timestamp":"2019-02-23T19:49:38.480Z"},{"players":8561,"timestamp":"2019-02-23T19:54:39.365Z"},{"players":8546,"timestamp":"2019-02-23T19:59:38.883Z"},{"players":8517,"timestamp":"2019-02-23T20:04:38.782Z"},{"players":8500,"timestamp":"2019-02-23T20:09:38.600Z"},{"players":8529,"timestamp":"2019-02-23T20:14:38.677Z"},{"players":8512,"timestamp":"2019-02-23T20:19:38.714Z"},{"players":8534,"timestamp":"2019-02-23T20:24:38.552Z"},{"players":8567,"timestamp":"2019-02-23T20:29:39.246Z"},{"players":8599,"timestamp":"2019-02-23T20:34:38.580Z"},{"players":8613,"timestamp":"2019-02-23T20:39:38.611Z"},{"players":8523,"timestamp":"2019-02-23T20:44:38.615Z"},{"players":8518,"timestamp":"2019-02-23T20:49:38.801Z"},{"players":8381,"timestamp":"2019-02-23T20:54:38.661Z"},{"players":8408,"timestamp":"2019-02-23T20:59:38.596Z"},{"players":8384,"timestamp":"2019-02-23T21:04:38.597Z"},{"players":8324,"timestamp":"2019-02-23T21:09:38.569Z"},{"players":8296,"timestamp":"2019-02-23T21:14:38.721Z"},{"players":8224,"timestamp":"2019-02-23T21:19:38.589Z"},{"players":8213,"timestamp":"2019-02-23T21:24:38.596Z"},{"players":8206,"timestamp":"2019-02-23T21:29:38.622Z"},{"players":8180,"timestamp":"2019-02-23T21:34:38.844Z"},{"players":8147,"timestamp":"2019-02-23T21:39:38.767Z"},{"players":8174,"timestamp":"2019-02-23T21:44:39.450Z"},{"players":8097,"timestamp":"2019-02-23T21:49:38.836Z"},{"players":8054,"timestamp":"2019-02-23T21:54:38.621Z"},{"players":8111,"timestamp":"2019-02-23T21:59:38.761Z"},{"players":8027,"timestamp":"2019-02-23T22:04:39.357Z"},{"players":7968,"timestamp":"2019-02-23T22:09:38.602Z"},{"players":7959,"timestamp":"2019-02-23T22:14:38.602Z"},{"players":7958,"timestamp":"2019-02-23T22:19:38.748Z"},{"players":7864,"timestamp":"2019-02-23T22:24:38.581Z"},{"players":7857,"timestamp":"2019-02-23T22:29:38.618Z"},{"players":7836,"timestamp":"2019-02-23T22:34:38.610Z"},{"players":7755,"timestamp":"2019-02-23T22:39:38.843Z"},{"players":7719,"timestamp":"2019-02-23T22:44:38.950Z"},{"players":7738,"timestamp":"2019-02-23T22:49:38.697Z"},{"players":7700,"timestamp":"2019-02-23T22:54:38.622Z"},{"players":7782,"timestamp":"2019-02-23T22:59:38.650Z"},{"players":7781,"timestamp":"2019-02-23T23:04:38.643Z"},{"players":7808,"timestamp":"2019-02-23T23:09:38.606Z"},{"players":7871,"timestamp":"2019-02-23T23:14:38.578Z"},{"players":7755,"timestamp":"2019-02-23T23:19:39.010Z"},{"players":6803,"timestamp":"2019-02-24T10:17:12.313Z"},{"players":6918,"timestamp":"2019-02-24T10:22:11.626Z"},{"players":6942,"timestamp":"2019-02-24T10:27:11.677Z"},{"players":6899,"timestamp":"2019-02-24T10:32:11.664Z"},{"players":6813,"timestamp":"2019-02-24T10:37:12.289Z"},{"players":6813,"timestamp":"2019-02-24T10:42:12.252Z"},{"players":6887,"timestamp":"2019-02-24T10:47:11.717Z"},{"players":6915,"timestamp":"2019-02-24T10:52:11.709Z"},{"players":6875,"timestamp":"2019-02-24T10:57:11.734Z"},{"players":6869,"timestamp":"2019-02-24T11:02:12.285Z"},{"players":7003,"timestamp":"2019-02-24T11:07:11.682Z"},{"players":7081,"timestamp":"2019-02-24T11:12:11.704Z"},{"players":7110,"timestamp":"2019-02-24T11:17:11.896Z"},{"players":7016,"timestamp":"2019-02-24T11:22:11.698Z"},{"players":6923,"timestamp":"2019-02-24T11:27:11.892Z"},{"players":6905,"timestamp":"2019-02-24T11:32:11.652Z"},{"players":6952,"timestamp":"2019-02-24T11:37:11.651Z"},{"players":6979,"timestamp":"2019-02-24T11:42:11.673Z"},{"players":7040,"timestamp":"2019-02-24T11:47:11.757Z"},{"players":6946,"timestamp":"2019-02-24T11:52:11.702Z"},{"players":6648,"timestamp":"2019-02-24T11:57:12.360Z"},{"players":6694,"timestamp":"2019-02-24T12:02:12.316Z"},{"players":6657,"timestamp":"2019-02-24T12:07:11.728Z"},{"players":6669,"timestamp":"2019-02-24T12:12:12.303Z"},{"players":6667,"timestamp":"2019-02-24T12:17:11.866Z"},{"players":6728,"timestamp":"2019-02-24T12:22:11.709Z"},{"players":6834,"timestamp":"2019-02-24T12:27:12.297Z"},{"players":6876,"timestamp":"2019-02-24T12:32:11.681Z"},{"players":6952,"timestamp":"2019-02-24T12:37:11.804Z"},{"players":6875,"timestamp":"2019-02-24T12:42:11.693Z"},{"players":6905,"timestamp":"2019-02-24T12:47:11.767Z"},{"players":6887,"timestamp":"2019-02-24T12:52:11.678Z"},{"players":6920,"timestamp":"2019-02-24T12:57:11.917Z"},{"players":6958,"timestamp":"2019-02-24T13:02:11.830Z"},{"players":7025,"timestamp":"2019-02-24T13:07:11.858Z"},{"players":7040,"timestamp":"2019-02-24T13:12:11.713Z"},{"players":7102,"timestamp":"2019-02-24T13:17:11.710Z"},{"players":7069,"timestamp":"2019-02-24T13:22:11.881Z"},{"players":7059,"timestamp":"2019-02-24T13:27:11.696Z"},{"players":7044,"timestamp":"2019-02-24T13:32:12.039Z"},{"players":7045,"timestamp":"2019-02-24T13:37:11.728Z"},{"players":7146,"timestamp":"2019-02-24T13:42:11.817Z"},{"players":7181,"timestamp":"2019-02-24T13:47:11.825Z"},{"players":7195,"timestamp":"2019-02-24T13:52:11.847Z"},{"players":7248,"timestamp":"2019-02-24T13:57:11.725Z"},{"players":7106,"timestamp":"2019-02-24T14:02:11.880Z"},{"players":7204,"timestamp":"2019-02-24T14:07:11.721Z"},{"players":7253,"timestamp":"2019-02-24T14:12:12.329Z"},{"players":7362,"timestamp":"2019-02-24T14:17:12.380Z"},{"players":7386,"timestamp":"2019-02-24T14:22:12.956Z"},{"players":7428,"timestamp":"2019-02-24T14:27:12.302Z"},{"players":7366,"timestamp":"2019-02-24T14:32:11.742Z"},{"players":7389,"timestamp":"2019-02-24T14:37:11.828Z"},{"players":7380,"timestamp":"2019-02-24T14:42:11.757Z"},{"players":7440,"timestamp":"2019-02-24T14:47:11.760Z"},{"players":7372,"timestamp":"2019-02-24T14:52:12.296Z"},{"players":7406,"timestamp":"2019-02-24T14:57:11.806Z"},{"players":7347,"timestamp":"2019-02-24T15:02:11.716Z"},{"players":7328,"timestamp":"2019-02-24T15:07:12.281Z"},{"players":7331,"timestamp":"2019-02-24T15:12:11.729Z"},{"players":7344,"timestamp":"2019-02-24T15:17:11.858Z"},{"players":7447,"timestamp":"2019-02-24T15:22:12.029Z"},{"players":7486,"timestamp":"2019-02-24T15:27:11.860Z"},{"players":7603,"timestamp":"2019-02-24T15:32:11.725Z"},{"players":7585,"timestamp":"2019-02-24T15:37:11.765Z"},{"players":7711,"timestamp":"2019-02-24T15:42:11.760Z"},{"players":7689,"timestamp":"2019-02-24T15:47:12.156Z"},{"players":7796,"timestamp":"2019-02-24T15:52:11.726Z"},{"players":7830,"timestamp":"2019-02-24T15:57:11.750Z"},{"players":7841,"timestamp":"2019-02-24T16:02:11.745Z"},{"players":7877,"timestamp":"2019-02-24T16:07:11.873Z"}]}
let realData = data.times.map(obj => {
return {
x: new Date(obj.timestamp),
y: obj.players,
}
})
newChart(realData)
// fetch("/data.json").then(res => res.text()).then(data => {
// let realData = data.times.map(obj => {
// return {
// x: new Date(obj.timestamp),
// y: obj.players,
// }
// })
// newChart(realData)
// })
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment