1

Im trying to get live data in highstock (js-lib). I used this template: http://www.highcharts.com/stock/demo/dynamic-update in combination with this guide: http://www.highcharts.com/docs/working-with-data/live-data

This is my result: http://jsfiddle.net/93deqwm4/ I dont get any new data every second. What is the problem, it looks so simple in the instructions.

Adis
  • 804
  • 1
  • 9
  • 15

1 Answers1

1

Let's go by parts, as Jack the Ripper said.

  1. Your ajax call is using relative path, which means it's trying to reach "http://fiddle.jshell.net/93deqwm4/show/live-server-data.php", that doesn't exist. You can change it to absolute path: "http://www.highcharts.com/studies/live-server-data.php", but then the second problem appears:
  2. You're trying to request a different domain than your page is on, so your browser is going to block it. I found here a very simple workaround if you use Chrome (if you don't, you can find other solutions there anyway).
  3. You ignored the 2 step of the tutorial you were following. You must make the variable 'chart' global. So I used window.chart to make it global.

After these changes, you have a functional example (<-- it won't work if you don't use a workaround to the 'different domain request' problem).

Community
  • 1
  • 1
carla
  • 1,970
  • 1
  • 31
  • 44
  • The example they have works grate. But I need to use "StockChart". They created a new chart by; `chart = new Highcharts.Chart` and then sending the data from requestData() to that chart. My problem is how do create a new chart (`chart = new Highcharts.Chart` but with StockChart. This doesent work: `chart = new $('#container').highcharts('StockChart', {` – Adis Jul 30 '15 at 07:50
  • 1
    You can simply change `chart = new Highcharts.Chart` to `chart = new Highcharts.StockChart`. Here: http://stackoverflow.com/questions/16071593/how-to-create-a-new-highstock-chart-with-new-highchart-and-not-jquery – carla Jul 31 '15 at 03:13