From d1b67847a249d0dcb9da440a5e9dfdeb4e1f0242 Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Thu, 25 Apr 2024 12:51:07 -0500 Subject: [PATCH] Migrations: Graph (old) percent stacked (#84335) --- public/app/plugins/panel/timeseries/migrations.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/panel/timeseries/migrations.ts b/public/app/plugins/panel/timeseries/migrations.ts index c27205c84a69..edb9eba6a574 100644 --- a/public/app/plugins/panel/timeseries/migrations.ts +++ b/public/app/plugins/panel/timeseries/migrations.ts @@ -339,9 +339,22 @@ export function graphToTimeseriesOptions(angular: any): { if (angular.stack) { graph.stacking = { - mode: StackingMode.Normal, + mode: angular.percentage ? StackingMode.Percent : StackingMode.Normal, group: defaultGraphConfig.stacking!.group, }; + + if (angular.percentage) { + if (angular.yaxis) { + delete y1.min; + delete y1.max; + + // TimeSeries currently uses 0-1 for percent, so allowing zero leaves only top and bottom ticks. + // removing it feels better. probably should fix in TimeSeries, but let's kick it down the road + if (y1.decimals === 0) { + delete y1.decimals; + } + } + } } y1.custom = omitBy(graph, isNil);