diff --git a/public/app/plugins/panel/timeseries/__snapshots__/migrations.test.ts.snap b/public/app/plugins/panel/timeseries/__snapshots__/migrations.test.ts.snap index 1862a91b058..54174fbd013 100644 --- a/public/app/plugins/panel/timeseries/__snapshots__/migrations.test.ts.snap +++ b/public/app/plugins/panel/timeseries/__snapshots__/migrations.test.ts.snap @@ -481,6 +481,56 @@ Object { } `; +exports[`Graph Migrations transforms should preserve "constant" transform 1`] = ` +Object { + "defaults": Object { + "custom": Object { + "drawStyle": "points", + "spanNulls": false, + }, + }, + "overrides": Array [ + Object { + "matcher": Object { + "id": "byName", + "options": "out", + }, + "properties": Array [ + Object { + "id": "custom.transform", + "value": "constant", + }, + ], + }, + ], +} +`; + +exports[`Graph Migrations transforms should preserve "negative-Y" transform 1`] = ` +Object { + "defaults": Object { + "custom": Object { + "drawStyle": "points", + "spanNulls": false, + }, + }, + "overrides": Array [ + Object { + "matcher": Object { + "id": "byName", + "options": "out", + }, + "properties": Array [ + Object { + "id": "custom.transform", + "value": "negative-Y", + }, + ], + }, + ], +} +`; + exports[`Graph Migrations twoYAxis 1`] = ` Object { "alert": undefined, diff --git a/public/app/plugins/panel/timeseries/migrations.test.ts b/public/app/plugins/panel/timeseries/migrations.test.ts index 06bc7d61fac..da9cf0275d4 100644 --- a/public/app/plugins/panel/timeseries/migrations.test.ts +++ b/public/app/plugins/panel/timeseries/migrations.test.ts @@ -406,6 +406,24 @@ describe('Graph Migrations', () => { expect(panel.fieldConfig).toMatchSnapshot(); }); }); + + describe('transforms', () => { + test.each(['negative-Y', 'constant'])('should preserve %p transform', (transform) => { + const old: any = { + angular: { + seriesOverrides: [ + { + alias: 'out', + transform, + }, + ], + }, + }; + const panel = {} as PanelModel; + panel.options = graphPanelChangedHandler(panel, 'graph', old, prevFieldConfig); + expect(panel.fieldConfig).toMatchSnapshot(); + }); + }); }); const customColor = { diff --git a/public/app/plugins/panel/timeseries/migrations.ts b/public/app/plugins/panel/timeseries/migrations.ts index c62b758811e..8b336f8d3c1 100644 --- a/public/app/plugins/panel/timeseries/migrations.ts +++ b/public/app/plugins/panel/timeseries/migrations.ts @@ -27,6 +27,7 @@ import { ScaleDistribution, StackingMode, SortOrder, + GraphTransform, } from '@grafana/schema'; import { TimeSeriesOptions } from './types'; import { omitBy, pickBy, isNil, isNumber, isString } from 'lodash'; @@ -242,6 +243,12 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour }, }); break; + case 'transform': + rule.properties.push({ + id: 'custom.transform', + value: v === 'negative-Y' ? GraphTransform.NegativeY : GraphTransform.Constant, + }); + break; default: console.log('Ignore override migration:', seriesOverride.alias, p, v); }