I'm having some difficulties with iterating over some json data and displaying the proper X axis (Date/Time) I've tried several times to loop through the json data to extract the time for each worker in "history", but unsuccessful.
Here is a sample of the JSON - https://github.com/devdevdevdev1/rvnpoolcharts/blob/main/samplejson.json
And here is my code - https://github.com/devdevdevdev1/rvnpoolcharts/blob/main/worker_stats.js
To get it to work (somewhat), i've just thrown 48 random numbers as points on the x-axis:
displayWorkerHashrateGraph(Array.from(Array(48).keys()), dataset, label);
but obviously there are several problems with this, such as if a new worker joins after one has already been reporting, it starts at 1 and doesn't line up with the other workers.
You can see here that there is no dates/times on the x axis, and the label says 78 instead of a date label. Current Graph
I've also tried to loop through the list of each worker and extract the time like so:
let labelsList = [];
let historyList = [];
//Begin History Loop
for (var w in workerData.history) {
var worker = getWorkerNameFromAddress(w);
var a = {
key: worker,
hashrate: []
};
for (var wh in workerData.history[w]) {
a.hashrate.push([workerData.history[w][wh].time * 1000, workerData.history[w][wh].hashrate]);
labelsList.push([w, workerData.history[w][wh].time * 1000]);
}
historyList.push(a);
But that ends up looking like this - Seems its taking the time for all 3 of them, but not lining up with the hashrate and pushing all the values to the left.
What I'm trying to achieve:
I'd really appreciate any help you can give, I'm a bit new to javascript and I've tried many times to achieve the above and have seriously been banging my head on a wall. Thanks in advance!