Home forums Using CanvasJS Last x number of minutes in X axis

This topic contains 2 replies, has 2 voices, and was last updated by  iggy 3 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #9634

    Is there a way to fix the x-axis of a dynamicly updating graph to show, lets say, the last 5 minutes?

    Basically, I have a dynamic graph that gets real time data. X axis is time. Once in a while that data stops. Right now I’m aging out old data based on the number of points. However, an issue arises when the data stops flowing for a period of time. Suddenly the there’s a large gap in the center of the graph until old points age out (basically until new points replace all of the old points).

    The way I want to work around it is either set it so that the graph always shows last x minutes (dynamically updating that in real time) or manually get the max x value and then subtract x from it and set it to the min value. Are either of these options currently possible?



    Hi Iggy,

    Yes, you can set the viewportMinimum and viewportMaximum values to display only the last x minutes.
    Here is an example jsfiddle where the graph shows only the last 5 minutes.


    Thanks! It worked. I didn’t realize it was a 1.8 feature so it took a bit of debugging before I realized that. I had to disable zoom to hide the navigation tool bar on top (had enabled by default) so that the user didn’t know it was zoomed in

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.