From 0e43d96b13fad51a89024e98b30bce9484fbc251 Mon Sep 17 00:00:00 2001 From: Ricky Putra Date: Thu, 25 Feb 2021 16:07:22 +0800 Subject: [PATCH] Heatmap: Fix missing/wrong value in heatmap legend (#31430) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Torkel Ödegaard --- public/app/plugins/panel/heatmap/color_legend.ts | 2 +- public/app/plugins/panel/heatmap/rendering.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/heatmap/color_legend.ts b/public/app/plugins/panel/heatmap/color_legend.ts index 71245082b5f..ea5bffe543f 100644 --- a/public/app/plugins/panel/heatmap/color_legend.ts +++ b/public/app/plugins/panel/heatmap/color_legend.ts @@ -71,7 +71,7 @@ coreModule.directive('heatmapLegend', () => { clearLegend(elem); if (!_.isEmpty(ctrl.data) && !_.isEmpty(ctrl.data.cards)) { const cardStats = ctrl.data.cardStats; - const rangeFrom = _.isNil(panel.color.min) ? Math.min(cardStats.min, 0) : panel.color.min; + const rangeFrom = _.isNil(panel.color.min) ? Math.max(cardStats.min, 0) : panel.color.min; const rangeTo = _.isNil(panel.color.max) ? cardStats.max : panel.color.max; const maxValue = cardStats.max; const minValue = cardStats.min; diff --git a/public/app/plugins/panel/heatmap/rendering.ts b/public/app/plugins/panel/heatmap/rendering.ts index 73f177b8bce..a85a58eb9f6 100644 --- a/public/app/plugins/panel/heatmap/rendering.ts +++ b/public/app/plugins/panel/heatmap/rendering.ts @@ -501,7 +501,7 @@ export class HeatmapRenderer { const cardsData = this.data.cards; const cardStats = this.data.cardStats; const maxValueAuto = cardStats.max; - const minValueAuto = Math.min(cardStats.min, 0); + const minValueAuto = Math.max(cardStats.min, 0); const maxValue = _.isNil(this.panel.color.max) ? maxValueAuto : this.panel.color.max; const minValue = _.isNil(this.panel.color.min) ? minValueAuto : this.panel.color.min; const colorScheme: any = _.find(this.ctrl.colorSchemes, {