From c1c1bcb874a9ec639fdea2f30656f2f1fbf69c54 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 27 Jun 2017 17:42:21 +0300 Subject: [PATCH] histogram: don't cut negative values, issue #8628 --- public/app/plugins/panel/graph/graph.ts | 2 +- public/app/plugins/panel/graph/histogram.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/graph/graph.ts b/public/app/plugins/panel/graph/graph.ts index 16d259c210e..c8d8fbfb25f 100755 --- a/public/app/plugins/panel/graph/graph.ts +++ b/public/app/plugins/panel/graph/graph.ts @@ -427,7 +427,7 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv, popoverSrv) { ticks = _.map(data[0].data, point => point[0]); // Expand ticks for pretty view - min = Math.max(0, _.min(ticks) - bucketSize); + min = _.min(ticks) - bucketSize; max = _.max(ticks) + bucketSize; ticks = []; diff --git a/public/app/plugins/panel/graph/histogram.ts b/public/app/plugins/panel/graph/histogram.ts index e6ad7ebb0f6..c60782942f2 100644 --- a/public/app/plugins/panel/graph/histogram.ts +++ b/public/app/plugins/panel/graph/histogram.ts @@ -38,9 +38,12 @@ export function convertValuesToHistogram(values: number[], bucketSize: number): } } - return _.map(histogram, (count, bound) => { + let histogam_series = _.map(histogram, (count, bound) => { return [Number(bound), count]; }); + + // Sort by Y axis values + return _.sortBy(histogam_series, point => point[0]); } function getBucketBound(value: number, bucketSize: number): number {