Old Graph migration: Preserve null values settings (#49493)

* Graph migration: Preserve null values settings

* Review
This commit is contained in:
Dominik Prokop 2022-05-25 12:22:28 +02:00 committed by GitHub
parent a67add5239
commit 30880e6e18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 9 deletions

View File

@ -12,7 +12,7 @@ Object {
"lineInterpolation": "stepAfter",
"lineWidth": 5,
"showPoints": "never",
"spanNulls": true,
"spanNulls": false,
},
"nullValueMode": "null",
"unit": "short",
@ -120,7 +120,7 @@ Object {
"lineInterpolation": "stepAfter",
"lineWidth": 1,
"showPoints": "never",
"spanNulls": true,
"spanNulls": false,
},
"nullValueMode": "null",
"unit": "short",
@ -176,7 +176,7 @@ Object {
"lineInterpolation": "stepAfter",
"lineWidth": 1,
"showPoints": "never",
"spanNulls": true,
"spanNulls": false,
},
"nullValueMode": "null",
"unit": "short",
@ -259,7 +259,7 @@ Object {
"lineInterpolation": "stepAfter",
"lineWidth": 5,
"showPoints": "never",
"spanNulls": true,
"spanNulls": false,
"stacking": Object {
"group": "A",
"mode": "normal",
@ -346,7 +346,7 @@ Object {
"lineInterpolation": "stepAfter",
"lineWidth": 5,
"showPoints": "never",
"spanNulls": true,
"spanNulls": false,
"stacking": Object {
"group": "A",
"mode": "normal",
@ -404,7 +404,7 @@ Object {
"lineInterpolation": "stepAfter",
"lineWidth": 1,
"showPoints": "never",
"spanNulls": true,
"spanNulls": false,
},
"displayName": "DISPLAY NAME",
"nullValueMode": "null",
@ -444,7 +444,7 @@ Object {
"lineInterpolation": "stepAfter",
"lineWidth": 5,
"showPoints": "never",
"spanNulls": true,
"spanNulls": false,
},
"nullValueMode": "null",
"unit": "short",
@ -554,7 +554,7 @@ Object {
"type": "log",
},
"showPoints": "never",
"spanNulls": true,
"spanNulls": false,
},
"decimals": 3,
"max": 1000,

View File

@ -426,6 +426,29 @@ describe('Graph Migrations', () => {
expect(panel.fieldConfig).toMatchSnapshot();
});
});
describe('null values', () => {
test('nullPointMode = null', () => {
const old: any = {
angular: {
nullPointMode: 'null',
},
};
const panel = {} as PanelModel;
panel.options = graphPanelChangedHandler(panel, 'graph', old, prevFieldConfig);
expect(panel.fieldConfig.defaults.custom.spanNulls).toBeFalsy();
});
test('nullPointMode = connected', () => {
const old: any = {
angular: {
nullPointMode: 'connected',
},
};
const panel = {} as PanelModel;
panel.options = graphPanelChangedHandler(panel, 'graph', old, prevFieldConfig);
expect(panel.fieldConfig.defaults.custom.spanNulls).toBeTruthy();
});
});
});
const customColor = {

View File

@ -296,7 +296,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
graph.fillOpacity = angular.fillGradient * 10; // fill is 0-10
}
graph.spanNulls = angular.nullPointMode === NullValueMode.Null;
graph.spanNulls = angular.nullPointMode === NullValueMode.Ignore;
if (angular.steppedLine) {
graph.lineInterpolation = LineInterpolation.StepAfter;