• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Realtime flot chart with java SSE not rendering

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an application where I have data stored in a database. This needs to be rendered on a web page( a jsp page) as a real time graph. I am using Server Side Events for sending data from the database to the client page every second. On the client, I am using flot charts to render a real time graph.

I am receiving the data from server correctly every second. However, the flot chart is not displayed correctly. It just shows a single straight line going up and down. Here is the code:



The event.data received as per console.log is like this :

[{"data":1.075095},{"data":1.031029},{"data":0.91654},{"data":0.748307},{"data":0.549199}....,{"data":0.012224}]

The graph shows a moving plot of a straight line which is incorrect. Also, the graph is not plotting from 0 of x-axis which is where the first datapoint starts.

Does this look like a concurrency issue. That is setupEventSource function has eventsource.onmessage which gets invoked every second and updates the serverDataPoints array. On the other hand, getRandomData gets invoked every few milliseconds to copy the server data and display it on the graph. Both these are present within $(function().

Thank you for your help in advance.
 
reply
    Bookmark Topic Watch Topic
  • New Topic