Commit 6911e184 by Torkel Ödegaard

New legend display option 'Right side', will show legend to the right of the graph (Closes #556)

parent 96272125
...@@ -3,6 +3,7 @@ vNext ...@@ -3,6 +3,7 @@ vNext
**New features or improvements** **New features or improvements**
- Allow [[..]] filter notation in all text panels (markdown/html/text) (Issue #511) - Allow [[..]] filter notation in all text panels (markdown/html/text) (Issue #511)
- New legend display option "Align as table" (Issue #136) - New legend display option "Align as table" (Issue #136)
- New legend display option "Right side", will show legend to the right of the graph (Issue #556)
- Enhanced InfluxDB series aliasing (legend names) with pattern replacements (Issue #525) - Enhanced InfluxDB series aliasing (legend names) with pattern replacements (Issue #525)
**Changes** **Changes**
......
...@@ -17,6 +17,7 @@ function (angular, $, kbn, moment, _) { ...@@ -17,6 +17,7 @@ function (angular, $, kbn, moment, _) {
link: function(scope, elem) { link: function(scope, elem) {
var data, plot, annotations; var data, plot, annotations;
var hiddenData = {}; var hiddenData = {};
var legendSideLastValue = null;
scope.$on('refresh',function() { scope.$on('refresh',function() {
if (scope.otherPanelInFullscreenMode()) { return; } if (scope.otherPanelInFullscreenMode()) { return; }
...@@ -55,7 +56,7 @@ function (angular, $, kbn, moment, _) { ...@@ -55,7 +56,7 @@ function (angular, $, kbn, moment, _) {
height = height - 32; // subtract panel title bar height = height - 32; // subtract panel title bar
if (scope.panel.legend.show) { if (scope.panel.legend.show && !scope.panel.legend.rightSide) {
height = height - 21; // subtract one line legend height = height - 21; // subtract one line legend
} }
...@@ -135,6 +136,7 @@ function (angular, $, kbn, moment, _) { ...@@ -135,6 +136,7 @@ function (angular, $, kbn, moment, _) {
yaxes: [], yaxes: [],
xaxis: {}, xaxis: {},
grid: { grid: {
minBorderMargin: 0,
markings: [], markings: [],
backgroundColor: null, backgroundColor: null,
borderWidth: 0, borderWidth: 0,
...@@ -161,9 +163,30 @@ function (angular, $, kbn, moment, _) { ...@@ -161,9 +163,30 @@ function (angular, $, kbn, moment, _) {
addAnnotations(options); addAnnotations(options);
configureAxisOptions(data, options); configureAxisOptions(data, options);
plot = $.plot(elem, data, options); // if legend is to the right delay plot draw a few milliseconds
// so the legend width calculation can be done
if (shouldDelayDraw(panel)) {
console.log('delay');
legendSideLastValue = panel.legend.rightSide;
setTimeout(function() {
plot = $.plot(elem, data, options);
addAxisLabels();
}, 50);
}
else {
plot = $.plot(elem, data, options);
addAxisLabels();
}
}
addAxisLabels(); function shouldDelayDraw(panel) {
if (panel.legend.rightSide) {
return true;
}
if (legendSideLastValue !== null && panel.legend.rightSide !== legendSideLastValue) {
return true;
}
return false;
} }
function addTimeAxis(options) { function addTimeAxis(options) {
......
...@@ -33,10 +33,6 @@ ...@@ -33,10 +33,6 @@
<label class="small">Max / <a ng-click="toggleGridMinMax('rightMax')">Auto <i class="icon-star" ng-show="_.isNull(panel.grid.rightMax)"></i></a></label> <label class="small">Max / <a ng-click="toggleGridMinMax('rightMax')">Auto <i class="icon-star" ng-show="_.isNull(panel.grid.rightMax)"></i></a></label>
<input type="number" class="input-small" ng-model="panel.grid.rightMax" ng-change="render()" ng-model-onblur /> <input type="number" class="input-small" ng-model="panel.grid.rightMax" ng-change="render()" ng-model-onblur />
</div> </div>
<div class="editor-option">
<label class="small">Label</label>
<input ng-change="get_data()" ng-model-onblur placeholder="" type="text" class="input-medium" ng-model="panel.rightYAxisLabel">
</div>
</div> </div>
</div> </div>
...@@ -53,6 +49,9 @@ ...@@ -53,6 +49,9 @@
<div class="editor-option"> <div class="editor-option">
<label class="small">Align as table</label><input type="checkbox" ng-model="panel.legend.alignAsTable" ng-checked="panel.legend.alignAsTable"> <label class="small">Align as table</label><input type="checkbox" ng-model="panel.legend.alignAsTable" ng-checked="panel.legend.alignAsTable">
</div> </div>
<div class="editor-option">
<label class="small">Right side</label><input type="checkbox" ng-model="panel.legend.rightSide" ng-change="render();" ng-checked="panel.legend.rightSide">
</div>
</div> </div>
<div class="section" ng-if="panel.legend.values"> <div class="section" ng-if="panel.legend.values">
......
<!-- <span ng-class="{'pull-right': series.yaxis === 2, 'hidden-series': hiddenSeries[series.alias]}"
ng-repeat='series in legend'
class="histogram-legend">
<i class='icon-minus pointer'
ng-style="{color: series.color}"
bs-popover="'colorPopup.html'"
>
</i>
<span class='small histogram-legend-item'>
<a ng-click="toggleSeries(series, $event)" data-unique="1" data-placement="{{series.yaxis === 2 ? 'bottomRight' : 'bottomLeft'}}">
{{series.alias}}
</a>
<span ng-if="panel.legend.values">
<span ng-show="panel.legend.current">
&nbsp;&nbsp;Current: {{series.current}}&nbsp;
</span>
<span ng-show="panel.legend.min">
&nbsp;&nbsp;Min: {{series.min}}&nbsp;
</span>
<span ng-show="panel.legend.max">
&nbsp;&nbsp;Max: {{series.max}}&nbsp;
</span>
<span ng-show="panel.legend.total">
&nbsp;&nbsp;Total: {{series.total}}&nbsp;
</span>
<span ng-show="panel.legend.avg">
&nbsp;&nbsp;Avg: {{series.avg}}&nbsp;
</span>
</span>
</span>
</span> -->
<section class="graph-legend" ng-class="{'graph-legend-table': panel.legend.alignAsTable}"> <section class="graph-legend" ng-class="{'graph-legend-table': panel.legend.alignAsTable}">
<div class="graph-legend-series" <div class="graph-legend-series"
......
...@@ -3,19 +3,45 @@ ...@@ -3,19 +3,45 @@
style="min-height:{{panel.height || row.height}}" style="min-height:{{panel.height || row.height}}"
ng-class="{'panel-fullscreen': fullscreen}"> ng-class="{'panel-fullscreen': fullscreen}">
<div style="position: relative"> <!-- <table style="width: 100%">
<tr>
<td style="width: 100%">
<div style="position: relative">
<div ng-if="datapointsWarning" class="datapoints-warning"> <div ng-if="datapointsWarning" class="datapoints-warning">
<span class="small" ng-show="!datapointsCount">No datapoints <tip>Can be caused by timezone mismatch between browser and graphite server</tip></span> <span class="small" ng-show="!datapointsCount">No datapoints <tip>Can be caused by timezone mismatch between browser and graphite server</tip></span>
<span class="small" ng-show="datapointsOutside">Datapoints outside time range <tip>Can be caused by timezone mismatch between browser and graphite server</tip></span> <span class="small" ng-show="datapointsOutside">Datapoints outside time range <tip>Can be caused by timezone mismatch between browser and graphite server</tip></span>
</div> </div>
<div grafana-graph class="pointer histogram-chart"> <div grafana-graph class="pointer histogram-chart">
</div> </div>
</div> </div>
</td>
<td>
<div ng-if="panel.legend.show" ng-include="'app/panels/graph/legend.html'">
</div>
</td>
</tr>
</table> -->
<div class="graph-wrapper" ng-class="{'graph-legend-rightside': panel.legend.rightSide}">
<div class="graph-canvas-wrapper">
<div ng-if="panel.legend.show" ng-include="'app/panels/graph/legend.html'"> <div ng-if="datapointsWarning" class="datapoints-warning">
<span class="small" ng-show="!datapointsCount">No datapoints <tip>Can be caused by timezone mismatch between browser and graphite server</tip></span>
<span class="small" ng-show="datapointsOutside">Datapoints outside time range <tip>Can be caused by timezone mismatch between browser and graphite server</tip></span>
</div>
<div grafana-graph class="pointer histogram-chart">
</div>
</div>
<div class="graph-legend-wrapper"
ng-if="panel.legend.show"
ng-include="'app/panels/graph/legend.html'">
</div>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
......
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
<div class="pull-left metrics-editor-help" style="margin-top: 30px;"> <div class="pull-left metrics-editor-help" style="margin-top: 30px;">
<div class="span6"> <div class="span6">
<span> <span class="pointer">
<i class="icon-question-sign"></i> alias patterns: <i class="icon-question-sign"></i> alias patterns:
</span> </span>
<ul class="hide"> <ul class="hide">
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
@import "submenu.less"; @import "submenu.less";
@import "legend.less"; @import "graph.less";
@import "bootstrap-tagsinput.less"; @import "bootstrap-tagsinput.less";
.hide-controls { .hide-controls {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
.graph-legend-alias, .graph-legend-alias,
.graph-legend-value { .graph-legend-value {
display: inline-block; display: inline-block;
white-space: nowrap;
} }
.graph-legend-series { .graph-legend-series {
...@@ -61,6 +62,41 @@ ...@@ -61,6 +62,41 @@
} }
} }
.graph-legend-rightside {
&.graph-wrapper {
display: table;
width: 100%;
}
.graph-canvas-wrapper {
display: table-cell;
width: 100%;
position: relative;
}
.graph-legend-wrapper {
display: table-cell;
vertical-align: top;
position: relative;
left: -4px;
}
.graph-legend {
margin: 0;
}
.graph-legend-series {
display: block;
padding-left: 0px;
}
.graph-legend-table .graph-legend-series {
display: table-row;
}
}
.graph-legend-series-hidden { .graph-legend-series-hidden {
a { a {
color: darken(@linkColor, 45%); color: darken(@linkColor, 45%);
...@@ -86,4 +122,4 @@ ...@@ -86,4 +122,4 @@
.editor-row { .editor-row {
padding: 5px; padding: 5px;
} }
} }
\ No newline at end of file
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