Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
ChartJS difficulty with X Axis and pulling appropriate data

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:

  1. Pull the time value for each worker iteration from the history element, regardless of when a worker starts reporting.
  2. Mark the hashrate on the graph at the proper date/time
  3. Only display the last hour of stats (BONUS: a way to zoom out to see all 12 hours of stats)

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!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda