Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda