From 8da6221441f3289e54bc8c3f315f814d0b781551 Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Fri, 8 Feb 2019 17:37:17 +0300 Subject: [PATCH] fix: TypeError: Cannot read property 'timeSrv' of undefined --- .vscode/launch.json | 2 +- src/panel/graph_panel/graph_renderer.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 81e8756..17e2ff9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "type": "chrome", "request": "launch", "name": "Launch Chrome against localhost", - "url": "http://localhost:3000/d/Votr2gvmk/nginx", + "url": "http://localhost:3000/", "sourceMaps": true, "pathMapping": { "/public/plugins/hastic-graph-panel": "${workspaceFolder}/dist" diff --git a/src/panel/graph_panel/graph_renderer.ts b/src/panel/graph_panel/graph_renderer.ts index 4d6ffb0..92129c6 100644 --- a/src/panel/graph_panel/graph_renderer.ts +++ b/src/panel/graph_panel/graph_renderer.ts @@ -56,7 +56,9 @@ export class GraphRenderer { private timeSrv: any; private _graphMousePosition: any; - constructor ($elem: JQuery, timeSrv, contextSrv, scope) { + constructor($elem: JQuery, timeSrv, contextSrv, scope) { + + var self = this; this.$elem = $elem; @@ -164,7 +166,7 @@ export class GraphRenderer { // this.eventManager.updateTime(selectionEvent.xaxis); // }, 100); } else { - this.scope.$apply(function() { + this.scope.$apply(() => { this.timeSrv.setTime({ from: moment.utc(selectionEvent.xaxis.from), to: moment.utc(selectionEvent.xaxis.to),