Search code examples
javascriptapexcharts

How to get the current time on the real-time Apexcharts


realTime Apexcharts

I am making a real-time chart with the source code in the link above. However, in the above chart, the value of the x-axis is not initialized to the current time.

Please tell me how to initialize the x-axis value to the current time.


Solution

  • Change this fragment

    getDayWiseTimeSeries(new Date('11 Feb 2017 GMT').getTime(), 10, {
      min: 10,
      max: 90
    })
    

    to this

    let initNumber = 10
    getDayWiseTimeSeries(new Date().getTime()-(initNumber - 1)*TICKINTERVAL, initNumber, {
      min: 10,
      max: 90
    })
    

    Sarting x-axis will be from 13 to 22 (today)