From 67defd9226e988ec7bcdabe368fd81cf95c89918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=C3=B3jcik?= Date: Mon, 29 Oct 2018 16:56:15 +0100 Subject: [PATCH] Making 0 line on graph always show --- .../modules/monitoring/js/directives/ui.particular.graph.js | 3 +++ .../monitoring/js/directives/ui.particular.largeGraph.js | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ServicePulse.Host/app/modules/monitoring/js/directives/ui.particular.graph.js b/src/ServicePulse.Host/app/modules/monitoring/js/directives/ui.particular.graph.js index 55a2ca7761..0fb40f8c0f 100644 --- a/src/ServicePulse.Host/app/modules/monitoring/js/directives/ui.particular.graph.js +++ b/src/ServicePulse.Host/app/modules/monitoring/js/directives/ui.particular.graph.js @@ -14,6 +14,9 @@ template: '', link: function link(scope, element, attrs) { scope.plotData = scope.plotData || { points: [], average: 0 }; + if (scope.plotData.points.length === 0) { + scope.plotData.points = new Array(10).fill(0); + } scope.$watch('plotData', function() { diff --git a/src/ServicePulse.Host/app/modules/monitoring/js/directives/ui.particular.largeGraph.js b/src/ServicePulse.Host/app/modules/monitoring/js/directives/ui.particular.largeGraph.js index ffba901922..77c0ae1514 100644 --- a/src/ServicePulse.Host/app/modules/monitoring/js/directives/ui.particular.largeGraph.js +++ b/src/ServicePulse.Host/app/modules/monitoring/js/directives/ui.particular.largeGraph.js @@ -110,8 +110,10 @@ var firstSeries = scope.firstDataSeries; var secondSeries = scope.secondDataSeries; - var amountOfValues = Math.max(firstSeries.points.length, secondSeries ? secondSeries.points.length : 0); - + var amountOfValues = Math.max(firstSeries.points.length, secondSeries ? secondSeries.points.length : 0) || 10; + if (firstSeries.points.length === 0) { + firstSeries.points = new Array(amountOfValues).fill(0); + } var scaleX = d3.scaleLinear() .domain([0, amountOfValues - 1]) .range([leftMargin, width]);