Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Services.WebApp/3.3/WebApp/shared/directives/flot.js @ 12428

Last change on this file since 12428 was 12428, checked in by ascheibe, 9 years ago

#2394 added web app and status page to trunk

File size: 2.0 KB
Line 
1(function () {
2    var module = appMainPlugin.getAngularModule();
3    module.directive('flot', function () {
4        return {
5            restrict: 'E',
6            link: function (scope, element, attrs) {
7                var chart = null, opts = scope[attrs.options];
8
9                scope.$watchCollection(attrs.dataset, function (newData, oldData) {
10                    if (!chart) {
11                        var div = element.append("<div>");
12                        div.bind("plotselected", function (event, ranges) {
13                            $.each(chart.getXAxes(), function (_, axis) {
14                                var opts2 = axis.options;
15                                opts2.min = ranges.xaxis.from;
16                                opts2.max = ranges.xaxis.to;
17                            });
18                            chart.setupGrid();
19                            chart.draw();
20                            chart.clearSelection();
21                        });
22                        div.dblclick(function () {
23                            var axes = chart.getAxes();
24                            var xaxis = axes.xaxis.options;
25                            xaxis.min = null;
26                            xaxis.max = null;
27                            chart.setupGrid();
28                            chart.draw();
29                        });
30                        div.addClass('chart');
31                        div.addClass('angular-flot-chart');
32                        chart = $.plot(div, newData, opts);
33                        div.resizable({});
34                        div.show();
35                    } else {
36                        var axes = chart.getAxes();
37                        var xaxis = axes.xaxis.options;
38                        xaxis.min = null;
39                        xaxis.max = null;
40                        chart.setData(newData);
41                        chart.setupGrid();
42                        chart.draw();
43                    }
44                });
45            }
46        };
47    });
48})();
Note: See TracBrowser for help on using the repository browser.