From 069d718b840ae8fb1194fe6402930ec370649191 Mon Sep 17 00:00:00 2001 From: Gaurav M Shah Date: Fri, 1 Nov 2019 19:16:35 +0530 Subject: [PATCH] Graph: Added series override option to have hidden series be persisted (#20124) --- docs/sources/features/panels/graph.md | 1 + public/app/core/time_series2.ts | 4 ++++ public/app/plugins/panel/graph/module.ts | 8 ++++++++ public/app/plugins/panel/graph/series_overrides_ctrl.ts | 1 + 4 files changed, 14 insertions(+) diff --git a/docs/sources/features/panels/graph.md b/docs/sources/features/panels/graph.md index 57d81218744..5923d0a6dbb 100644 --- a/docs/sources/features/panels/graph.md +++ b/docs/sources/features/panels/graph.md @@ -137,6 +137,7 @@ Display styles control visual properties of the graph. - **Line Width** - The width of the line for a series (default 1). - **Staircase** - Draws adjacent points as staircase - **Points Radius** - Adjust the size of points when *Points* are selected as *Draw Mode*. +- **Hidden Series** - Hide series by default in graph. #### Hover tooltip diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index 26577900f28..40a5ff03837 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -94,6 +94,7 @@ export default class TimeSeries { isOutsideRange: boolean; lines: any; + hiddenSeries: boolean; dashes: any; bars: any; points: any; @@ -200,6 +201,9 @@ export default class TimeSeries { if (override.yaxis !== void 0) { this.yaxis = override.yaxis; } + if (override.hiddenSeries !== void 0) { + this.hiddenSeries = override.hiddenSeries; + } } } diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index e2316ade455..60c0aa02c23 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -27,6 +27,7 @@ class GraphCtrl extends MetricsPanelCtrl { renderError: boolean; hiddenSeries: any = {}; + hiddenSeriesTainted = false; seriesList: TimeSeries[] = []; dataList: DataFrame[] = []; annotations: any = []; @@ -84,6 +85,8 @@ class GraphCtrl extends MetricsPanelCtrl { linewidth: 1, // show/hide dashed line dashes: false, + // show/hide line + hiddenSeries: false, // length of a dash dashLength: 10, // length of space between two dashes @@ -165,6 +168,7 @@ class GraphCtrl extends MetricsPanelCtrl { this.addEditorTab('Thresholds & Time Regions', 'public/app/plugins/panel/graph/tab_thresholds_time_regions.html'); this.addEditorTab('Data links', 'public/app/plugins/panel/graph/tab_drilldown_links.html'); this.subTabIndex = 0; + this.hiddenSeriesTainted = false; } onInitPanelActions(actions: any[]) { @@ -267,6 +271,9 @@ class GraphCtrl extends MetricsPanelCtrl { if (series.unit) { this.panel.yaxes[series.yaxis - 1].format = series.unit; } + if (this.hiddenSeriesTainted === false && series.hiddenSeries === true) { + this.hiddenSeries[series.alias] = true; + } } } @@ -277,6 +284,7 @@ class GraphCtrl extends MetricsPanelCtrl { }; onToggleSeries = (hiddenSeries: any) => { + this.hiddenSeriesTainted = true; this.hiddenSeries = hiddenSeries; this.render(); }; diff --git a/public/app/plugins/panel/graph/series_overrides_ctrl.ts b/public/app/plugins/panel/graph/series_overrides_ctrl.ts index a3a1f55d2b0..96524b9ac1b 100644 --- a/public/app/plugins/panel/graph/series_overrides_ctrl.ts +++ b/public/app/plugins/panel/graph/series_overrides_ctrl.ts @@ -106,6 +106,7 @@ export function SeriesOverridesCtrl($scope: any, $element: JQuery, popoverSrv: a $scope.addOverrideOption('Fill below to', 'fillBelowTo', $scope.getSeriesNames()); $scope.addOverrideOption('Staircase line', 'steppedLine', [true, false]); $scope.addOverrideOption('Dashes', 'dashes', [true, false]); + $scope.addOverrideOption('Hidden Series', 'hiddenSeries', [true, false]); $scope.addOverrideOption('Dash Length', 'dashLength', [ 1, 2,