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