From e481e5c9c1d7cfde3e597020c0bdf7573751713c Mon Sep 17 00:00:00 2001 From: Gabriel Reid Date: Thu, 21 Feb 2019 16:20:30 +0100 Subject: [PATCH] Fix infinite watcher recursion Make a copy of the layout before assigning it to the graph element. Plotly sometimes performs its own updates on the layout element, specifically when dealing with time series data where the x-axis consists of Date values. In this case, we can get into an infinite recursion situation with the watcher in angular. --- src/angular-plotly.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/angular-plotly.js b/src/angular-plotly.js index 7b7cb66..967fced 100644 --- a/src/angular-plotly.js +++ b/src/angular-plotly.js @@ -38,7 +38,9 @@ subscribeToEvents(graph); } } - graph.layout = scope.plotlyLayout; + // Copy the layout so that internal updates by plotly don't trigger the watcher, otherwise + // we can end up in infinite watcher recursion -- this can happen when plotting time series data + graph.layout = angular.copy(scope.plotlyLayout); graph.data = scope.plotlyData; Plotly.redraw(graph); Plotly.Plots.resize(graph);