SHARE
TWEET

Untitled

a guest Dec 19th, 2014 4 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mainApp = angular.module('mainApp', ['n3-line-chart']);
  2.  
  3. mainApp.controller('MainController', function ($scope) {
  4.         $scope.state = {"time": 1.234, "pressure": -29348}
  5.         $scope.data = [
  6.           {x: 0, value: 4, otherValue: 14},
  7.           {x: 1, value: 8, otherValue: 1},
  8.           {x: 2, value: 15, otherValue: 11},
  9.           {x: 3, value: 16, otherValue: 147},
  10.           {x: 4, value: 23, otherValue: 87},
  11.           {x: 5, value: 42, otherValue: 45}
  12.         ];
  13.  
  14.         last_x = 5
  15.         last_v = 42
  16.  
  17.         $scope.options = {
  18.           axes: {
  19.             x: {key: 'x', labelFunction: function(value) {return value;}, type: 'linear', min: 0, max: 5, ticks: 2},
  20.             y: {type: 'linear', min: 0, max: 50, ticks: 5},
  21.             // y2: {type: 'linear', min: 0, max: 1, ticks: [1, 2, 3, 4]}
  22.           },
  23.           series: [
  24.             {y: 'value', color: 'steelblue', thickness: '2px', type: 'line', striped: true, label: 'Pouet'},
  25.             // {y: 'otherValue', axis: 'y2', color: 'lightsteelblue', visible: false, drawDots: true, dotSize: 2}
  26.           ],
  27.           lineMode: 'linear',
  28.           tension: 0.7,
  29.           tooltip: {mode: 'scrubber', formatter: function(x, y, series) {return 'pouet';}},
  30.           drawLegend: true,
  31.           drawDots: true,
  32.           columnsHGap: 5
  33.         }
  34.  
  35.  
  36.         $scope.$watch('data',
  37.         function(newValue, oldValue) {
  38.                         console.log('changed detected!', newValue, oldValue)
  39.                 }
  40.         );
  41.  
  42.         $scope.addData = function() {
  43.                 last_x += 1
  44.                 last_v += 5
  45.                 $scope.data.push({x: last_x, y: last_v})
  46.                 // console.log($scope.data)
  47.         }
  48.  
  49.  
  50.  
  51. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top