mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
HeatMap: Sort y buckets when all bucket names are numeric (#65322)
This commit is contained in:
parent
1e098d2a4c
commit
6f4232bee3
@ -650,13 +650,13 @@ function transformToHistogramOverTime(seriesList: DataFrame[]) {
|
||||
return seriesList;
|
||||
}
|
||||
|
||||
function sortSeriesByLabel(s1: DataFrame, s2: DataFrame): number {
|
||||
export function sortSeriesByLabel(s1: DataFrame, s2: DataFrame): number {
|
||||
let le1, le2;
|
||||
|
||||
try {
|
||||
// fail if not integer. might happen with bad queries
|
||||
le1 = parseSampleValue(s1.name ?? '');
|
||||
le2 = parseSampleValue(s2.name ?? '');
|
||||
le1 = parseSampleValue(s1.name ?? s1.fields[1].name);
|
||||
le2 = parseSampleValue(s2.name ?? s2.fields[1].name);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return 0;
|
||||
|
@ -19,6 +19,7 @@ import {
|
||||
readHeatmapRowsCustomMeta,
|
||||
rowsToCellsHeatmap,
|
||||
} from 'app/features/transformers/calculateHeatmap/heatmap';
|
||||
import { parseSampleValue, sortSeriesByLabel } from 'app/plugins/datasource/prometheus/result_transformer';
|
||||
|
||||
import { CellValues, PanelOptions } from './types';
|
||||
import { boundedMinMax } from './utils';
|
||||
@ -94,6 +95,14 @@ export function prepareHeatmapData(
|
||||
// Everything past here assumes a field for each row in the heatmap (buckets)
|
||||
if (!rowsHeatmap) {
|
||||
if (frames.length > 1) {
|
||||
let allNamesNumeric = frames.every(
|
||||
(frame) => !Number.isNaN(parseSampleValue(frame.name ?? frame.fields[1].name))
|
||||
);
|
||||
|
||||
if (allNamesNumeric) {
|
||||
frames.sort(sortSeriesByLabel);
|
||||
}
|
||||
|
||||
rowsHeatmap = [
|
||||
outerJoinDataFrames({
|
||||
frames,
|
||||
|
Loading…
Reference in New Issue
Block a user