From 10fbfcb1d3ed3f42f574e11a18eecf2c82879636 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 12 Dec 2017 19:02:19 +0300 Subject: [PATCH] Fix graph legend scroll (#10169) * graph panel: fix legend scroll * graph panel: enable scroll for table legend * graph panel: fix legend right side toggle --- public/app/plugins/panel/graph/legend.ts | 30 ++++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/public/app/plugins/panel/graph/legend.ts b/public/app/plugins/panel/graph/legend.ts index 1a445068b97..791ebf761ae 100644 --- a/public/app/plugins/panel/graph/legend.ts +++ b/public/app/plugins/panel/graph/legend.ts @@ -220,12 +220,32 @@ module.directive('graphLegend', function(popoverSrv, $timeout) { elem.append(tbodyElem); } else { elem.append(seriesElements); + } - if (!legendScrollbar) { - legendScrollbar = new PerfectScrollbar(elem[0]); - } else { - legendScrollbar.update(); - } + if (!panel.legend.rightSide) { + addScrollbar(); + } else { + destroyScrollbar(); + } + } + + function addScrollbar() { + const scrollbarOptions = { + // Number of pixels the content height can surpass the container height without enabling the scroll bar. + scrollYMarginOffset: 2, + suppressScrollX: true + }; + + if (!legendScrollbar) { + legendScrollbar = new PerfectScrollbar(elem[0], scrollbarOptions); + } else { + legendScrollbar.update(); + } + } + + function destroyScrollbar() { + if (legendScrollbar) { + legendScrollbar.destroy(); } } }