gevgeny / angular2-highcharts

:bar_chart: :chart_with_upwards_trend: Highcharts for your Angular project
MIT License
380 stars 113 forks source link

Dynamic Data is not moving the x-axis #167

Open kambajwa opened 7 years ago

kambajwa commented 7 years ago

Hi, I replicated the dynamic data from the demo on your site but the x-axis is not moving. it seems to be moving, but as more and more data points are getting added in, it is becoming congested. dynamic-data http://plnkr.co/edit/OQSFSKisIIWAH0megy4d?p=preview

ronnyek commented 7 years ago

you could massage the data if you only care about displaying a specific number of data points... (and there may very well be a way to achieve this in chart options alone)

const maxDataPoints=100;
 // data coming from somewhere
dataPoints.push(dataFromSource);
if(dataPoints.length>maxDataPoints){
  dataPoints.shift();
}

The demos on Highcharts site actually dont work this way... but rather use methods on the series itself to push datapoints on to the chart (likely in a much more optimal fashion than re-initializing chart every time new data comes in).

kaelvergara commented 6 years ago

I think you have to use

this.chart.series[0].addPoint([Math.random()` * 10], true, true)

instead of

this.chart.series[0].addPoint(Math.random() * 10)

Check out this example. http://plnkr.co/edit/jUnxafwLqcejmiCoi6GS?p=preview