mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TimeSeries: use positive stacks for 0-valued series (#48197)
This commit is contained in:
parent
ebe34ddcba
commit
0ca32f0c61
@ -230,29 +230,29 @@ describe('preparePlotData2', () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
expect(preparePlotData2(df, getStackingGroups(df))).toMatchInlineSnapshot(`
|
expect(preparePlotData2(df, getStackingGroups(df))).toMatchInlineSnapshot(`
|
||||||
Array [
|
Array [
|
||||||
Array [
|
Array [
|
||||||
9997,
|
9997,
|
||||||
9998,
|
9998,
|
||||||
9999,
|
9999,
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
-10,
|
-10,
|
||||||
20,
|
20,
|
||||||
10,
|
10,
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
10,
|
10,
|
||||||
10,
|
10,
|
||||||
10,
|
10,
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
20,
|
20,
|
||||||
20,
|
20,
|
||||||
20,
|
20,
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('standard', () => {
|
it('standard', () => {
|
||||||
@ -289,14 +289,14 @@ describe('preparePlotData2', () => {
|
|||||||
10,
|
10,
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
0,
|
10,
|
||||||
30,
|
10,
|
||||||
20,
|
10,
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
20,
|
30,
|
||||||
50,
|
30,
|
||||||
40,
|
30,
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
`);
|
`);
|
||||||
@ -345,19 +345,19 @@ describe('preparePlotData2', () => {
|
|||||||
10,
|
10,
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
],
|
||||||
|
Array [
|
||||||
|
-30,
|
||||||
0,
|
0,
|
||||||
30,
|
-10,
|
||||||
20,
|
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
|
-40,
|
||||||
|
-10,
|
||||||
-20,
|
-20,
|
||||||
-20,
|
|
||||||
-20,
|
|
||||||
],
|
|
||||||
Array [
|
|
||||||
-30,
|
|
||||||
-30,
|
|
||||||
-30,
|
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
`);
|
`);
|
||||||
@ -413,14 +413,14 @@ describe('preparePlotData2', () => {
|
|||||||
10,
|
10,
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
0,
|
10,
|
||||||
30,
|
10,
|
||||||
20,
|
10,
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
20,
|
30,
|
||||||
50,
|
30,
|
||||||
40,
|
30,
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
1,
|
1,
|
||||||
@ -580,13 +580,13 @@ describe('auto stacking groups', () => {
|
|||||||
"dir": -1,
|
"dir": -1,
|
||||||
"series": Array [
|
"series": Array [
|
||||||
1,
|
1,
|
||||||
3,
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"dir": 1,
|
"dir": 1,
|
||||||
"series": Array [
|
"series": Array [
|
||||||
2,
|
2,
|
||||||
|
3,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -622,11 +622,6 @@ describe('auto stacking groups', () => {
|
|||||||
"series": Array [
|
"series": Array [
|
||||||
1,
|
1,
|
||||||
2,
|
2,
|
||||||
],
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"dir": -1,
|
|
||||||
"series": Array [
|
|
||||||
3,
|
3,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -115,16 +115,17 @@ export function getStackingGroups(frame: DataFrame) {
|
|||||||
// will this be stacked up or down after any transforms applied
|
// will this be stacked up or down after any transforms applied
|
||||||
let vals = values.toArray();
|
let vals = values.toArray();
|
||||||
let transform = custom.transform;
|
let transform = custom.transform;
|
||||||
|
let firstValue = vals.find((v) => v != null);
|
||||||
let stackDir =
|
let stackDir =
|
||||||
transform === GraphTransform.Constant
|
transform === GraphTransform.Constant
|
||||||
? vals[0] > 0
|
? firstValue >= 0
|
||||||
? StackDirection.Pos
|
? StackDirection.Pos
|
||||||
: StackDirection.Neg
|
: StackDirection.Neg
|
||||||
: transform === GraphTransform.NegativeY
|
: transform === GraphTransform.NegativeY
|
||||||
? vals.some((v) => v > 0)
|
? firstValue >= 0
|
||||||
? StackDirection.Neg
|
? StackDirection.Neg
|
||||||
: StackDirection.Pos
|
: StackDirection.Pos
|
||||||
: vals.some((v) => v > 0)
|
: firstValue >= 0
|
||||||
? StackDirection.Pos
|
? StackDirection.Pos
|
||||||
: StackDirection.Neg;
|
: StackDirection.Neg;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user