From ac347fa06a3472158357bde38e04d7ba867743d2 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 28 Mar 2017 18:09:15 +0300 Subject: [PATCH] heatmap: fix error while loading panel in editor mode --- public/app/plugins/panel/heatmap/rendering.ts | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/public/app/plugins/panel/heatmap/rendering.ts b/public/app/plugins/panel/heatmap/rendering.ts index 1d8cf1e4d9f..afc92375018 100644 --- a/public/app/plugins/panel/heatmap/rendering.ts +++ b/public/app/plugins/panel/heatmap/rendering.ts @@ -769,26 +769,30 @@ export default function link(scope, elem, attrs, ctrl) { if (setElementHeight()) { - // Draw default axes and return if no data - if (!data || _.isEmpty(data.buckets)) { - addHeatmapCanvas(); - addAxes(); + if (data) { + // Draw default axes and return if no data + if (_.isEmpty(data.buckets)) { + addHeatmapCanvas(); + addAxes(); + return; + } + + addHeatmap(); + scope.yScale = yScale; + scope.xScale = xScale; + scope.yAxisWidth = yAxisWidth; + scope.xAxisHeight = xAxisHeight; + scope.chartHeight = chartHeight; + scope.chartWidth = chartWidth; + scope.chartTop = chartTop; + + // Register selection listeners + $heatmap.on("mousedown", onMouseDown); + $heatmap.on("mousemove", onMouseMove); + $heatmap.on("mouseleave", onMouseLeave); + } else { return; } - - addHeatmap(); - scope.yScale = yScale; - scope.xScale = xScale; - scope.yAxisWidth = yAxisWidth; - scope.xAxisHeight = xAxisHeight; - scope.chartHeight = chartHeight; - scope.chartWidth = chartWidth; - scope.chartTop = chartTop; - - // Register selection listeners - $heatmap.on("mousedown", onMouseDown); - $heatmap.on("mousemove", onMouseMove); - $heatmap.on("mouseleave", onMouseLeave); } // Draw only if color editor is opened