O'Reilly logo

Highcharts Cookbook by Nicholas Terwoord

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using WebSockets for real-time updates

Using AJAX for chart updates, as done in the last recipe, is helpful but may lead to a lot of unnecessary calls to whichever backend service is providing the data. Also, regardless of whether there is new data, we will have to ask for it every three seconds (or whichever interval we've configured). One alternative to this is to use WebSockets, which allows us to receive updates as soon as the server has updates.

For this recipe, we will be using Tornado, a python library that is available at http://www.tornadoweb.org, to provide the server-side component for our chart, but the client-side code will be similar for any server-side component that provides the WebSockets connectivity.

Note

While WebSockets is gaining ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required