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(`
|
||||
Array [
|
||||
Array [
|
||||
9997,
|
||||
9998,
|
||||
9999,
|
||||
],
|
||||
Array [
|
||||
-10,
|
||||
20,
|
||||
10,
|
||||
],
|
||||
Array [
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
],
|
||||
Array [
|
||||
20,
|
||||
20,
|
||||
20,
|
||||
],
|
||||
]
|
||||
`);
|
||||
Array [
|
||||
Array [
|
||||
9997,
|
||||
9998,
|
||||
9999,
|
||||
],
|
||||
Array [
|
||||
-10,
|
||||
20,
|
||||
10,
|
||||
],
|
||||
Array [
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
],
|
||||
Array [
|
||||
20,
|
||||
20,
|
||||
20,
|
||||
],
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
it('standard', () => {
|
||||
@ -289,14 +289,14 @@ describe('preparePlotData2', () => {
|
||||
10,
|
||||
],
|
||||
Array [
|
||||
0,
|
||||
30,
|
||||
20,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
],
|
||||
Array [
|
||||
20,
|
||||
50,
|
||||
40,
|
||||
30,
|
||||
30,
|
||||
30,
|
||||
],
|
||||
]
|
||||
`);
|
||||
@ -345,19 +345,19 @@ describe('preparePlotData2', () => {
|
||||
10,
|
||||
],
|
||||
Array [
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
],
|
||||
Array [
|
||||
-30,
|
||||
0,
|
||||
30,
|
||||
20,
|
||||
-10,
|
||||
],
|
||||
Array [
|
||||
-40,
|
||||
-10,
|
||||
-20,
|
||||
-20,
|
||||
-20,
|
||||
],
|
||||
Array [
|
||||
-30,
|
||||
-30,
|
||||
-30,
|
||||
],
|
||||
]
|
||||
`);
|
||||
@ -413,14 +413,14 @@ describe('preparePlotData2', () => {
|
||||
10,
|
||||
],
|
||||
Array [
|
||||
0,
|
||||
30,
|
||||
20,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
],
|
||||
Array [
|
||||
20,
|
||||
50,
|
||||
40,
|
||||
30,
|
||||
30,
|
||||
30,
|
||||
],
|
||||
Array [
|
||||
1,
|
||||
@ -580,13 +580,13 @@ describe('auto stacking groups', () => {
|
||||
"dir": -1,
|
||||
"series": Array [
|
||||
1,
|
||||
3,
|
||||
],
|
||||
},
|
||||
Object {
|
||||
"dir": 1,
|
||||
"series": Array [
|
||||
2,
|
||||
3,
|
||||
],
|
||||
},
|
||||
]
|
||||
@ -622,11 +622,6 @@ describe('auto stacking groups', () => {
|
||||
"series": Array [
|
||||
1,
|
||||
2,
|
||||
],
|
||||
},
|
||||
Object {
|
||||
"dir": -1,
|
||||
"series": Array [
|
||||
3,
|
||||
],
|
||||
},
|
||||
|
@ -115,16 +115,17 @@ export function getStackingGroups(frame: DataFrame) {
|
||||
// will this be stacked up or down after any transforms applied
|
||||
let vals = values.toArray();
|
||||
let transform = custom.transform;
|
||||
let firstValue = vals.find((v) => v != null);
|
||||
let stackDir =
|
||||
transform === GraphTransform.Constant
|
||||
? vals[0] > 0
|
||||
? firstValue >= 0
|
||||
? StackDirection.Pos
|
||||
: StackDirection.Neg
|
||||
: transform === GraphTransform.NegativeY
|
||||
? vals.some((v) => v > 0)
|
||||
? firstValue >= 0
|
||||
? StackDirection.Neg
|
||||
: StackDirection.Pos
|
||||
: vals.some((v) => v > 0)
|
||||
: firstValue >= 0
|
||||
? StackDirection.Pos
|
||||
: StackDirection.Neg;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user