From 4e75953cefb6ae9e9e2c3ea897f0e9a38886027a Mon Sep 17 00:00:00 2001 From: Kim Svensson Sand Date: Wed, 10 May 2017 11:54:34 +0200 Subject: [PATCH] Fixed color bug for selecting while timelapsing this closes #128 --- heatmap_panel/src/HeatmapCtrl.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/heatmap_panel/src/HeatmapCtrl.js b/heatmap_panel/src/HeatmapCtrl.js index 20c7067..493068f 100644 --- a/heatmap_panel/src/HeatmapCtrl.js +++ b/heatmap_panel/src/HeatmapCtrl.js @@ -147,6 +147,31 @@ export class HeatmapCtrl extends MetricsPanelCtrl { this.circles.setCircleColor(this.currentDataList, index, '.circle', this.lightTheme ? 'lightgrey' : 'white'); } else { this.selected.push(serviceName); + + if (this.timelapse.state !== 'stop') { + let rearragned = []; + for (let i = 0; i < this.currentDataList.length; i++) { + let productName = this.targetParser.parseName(this.currentDataList[i].target) + + if (this.selected.includes(productName)) { + rearragned.push(productName); + } else { + this.circles.setCircleColor(this.currentDataList, i, '.circle', this.lightTheme ? 'lightgrey' : 'white'); + } + } + + for (let i = 0; i < rearragned.length; i++) { + let k = 0; + + while (rearragned[i] !== this.targetParser.parseName(this.currentDataList[k].target) && this.currentDataList[k + 1] !== undefined) { + k++; + } + + if (rearragned[i] === this.targetParser.parseName(this.currentDataList[k].target)) { + this.circles.setCircleColor(this.currentDataList, k, '.circle', this.panel.colors[i]); + } + } + } } this.productSelector.buildSimple('products', this.selected); // Add product to grafana template variable.