Home forums Report Bugs Line Graph Point Connection Bug

This topic contains 2 replies, has 2 voices, and was last updated by  Vishwas R 2 weeks, 4 days ago.

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

    Kieran
    Member

    I’ve just tried posting this but I believe there was an error, so my apologies if this is posted twice

    I’m trying to use CanvasJS to display some data in real-time from a SQL DB.
    This data is added periodically every 10th of a second.

    I am achieving this by sending an AJAX request to the PHP server with the ID of the last record previously retrieved, which then replies with all the records currently adter this ID. Upon the JS (JavaScript) getting this, the data is then added to the graph in CanvasJS. The JS-side keeps track of 24 hours worth of data, so it will only ever contain a maximum of 24 hour-old data at once; however, I am encountering some unusual issues with the graph when the points are added. In the following screenshot(s) the data is shown in real-time, but only 1 minute’s worth of data is shown.

    Unusual behaviour
    As seen in the screenshot above, some of the points are connected to unrelated previous points. Focusing on the time stamp, if the page is refreshed (the past 24 hour’s worth of data is retrieved again), this behaviour is not replicated again, as seen below:
    Unusual behaviour gone

    My first assumption was that there was some mistake with the data in the database; however the subsequent screenshot shows that the data is in the correct order and hence should not be causing the problem:
    Data from database
    (Yes, I know some of the IDs are missing – this is due to multiple machines feeding data to ensure that the 10th-second-interval is met, even so, this should not cause an issue that I can think of).

    I have also implemented a “pause” button to the graph, which stops the interval of continuously requesting recent data until “played” again. This uses the same request system, retrieving all after the previous ID (as it would do in real-time). The below screenshot indicates the time period spent paused by the red box:
    Paused graph
    The problem of the connecting points does not seem to occur when the graph is “paused” (the interval is cleared and started again at a later date).

    This problem does not occur when the data is submitted at 1 second intervals, only at 0.1 second intervals. Despite this, I would like to pursue with the 0.1 second intervals for the increased level of accuracy.

    #13870

    Kieran
    Member

    For further context to the situation, as I explained previously, only 24 hours of data is kept in memory. This is done by fetching the most recent 24 hours of data initially, then splicing by the length of the new data received each time from the start of the dictionary – essentially keeping a fixed length dictionary of the points.

    I have also implemented a method of changing the amount of data displayed on the graph through variables. If the limit were set to a minute, when updating the graph, the script would iterate through the stored 24 hours of data backwards until it find an item before the limit, at this point the data points for the graph will be set to a slice of the stored 24 hours of data from the found index to the last item.
    I wanted to explain this in case the points on the graph were being mixed up somehow as a result of the shifting of the data points for the limits.

    #13876

    Vishwas R
    Keymaster

    @kieran,

    Can you kindly create jsfiddle with the issue and sample-data that helps in creating the issue, so that we can look into it and help you out?

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

You must be logged in to reply to this topic.