mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add migration from old graph panel
This commit is contained in:
parent
3833d79911
commit
33b5a90b66
@ -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,
|
||||
|
@ -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 = {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user