From ab75fbd009e55dc62639e8b20722540158b9b6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 18 Sep 2023 16:19:59 +0200 Subject: [PATCH] TimeSeries: Old graph migration fix for series override lines: true (#74970) --- .../panel/timeseries/migrations.test.ts | 45 +++++++++++++++++++ .../plugins/panel/timeseries/migrations.ts | 15 +++++-- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/public/app/plugins/panel/timeseries/migrations.test.ts b/public/app/plugins/panel/timeseries/migrations.test.ts index a266dc53985..48d08f11329 100644 --- a/public/app/plugins/panel/timeseries/migrations.test.ts +++ b/public/app/plugins/panel/timeseries/migrations.test.ts @@ -623,6 +623,51 @@ describe('Graph Migrations', () => { 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 = { diff --git a/public/app/plugins/panel/timeseries/migrations.ts b/public/app/plugins/panel/timeseries/migrations.ts index f1f0c852f7a..792851b7502 100644 --- a/public/app/plugins/panel/timeseries/migrations.ts +++ b/public/app/plugins/panel/timeseries/migrations.ts @@ -222,10 +222,17 @@ export function graphToTimeseriesOptions(angular: any): { } break; case 'lines': - rule.properties.push({ - id: 'custom.lineWidth', - value: 0, // don't show lines - }); + if (v) { + rule.properties.push({ + id: 'custom.drawStyle', + value: 'line', + }); + } else { + rule.properties.push({ + id: 'custom.lineWidth', + value: 0, + }); + } break; case 'linewidth': rule.properties.push({