Commit 78d314a9 by Daniel Lee Committed by GitHub

Merge pull request #11140 from grafana/11131_right_legend_responsive

added media breakpoint to legend-right
parents 09df38d9 4f38d237
......@@ -15,6 +15,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
var seriesList;
var i;
var legendScrollbar;
const legendRightDefaultWidth = 10;
scope.$on('$destroy', function() {
if (legendScrollbar) {
......@@ -111,6 +112,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
}
function render() {
let legendWidth = elem.width();
if (!ctrl.panel.legend.show) {
elem.empty();
firstRender = true;
......@@ -163,7 +165,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
}
// render first time for getting proper legend height
if (!panel.legend.rightSide) {
if (!panel.legend.rightSide || (panel.legend.rightSide && legendWidth !== legendRightDefaultWidth)) {
renderLegendElement(tableHeaderElem);
elem.empty();
}
......@@ -227,6 +229,8 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
}
function renderLegendElement(tableHeaderElem) {
let legendWidth = elem.width();
var seriesElements = renderSeriesLegendElements();
if (panel.legend.alignAsTable) {
......@@ -238,7 +242,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
elem.append(seriesElements);
}
if (!panel.legend.rightSide) {
if (!panel.legend.rightSide || (panel.legend.rightSide && legendWidth !== legendRightDefaultWidth)) {
addScrollbar();
} else {
destroyScrollbar();
......@@ -263,6 +267,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
function destroyScrollbar() {
if (legendScrollbar) {
legendScrollbar.destroy();
legendScrollbar = undefined;
}
}
},
......
......@@ -4,24 +4,26 @@
height: 100%;
&--legend-right {
flex-direction: row;
@include media-breakpoint-up(sm) {
flex-direction: row;
.graph-legend {
flex: 0 1 10px;
max-height: 100%;
}
.graph-legend {
flex: 0 1 10px;
max-height: 100%;
}
.graph-legend-series {
display: block;
padding-left: 0px;
}
.graph-legend-series {
display: block;
padding-left: 0px;
}
.graph-legend-table {
width: auto;
}
.graph-legend-table {
width: auto;
}
.graph-legend-table .graph-legend-series {
display: table-row;
.graph-legend-table .graph-legend-series {
display: table-row;
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment