Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
real time scrolling based chart with chart.js

i want to create real time graph with scrolling time such as in the following video:https://www.youtube.com/watch?v=2-tnkzG0sKU

is this possible with chart.js? I have so far the following, it is scrolling but the time is not showing up, i want to show in seconds.

let dataSize = 500;
let readings = new Array(dataSize);    
// data object for the chart:
const data = {
  // X axis labels
  labels: new Array(),
  datasets: [{
    data: readings,         // the data to chart
    borderColor: '#272323', // line color (lavender)
    pointRadius: 0.5          // point size
  }]
};

const config = {
  type: 'line',         // type of chart
  data: data,           // the data
  options: {
    animation: false,   // remove animation to speed drawing up
    responsive: true,
    maintainAspectRatio: false,
    scales: {           // axis ranges:
      y: {
        type: 'linear',
        min: 0,
        max: 255
      },
      x:{
      //  ticks:{
          type: 'time',
          time:{
            //unit:'second',
            displayFormats: {hour: 'mm:ss'}
          },
          min:0,
          max: dataSize,
          //beginAtZero: true,
          maxTicksLimit: dataSize/2
        //}
      }
    }
  }
};

thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Easyest way to achieve this is by using the streaming plugin for chart.js: https://nagix.github.io/chartjs-plugin-streaming/master/guide/#table-of-contents

You will get something like this where in your onRefresh you add your data.

npm i chartjs-plugin-streaming

import ChartStreaming from 'chartjs-plugin-streaming';
import 'anyDatAdapterFromAhichDateLibYouAreUsing';

Chart.register(ChartStreaming);

const myChart = new Chart(ctx, {
  options: {
    scales: {
      x: {
        type: 'realtime',
        realtime: {
          onRefresh: function(chart) {
            chart.data.datasets.forEach(function(dataset) {
              dataset.data.push({
                x: Date.now(),
                y: Math.random()
              });
            });
          }
        }
      }
    }
  }
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!