Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Realtime flot chart with java SSE not rendering

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 received as per console.log is like this :


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.
You don't like waffles? Well, do you like this tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic