mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TimeSeries: Add migration for Graph panel's transform series override (#46577)
This commit is contained in:
parent
93d37db4f0
commit
f452e068f0
@ -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`] = `
|
exports[`Graph Migrations twoYAxis 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"alert": undefined,
|
"alert": undefined,
|
||||||
|
@ -406,6 +406,24 @@ describe('Graph Migrations', () => {
|
|||||||
expect(panel.fieldConfig).toMatchSnapshot();
|
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 = {
|
const customColor = {
|
||||||
|
@ -27,6 +27,7 @@ import {
|
|||||||
ScaleDistribution,
|
ScaleDistribution,
|
||||||
StackingMode,
|
StackingMode,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
|
GraphTransform,
|
||||||
} from '@grafana/schema';
|
} from '@grafana/schema';
|
||||||
import { TimeSeriesOptions } from './types';
|
import { TimeSeriesOptions } from './types';
|
||||||
import { omitBy, pickBy, isNil, isNumber, isString } from 'lodash';
|
import { omitBy, pickBy, isNil, isNumber, isString } from 'lodash';
|
||||||
@ -242,6 +243,12 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case 'transform':
|
||||||
|
rule.properties.push({
|
||||||
|
id: 'custom.transform',
|
||||||
|
value: v === 'negative-Y' ? GraphTransform.NegativeY : GraphTransform.Constant,
|
||||||
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.log('Ignore override migration:', seriesOverride.alias, p, v);
|
console.log('Ignore override migration:', seriesOverride.alias, p, v);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user