0

Hi guys i need your help. I am using the Highcharts-NG to make my charts, but i have one small problem. I have my graph working , i am pushing live data to my graph and it is working very well, but instead of X values "1","2","3" every time i insert one point to series i want to insert timestamp in x axis. In normal highcharts is easy to do with the function addPoint() , but with highcharts-ng i don't have that function. Can someone please help me please?

Here is my working file : http://jsfiddle.net/zrKEb/

Zippy
  • 1,804
  • 5
  • 27
  • 36

2 Answers2

0

Here is my solution for using addPoint function with highcharts-ng directive:

$scope.chart_realtimeForceConfig = {
options: {
  chart: {
    type: 'line',
  },   
  xAxis: { 
    type: 'datetime' ,         
    labels: {
    format: '{value:%H:%M:%S %Y}'
    }
    },
},
series: [{
  name: 'Fx',
  data: [],

}, ],
func: function(chart) {
  $timeout(function() {
    chart.reflow();

  }, 300);

  $interval(function() {

    var shift = chart.series[0].data.length > 100;

    chart.series[0].addPoint([Date.now(),Math.floor(Math.random() * 100) + 1], true, shift, false);
  }, 1000);
},
loading: false

}

});

The date format is done in the chart

http://codepen.io/ruisebastiao/pen/BKmQQz

Rui Sebastião
  • 855
  • 1
  • 18
  • 36
-1

After a lot of workaround i found one solution but i don't know if it is the best way to do what i want.

$scope.highchartsNG.xAxis.categories.push($filter('date')(new Date(), "mediumTime"));

This will push the timestamp now value to the Xaxis and will filter it. The final result will be a value in the format 'h:mm:ss a' If anyone have another solution please answer to my question.