TimeSeries: Old graph migration fix for series override lines: true (#74970)

This commit is contained in:
Torkel Ödegaard 2023-09-18 16:19:59 +02:00 committed by GitHub
parent a2e1a7e2f7
commit ab75fbd009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 4 deletions

View File

@ -623,6 +623,51 @@ describe('Graph Migrations', () => {
expect(panel.fieldConfig.defaults.custom.spanNulls).toBeTruthy(); expect(panel.fieldConfig.defaults.custom.spanNulls).toBeTruthy();
}); });
}); });
describe('seriesOverride lines: true', () => {
test('Should set displayMode', () => {
const old = {
angular: {
bars: true,
lines: false,
seriesOverrides: [
{
alias: 'A-series',
lines: true,
},
],
},
};
const panel = {} as PanelModel;
panel.options = graphPanelChangedHandler(panel, 'graph', old, prevFieldConfig);
expect(panel.fieldConfig.overrides[0]).toEqual({
matcher: { id: 'byName', options: 'A-series' },
properties: [{ id: 'custom.drawStyle', value: 'line' }],
});
});
});
describe('seriesOverride lines: false', () => {
test('Should set lineWidth 0', () => {
const old = {
angular: {
lines: true,
seriesOverrides: [
{
alias: 'A-series',
lines: false,
},
],
},
};
const panel = {} as PanelModel;
panel.options = graphPanelChangedHandler(panel, 'graph', old, prevFieldConfig);
expect(panel.fieldConfig.overrides[0]).toEqual({
matcher: { id: 'byName', options: 'A-series' },
properties: [{ id: 'custom.lineWidth', value: 0 }],
});
});
});
}); });
const customColor = { const customColor = {

View File

@ -222,10 +222,17 @@ export function graphToTimeseriesOptions(angular: any): {
} }
break; break;
case 'lines': case 'lines':
rule.properties.push({ if (v) {
id: 'custom.lineWidth', rule.properties.push({
value: 0, // don't show lines id: 'custom.drawStyle',
}); value: 'line',
});
} else {
rule.properties.push({
id: 'custom.lineWidth',
value: 0,
});
}
break; break;
case 'linewidth': case 'linewidth':
rule.properties.push({ rule.properties.push({