Advertisement
Guest User

Untitled

a guest
Mar 6th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.     Highcharts.setOptions({
  3.         global: {
  4.             useUTC: false
  5.         }
  6.     });
  7.  
  8. // Create the chart
  9.     $.get('api_plc/1', function (res) {
  10.         var obj = jQuery.parseJSON(res);
  11.         Highcharts.stockChart('containers', {
  12.             chart: {
  13.                 events: {
  14.                     load: function () {
  15.  
  16.                         // set up the updating of the chart each second
  17.                         var series = this.series[0];
  18.                         setInterval(function () {
  19.                             var x = (new Date()).getTime(), // current time
  20.                                     y = Math.round(Math.random() * 100);
  21.                             series.addPoint([x, y], true, true);
  22.                         }, 1000);
  23.                     }
  24.                 }
  25.             },
  26.             rangeSelector: {
  27.                 buttons: [{
  28.                         count: 1,
  29.                         type: 'minute',
  30.                         text: '1M'
  31.                     }, {
  32.                         count: 5,
  33.                         type: 'minute',
  34.                         text: '5M'
  35.                     }, {
  36.                         type: 'all',
  37.                         text: 'All'
  38.                     }],
  39.                 inputEnabled: false,
  40.                 selected: 0
  41.             },
  42.             title: {
  43.                 text: 'Live random data'
  44.             },
  45.             exporting: {
  46.                 enabled: false
  47.             },
  48.             series: obj.data.series
  49.         });
  50.     });
  51. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement