diff --git a/bower.json b/bower.json index 39389c7..e44b7b0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-plotly", - "version": "0.1.3", + "version": "0.1.4", "description": "An AngularJS directive for plotly.js", "main": [ "src/angular-plotly.js" @@ -22,7 +22,7 @@ }, "dependencies": { "angular": "^1.x", - "plotly.js":"^1.10.2" + "plotly.js": "^1.40.1" }, "ignore": [ "**/.*", diff --git a/src/angular-plotly.js b/src/angular-plotly.js index 916e52a..421b00c 100644 --- a/src/angular-plotly.js +++ b/src/angular-plotly.js @@ -1,8 +1,8 @@ -(function() { +(function () { 'use strict'; angular.module('plotly', []).directive('plotly', [ '$window', - function($window) { + function ($window) { return { restrict: 'E', template: '
', @@ -13,12 +13,12 @@ plotlyEvents: '=', plotlyManualDataUpdate: '=' }, - link: function(scope, element) { + link: function (scope, element) { var graph = element[0].children[0]; var initialized = false; function subscribeToEvents(graph) { - scope.plotlyEvents(graph); + scope.plotlyEvents(graph); } function onUpdate() { @@ -34,14 +34,13 @@ if (!initialized) { initialized = true; Plotly.newPlot(graph, scope.plotlyData, scope.plotlyLayout, scope.plotlyOptions); - if (scope.plotlyEvents){ - subscribeToEvents(graph); + if (scope.plotlyEvents) { + subscribeToEvents(graph); } } graph.layout = scope.plotlyLayout; graph.data = scope.plotlyData; - Plotly.redraw(graph); - Plotly.Plots.resize(graph); + Plotly.update(graph); } function onResize() { @@ -50,20 +49,20 @@ } scope.$watch( - function(scope) { + function (scope) { return scope.plotlyLayout; }, - function(newValue, oldValue) { + function (newValue, oldValue) { if (angular.equals(newValue, oldValue) && initialized) return; onUpdate(); }, true); if (!scope.plotlyManualDataUpdate) { scope.$watch( - function(scope) { + function (scope) { return scope.plotlyData; }, - function(newValue, oldValue) { + function (newValue, oldValue) { if (angular.equals(newValue, oldValue) && initialized) return; onUpdate(); }, true); @@ -76,12 +75,12 @@ onUpdate(); }); - scope.$watch(function() { + scope.$watch(function () { return { 'h': element[0].offsetHeight, 'w': element[0].offsetWidth }; - }, function(newValue, oldValue) { + }, function (newValue, oldValue) { if (angular.equals(newValue, oldValue)) return; onResize(); }, true);