1

I followed the solution in the Stackoverflow question below. But I want to plot time on xaxis. But it does not work

How to Integrate Flot with AngularJS?

Please check the fiddle below. I do not get the graph output.

var App = angular.module('App', []);

App.controller('Ctrl', function ($scope) {
    $scope.data = [
        [1438031893270, 1],
        [1438031894270, 2],
        [1438031895269, 3],
        [1438031896269, 4],
        [1438031897278, 5],
        [1438031898270, 6],
        [1438031899268, 7],
        [1438031900277, 8],
        [1438031901269, 9]
    ];
});

App.directive('chart', function () {
    return {
        restrict: 'E',
        link: function (scope, elem, attrs) {
            var opts = {
                xaxis: {
                    mode: "time",
                    timeformat: "%H:%M:%S"
                },
            };
            var data = scope[attrs.ngModel];
            $.plot(elem, data, opts);
            elem.show();
        }
    };
});

http://jsfiddle.net/ksdqhqb2/38/

http://jsfiddle.net/ksdqhqb2/39/

Community
  • 1
  • 1
user3755282
  • 813
  • 2
  • 9
  • 15

1 Answers1

0

Check the working demo: JSFiddle. You miss a [] in $scope.data.

Joy
  • 9,430
  • 11
  • 44
  • 95