From 614bd7f1e8742a8d4540e10a422c78396a705df6 Mon Sep 17 00:00:00 2001 From: Ben RUBSON Date: Thu, 24 Nov 2016 10:24:49 +0100 Subject: [PATCH] Sort series by yaxis by default (#6683) * Sort series by yxis by default * Sort series by yxis by default * Sort series by yxis by default --- .../app/plugins/panel/graph/graph_tooltip.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/public/app/plugins/panel/graph/graph_tooltip.js b/public/app/plugins/panel/graph/graph_tooltip.js index 91ea556d9dc..89b6e1c426e 100644 --- a/public/app/plugins/panel/graph/graph_tooltip.js +++ b/public/app/plugins/panel/graph/graph_tooltip.js @@ -49,7 +49,8 @@ function ($) { this.getMultiSeriesPlotHoverInfo = function(seriesList, pos) { var value, i, series, hoverIndex, hoverDistance, pointTime, yaxis; - var results = []; + // 3 sub-arrays, 1st for hidden series, 2nd for left yaxis, 3rd for right yaxis. + var results = [[],[],[]]; //now we know the current X (j) position for X and Y values var last_value = 0; //needed for stacked values @@ -60,14 +61,14 @@ function ($) { series = seriesList[i]; if (!series.data.length || (panel.legend.hideEmpty && series.allIsNull)) { - // Init value & yaxis so that it does not brake series sorting - results.push({ hidden: true, value: 0, yaxis: 0 }); + // Init value so that it does not brake series sorting + results[0].push({ hidden: true, value: 0 }); continue; } if (!series.data.length || (panel.legend.hideZero && series.allIsZero)) { - // Init value & yaxis so that it does not brake series sorting - results.push({ hidden: true, value: 0, yaxis: 0 }); + // Init value so that it does not brake series sorting + results[0].push({ hidden: true, value: 0 }); continue; } @@ -110,18 +111,20 @@ function ($) { yaxis = series.yaxis.n; } - results.push({ + results[yaxis].push({ value: value, hoverIndex: hoverIndex, color: series.color, label: series.label, time: pointTime, distance: hoverDistance, - yaxis: yaxis, index: i }); } + // Contat the 3 sub-arrays + results = results[0].concat(results[1],results[2]); + // Time of the point closer to pointer results.time = minTime; @@ -172,7 +175,7 @@ function ($) { absoluteTime = dashboard.formatDate(seriesHoverInfo.time, tooltipFormat); // Dynamically reorder the hovercard for the current time point if the - // option is enabled, sort by yaxis by default. + // option is enabled. if (panel.tooltip.sort === 2) { seriesHoverInfo.sort(function(a, b) { return b.value - a.value;