From fbf39598b855dea9959dae9e6554be1bba1d489a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 5 May 2017 17:33:54 +0200 Subject: [PATCH] heatmp: removed series stats option, lacked tests --- .../app/plugins/panel/heatmap/heatmap_ctrl.ts | 1 - .../panel/heatmap/heatmap_data_converter.ts | 10 ---- .../plugins/panel/heatmap/heatmap_tooltip.ts | 58 ++++++++----------- .../heatmap/partials/display_editor.html | 4 -- 4 files changed, 25 insertions(+), 48 deletions(-) diff --git a/public/app/plugins/panel/heatmap/heatmap_ctrl.ts b/public/app/plugins/panel/heatmap/heatmap_ctrl.ts index 5600a5ea2e4..02d2ef24b79 100644 --- a/public/app/plugins/panel/heatmap/heatmap_ctrl.ts +++ b/public/app/plugins/panel/heatmap/heatmap_ctrl.ts @@ -46,7 +46,6 @@ let panelDefaults = { yBucketNumber: null, tooltip: { show: true, - seriesStat: false, showHistogram: false }, highlightCards: true diff --git a/public/app/plugins/panel/heatmap/heatmap_data_converter.ts b/public/app/plugins/panel/heatmap/heatmap_data_converter.ts index 2115d4070be..f627173d233 100644 --- a/public/app/plugins/panel/heatmap/heatmap_data_converter.ts +++ b/public/app/plugins/panel/heatmap/heatmap_data_converter.ts @@ -60,7 +60,6 @@ function convertToCards(buckets) { yBounds: yBucket.bounds, values: yBucket.values, count: yBucket.count, - seriesStat: getSeriesStat(yBucket.points) }; cards.push(card); }); @@ -145,15 +144,6 @@ function removeZeroBuckets(buckets) { return buckets; } -/** - * Count values number for each timeseries in given bucket - * @param {Array} points Bucket's datapoints with series name ([val, ts, series_name]) - * @return {Object} seriesStat: {seriesName_1: val_1, seriesName_2: val_2} - */ -function getSeriesStat(points) { - return _.countBy(points, p => p[2]); -} - /** * Convert set of time series into heatmap buckets * @return {Object} Heatmap object: diff --git a/public/app/plugins/panel/heatmap/heatmap_tooltip.ts b/public/app/plugins/panel/heatmap/heatmap_tooltip.ts index 71207886d7d..28824d7c7e2 100644 --- a/public/app/plugins/panel/heatmap/heatmap_tooltip.ts +++ b/public/app/plugins/panel/heatmap/heatmap_tooltip.ts @@ -87,17 +87,18 @@ export class HeatmapTooltip { let tooltipHtml = `
${time}
`; - if (yData && yData.bounds) { - boundBottom = valueFormatter(yData.bounds.bottom); - boundTop = valueFormatter(yData.bounds.top); - valuesNumber = yData.count; - tooltipHtml += `
- bucket: ${boundBottom} - ${boundTop}
- count: ${valuesNumber}
-
`; - - if (this.panel.tooltip.seriesStat && yData.seriesStat) { - tooltipHtml = this.addSeriesStat(tooltipHtml, yData.seriesStat); + if (yData) { + if (yData.bounds) { + boundBottom = valueFormatter(yData.bounds.bottom); + boundTop = valueFormatter(yData.bounds.top); + valuesNumber = yData.count; + tooltipHtml += `
+ bucket: ${boundBottom} - ${boundTop}
+ count: ${valuesNumber}
+
`; + } else { + // currently no bounds for pre bucketed data + tooltipHtml += `
count: ${yData.count}
`; } } else { if (!this.panel.tooltip.showHistogram) { @@ -159,15 +160,6 @@ export class HeatmapTooltip { return pos; } - addSeriesStat(tooltipHtml, seriesStat) { - tooltipHtml += "series:
"; - _.forEach(seriesStat, (values, series) => { - tooltipHtml += `  -  ${series}: ${values}
`; - }); - - return tooltipHtml; - } - addHistogram(data) { let xBucket = this.scope.ctrl.data.buckets[data.x]; let yBucketSize = this.scope.ctrl.data.yBucketSize; @@ -181,8 +173,8 @@ export class HeatmapTooltip { let scale = this.scope.yScale.copy(); let histXScale = scale - .domain([min, max]) - .range([0, HISTOGRAM_WIDTH]); + .domain([min, max]) + .range([0, HISTOGRAM_WIDTH]); let barWidth; if (this.panel.yAxis.logBase === 1) { @@ -193,21 +185,21 @@ export class HeatmapTooltip { barWidth = Math.max(barWidth, 1); let histYScale = d3.scaleLinear() - .domain([0, _.max(_.map(histogramData, d => d[1]))]) - .range([0, HISTOGRAM_HEIGHT]); + .domain([0, _.max(_.map(histogramData, d => d[1]))]) + .range([0, HISTOGRAM_HEIGHT]); let histogram = this.tooltip.select(".heatmap-histogram") - .append("svg") - .attr("width", HISTOGRAM_WIDTH) - .attr("height", HISTOGRAM_HEIGHT); + .append("svg") + .attr("width", HISTOGRAM_WIDTH) + .attr("height", HISTOGRAM_HEIGHT); histogram.selectAll(".bar").data(histogramData) - .enter().append("rect") - .attr("x", d => { - return histXScale(d[0]); - }) - .attr("width", barWidth) - .attr("y", d => { + .enter().append("rect") + .attr("x", d => { + return histXScale(d[0]); + }) + .attr("width", barWidth) + .attr("y", d => { return HISTOGRAM_HEIGHT - histYScale(d[1]); }) .attr("height", d => { diff --git a/public/app/plugins/panel/heatmap/partials/display_editor.html b/public/app/plugins/panel/heatmap/partials/display_editor.html index a6d1de1981c..863fcc49d07 100644 --- a/public/app/plugins/panel/heatmap/partials/display_editor.html +++ b/public/app/plugins/panel/heatmap/partials/display_editor.html @@ -62,10 +62,6 @@ checked="ctrl.panel.tooltip.show" on-change="ctrl.render()">
- -