Skip to content

Commit

Permalink
fix elastic#572 adding a legendPosition setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Aug 13, 2016
1 parent adfcf06 commit 567d557
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/core_plugins/kbn_vislib_vis_types/public/area.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function HistogramVisType(Private) {
shareYAxis: true,
addTooltip: true,
addLegend: true,
legendPosition: 'right',
smoothLines: false,
scale: 'linear',
interpolate: 'linear',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<div>
<div class="vis-option-item" ng-if="vis.params.showLegend">
<label>
Legend Position
<select
class="form-control"
ng-model="vis.params.legendPosition"
ng-options="position for position in ['top', 'left', 'right', 'bottom']"
>
</select>
</label>
</div>
<div class="vis-option-item">
<label>
<input type="checkbox" ng-model="vis.params.addTooltip">
Expand Down
1 change: 1 addition & 0 deletions src/core_plugins/kbn_vislib_vis_types/public/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function HistogramVisType(Private) {
shareYAxis: true,
addTooltip: true,
addLegend: true,
legendPosition: 'right',
scale: 'linear',
mode: 'stacked',
times: [],
Expand Down
1 change: 1 addition & 0 deletions src/core_plugins/kbn_vislib_vis_types/public/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function HistogramVisType(Private) {
shareYAxis: true,
addTooltip: true,
addLegend: true,
legendPosition: 'right',
showCircles: true,
smoothLines: false,
interpolate: 'linear',
Expand Down
1 change: 1 addition & 0 deletions src/core_plugins/kbn_vislib_vis_types/public/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function HistogramVisType(Private) {
shareYAxis: true,
addTooltip: true,
addLegend: true,
legendPosition: 'right',
isDonut: false
},
editor: pieTemplate
Expand Down
24 changes: 24 additions & 0 deletions src/ui/public/vislib/styles/_legend.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ visualize-legend {
flex-direction: row;
padding-top: 5px;

.vis-container--legend-left & {
flex-direction: row-reverse;
}
.vis-container--legend-right & {
flex-direction: row;
}
.vis-container--legend-top & {
flex-direction: column-reverse;
width: 100%;
}
.vis-container--legend-bottom & {
flex-direction: column;
width: 100%;
}

.header {
cursor: pointer;
width: 15px;
Expand Down Expand Up @@ -54,6 +69,15 @@ visualize-legend {
text-align: left;

flex-direction: column;

.vis-container--legend-top &,
.vis-container--legend-bottom & {
width: auto;

li {
display: inline-block;
}
}
}

.legend-ul.hidden {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/visualize/visualize.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h4>No results found</h4>
</div>
<div class="item bottom"></div>
</div>
<div div ng-hide="showNoResultsMessage()" class="vis-container">
<div div ng-hide="showNoResultsMessage()" class="vis-container vis-container--legend-{{vis.params.legendPosition}}">
<div
ng-style="loadingStyle"
ng-class="{ loading: vis.type.requiresSearch && searchSource.activeFetchCount > 0 }"
Expand Down
8 changes: 8 additions & 0 deletions src/ui/public/visualize/visualize.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ uiModules
return Boolean(requiresSearch && isZeroHits && shouldShowMessage);
};

$scope.showLegendTopOrLeft = function () {
return $scope.vis.params.legendPosition === 'top' || $scope.vis.params.legendPosition === 'left';
};

$scope.showLegendBottomOrRight = function () {
return $scope.vis.params.legendPosition === 'bottom' || $scope.vis.params.legendPosition === 'right';
};

$scope.spy = {};
$scope.spy.mode = ($scope.uiState) ? $scope.uiState.get('spy.mode', {}) : {};

Expand Down
13 changes: 13 additions & 0 deletions src/ui/public/visualize/visualize.less
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ visualize {
-webkit-transition: opacity 0.01s;
transition: opacity 0.01s;

&.vis-container--legend-left {
flex-direction: row-reverse;
}
&.vis-container--legend-right {
flex-direction: row;
}
&.vis-container--legend-top {
flex-direction: column-reverse;
}
&.vis-container--legend-bottom {
flex-direction: column;
}

&.spy-only {
display: none;
}
Expand Down

0 comments on commit 567d557

Please sign in to comment.