Commit 614bd7f1 by Ben RUBSON Committed by Torkel Ödegaard

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
parent 6081c6cb
...@@ -49,7 +49,8 @@ function ($) { ...@@ -49,7 +49,8 @@ function ($) {
this.getMultiSeriesPlotHoverInfo = function(seriesList, pos) { this.getMultiSeriesPlotHoverInfo = function(seriesList, pos) {
var value, i, series, hoverIndex, hoverDistance, pointTime, yaxis; 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 //now we know the current X (j) position for X and Y values
var last_value = 0; //needed for stacked values var last_value = 0; //needed for stacked values
...@@ -60,14 +61,14 @@ function ($) { ...@@ -60,14 +61,14 @@ function ($) {
series = seriesList[i]; series = seriesList[i];
if (!series.data.length || (panel.legend.hideEmpty && series.allIsNull)) { if (!series.data.length || (panel.legend.hideEmpty && series.allIsNull)) {
// Init value & yaxis so that it does not brake series sorting // Init value so that it does not brake series sorting
results.push({ hidden: true, value: 0, yaxis: 0 }); results[0].push({ hidden: true, value: 0 });
continue; continue;
} }
if (!series.data.length || (panel.legend.hideZero && series.allIsZero)) { if (!series.data.length || (panel.legend.hideZero && series.allIsZero)) {
// Init value & yaxis so that it does not brake series sorting // Init value so that it does not brake series sorting
results.push({ hidden: true, value: 0, yaxis: 0 }); results[0].push({ hidden: true, value: 0 });
continue; continue;
} }
...@@ -110,18 +111,20 @@ function ($) { ...@@ -110,18 +111,20 @@ function ($) {
yaxis = series.yaxis.n; yaxis = series.yaxis.n;
} }
results.push({ results[yaxis].push({
value: value, value: value,
hoverIndex: hoverIndex, hoverIndex: hoverIndex,
color: series.color, color: series.color,
label: series.label, label: series.label,
time: pointTime, time: pointTime,
distance: hoverDistance, distance: hoverDistance,
yaxis: yaxis,
index: i index: i
}); });
} }
// Contat the 3 sub-arrays
results = results[0].concat(results[1],results[2]);
// Time of the point closer to pointer // Time of the point closer to pointer
results.time = minTime; results.time = minTime;
...@@ -172,7 +175,7 @@ function ($) { ...@@ -172,7 +175,7 @@ function ($) {
absoluteTime = dashboard.formatDate(seriesHoverInfo.time, tooltipFormat); absoluteTime = dashboard.formatDate(seriesHoverInfo.time, tooltipFormat);
// Dynamically reorder the hovercard for the current time point if the // 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) { if (panel.tooltip.sort === 2) {
seriesHoverInfo.sort(function(a, b) { seriesHoverInfo.sort(function(a, b) {
return b.value - a.value; return b.value - a.value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment