Skip to content

Commit

Permalink
adding new options to kibana visualizations
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Feb 15, 2017
1 parent 6d642ca commit ec9a614
Show file tree
Hide file tree
Showing 19 changed files with 1,282 additions and 70 deletions.
104 changes: 78 additions & 26 deletions src/core_plugins/kbn_vislib_vis_types/public/area.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import VislibVisTypeVislibVisTypeProvider from 'ui/vislib_vis_type/vislib_vis_type';
import VisSchemasProvider from 'ui/vis/schemas';
import areaTemplate from 'plugins/kbn_vislib_vis_types/editors/area.html';
import pointSeriesTemplate from 'plugins/kbn_vislib_vis_types/editors/point_series.html';

export default function HistogramVisType(Private) {
export default function PointSeriesVisType(Private) {
const VislibVisType = Private(VislibVisTypeVislibVisTypeProvider);
const Schemas = Private(VisSchemasProvider);

Expand All @@ -11,35 +11,83 @@ export default function HistogramVisType(Private) {
title: 'Area chart',
icon: 'fa-area-chart',
description: 'Great for stacked timelines in which the total of all series is more important ' +
'than comparing any two or more series. Less useful for assessing the relative change of ' +
'unrelated data points as changes in a series lower down the stack will have a difficult to gauge ' +
'effect on the series above it.',
'than comparing any two or more series. Less useful for assessing the relative change of ' +
'unrelated data points as changes in a series lower down the stack will have a difficult to gauge ' +
'effect on the series above it.',
params: {
defaults: {
grid: {
show: false,
categoryLines: true,
style: {
color: '#eee'
}
},
categoryAxes: [
{
id: 'CategoryAxis-1',
type: 'category',
position: 'bottom',
show: true,
style: {
},
scale: {
type: 'linear'
},
labels: {
show: true
},
title: {}
}
],
valueAxes: [
{
id: 'ValueAxis-1',
type: 'value',
position: 'left',
show: true,
style: {
},
scale: {
type: 'linear',
mode: 'normal'
},
labels: {
show: true,
rotate: 0,
filter: false,
truncate: 100
},
title: {}
}
],
seriesParams: [{
show: true,
type: 'area',
mode: 'stacked',
data: {
label: 'Count'
}
}],
addTooltip: true,
addLegend: true,
legendPosition: 'right',
scale: 'linear',
showCircles: true,
smoothLines: false,
interpolate: 'linear',
mode: 'stacked',
scale: 'linear',
drawLinesBetweenPoints: true,
radiusRatio: 9,
times: [],
addTimeMarker: false,
defaultYExtents: false,
setYExtents: false
},
legendPositions: [{
value: 'left',
text: 'left',
}, {
value: 'right',
text: 'right',
}, {
value: 'top',
text: 'top',
}, {
value: 'bottom',
text: 'bottom',
}],
positions: ['top', 'left', 'right', 'bottom'],
chartTypes: ['line', 'area', 'histogram'],
axisModes: ['normal', 'percentage', 'wiggle', 'silhouette'],
scaleTypes: ['linear', 'log', 'square root'],
chartModes: ['normal', 'stacked'],
interpolationModes: [{
value: 'linear',
text: 'straight',
Expand All @@ -50,22 +98,26 @@ export default function HistogramVisType(Private) {
value: 'step-after',
text: 'stepped',
}],
scales: ['linear', 'log', 'square root'],
modes: ['stacked', 'overlap', 'percentage', 'wiggle', 'silhouette'],
editor: areaTemplate
editor: pointSeriesTemplate
},
implementsRenderComplete: true,
schemas: new Schemas([
{
group: 'metrics',
name: 'metric',
title: 'Y-Axis',
min: 1,
aggFilter: '!std_dev',
defaults: [
{ schema: 'metric', type: 'count' }
]
},
{
group: 'metrics',
name: 'radius',
title: 'Dot Size',
min: 0,
max: 1,
aggFilter: ['count', 'avg', 'sum', 'min', 'max', 'cardinality']
},
{
group: 'buckets',
name: 'segment',
Expand All @@ -77,7 +129,7 @@ export default function HistogramVisType(Private) {
{
group: 'buckets',
name: 'group',
title: 'Split Area',
title: 'Split Series',
min: 0,
max: 1,
aggFilter: '!geohash_grid'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<div>
<div class="kuiSideBarCollapsibleTitle">
<div
class="kuiSideBarCollapsibleTitle__label"
ng-click="isCategoryAxisOpen = !isCategoryAxisOpen"
>
<span
aria-hidden="true"
ng-class="{ 'fa-caret-down': isCategoryAxisOpen, 'fa-caret-right': !isCategoryAxisOpen }"
class="fa fa-caret-right kuiSideBarCollapsibleTitle__caret"
></span>
<span class="kuiSideBarCollapsibleTitle__text">
Category Axis
</span>
</div>
</div>

<div ng-show="isCategoryAxisOpen" class="kuiSideBarCollapsibleSection">
<!-- General -->
<div class="kuiSideBarSection">
<div class="kuiSideBarFormRow">
<label class="kuiSideBarFormRow__label" for="categoryAxisShow">
Show
</label>
<div class="kuiSideBarFormRow__control">
<input class="kuiCheckBox" id="categoryAxisShow" type="checkbox" ng-model="vis.params.categoryAxes[0].show">
</div>
</div>

<div class="kuiSideBarFormRow">
<label class="kuiSideBarFormRow__label" for="categoryAxisPosition">
Position
</label>
<div class="kuiSideBarFormRow__control">
<select
id="categoryAxisPosition"
class="kuiSelect kuiSideBarSelect"
ng-model="vis.params.categoryAxes[0].position"
ng-options="mode for mode in vis.type.params.positions"
></select>
</div>
</div>
</div>

<!-- Advanced options -->
<div class="kuiSideBarSection">
<a
href=""
class="kuiSideBarOptionsLink"
ng-click="isCategoryAxisAdvancedOptionsOpen = !isCategoryAxisAdvancedOptionsOpen"
>
<span
aria-hidden="true"
ng-class="{ 'fa-caret-down': isCategoryAxisAdvancedOptionsOpen, 'fa-caret-right': !isCategoryAxisAdvancedOptionsOpen }"
class="fa fa-caret-right kuiSideBarOptionsLink__caret"
></span>
<span class="kuiSideBarOptionsLink__text">
<span ng-show="!isCategoryAxisAdvancedOptionsOpen">
Show
</span>
<span ng-show="isCategoryAxisAdvancedOptionsOpen">
Hide
</span>
Advanced Options
</span>
</a>

<div ng-show="isCategoryAxisAdvancedOptionsOpen">
<!-- Labels -->
<div class="kuiSideBarSection">
<h6 class="kuiSideBarFormSectionTitle">
Labels
</h6>

<div class="kuiSideBarFormRow">
<label class="kuiSideBarFormRow__label" for="showLabels">
Show Labels
</label>
<div class="kuiSideBarFormRow__control">
<input class="kuiCheckBox" id="showLabels" type="checkbox" ng-model="vis.params.categoryAxes[0].labels.show">
</div>
</div>

<div class="kuiSideBarFormRow">
<label class="kuiSideBarFormRow__label" for="showFilter">
Filter Labels
</label>
<div class="kuiSideBarFormRow__control">
<input class="kuiCheckBox" id="showFilter" type="checkbox" ng-model="vis.params.categoryAxes[0].labels.filter">
</div>
</div>

<div class="kuiSideBarFormRow">
<label class="kuiSideBarFormRow__label" for="rotateLabels">
Rotate
</label>
<div class="kuiSideBarFormRow__control">
<input
id="rotateLabels"
class="kuiInput kuiSideBarInput"
type="number"
ng-model="vis.params.categoryAxes[0].labels.rotate"
>
</div>
</div>

<div class="kuiSideBarFormRow">
<label class="kuiSideBarFormRow__label" for="truncateLabels">
Truncate
</label>
<div class="kuiSideBarFormRow__control">
<input
id="truncateLabels"
class="kuiInput kuiSideBarInput"
type="number"
ng-model="vis.params.categoryAxes[0].labels.truncate"
>
</div>
</div>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import _ from 'lodash';
import uiModules from 'ui/modules';
import vislibValueAxesTemplate from 'plugins/kbn_vislib_vis_types/controls/point_series/category_axis.html';
const module = uiModules.get('kibana');

module.directive('vislibCategoryAxis', function ($parse, $compile) {
return {
restrict: 'E',
template: vislibValueAxesTemplate,
replace: true,
link: function ($scope) {
function mapPosition(position) {
switch (position) {
case 'bottom': return 'left';
case 'top': return 'right';
case 'left': return 'bottom';
case 'right': return 'top';
}
}

$scope.$watch('vis.params.categoryAxes[0].position', position => {
const categoryAxisIsHorizontal = ['top', 'bottom'].includes(position);
$scope.vis.params.valueAxes.forEach(axis => {
const axisIsHorizontal = ['top', 'bottom'].includes(axis.position);
if (axisIsHorizontal === categoryAxisIsHorizontal) {
axis.position = mapPosition(axis.position);
}
});
});

let lastAxisTitle = '';
$scope.$watch(() => {
return $scope.vis.aggs.map(agg => {
return agg.params.field ? agg.makeLabel() : '';
}).join();
}, () => {
const agg = $scope.vis.aggs.find(agg => agg.schema.name === 'segment');
const label = agg ? agg.makeLabel() : '';
if (lastAxisTitle !== label) {
lastAxisTitle = label;
$scope.vis.params.categoryAxes[0].title.text = label;
}
});
}
};
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<div>
<div class="kuiSideBarCollapsibleTitle">
<div
class="kuiSideBarCollapsibleTitle__label"
ng-click="isGridOpen = !isGridOpen"
>
<span
aria-hidden="true"
ng-class="{ 'fa-caret-down': isCategoryAxisOpen, 'fa-caret-right': !isCategoryAxisOpen }"
class="fa fa-caret-right kuiSideBarCollapsibleTitle__caret"
></span>
<span class="kuiSideBarCollapsibleTitle__text">
Grid
</span>
</div>
<input
aria-label="enable"
ng-model="vis.params.grid.show"
type="checkbox"
class="kuiSideBarSectionTitle__action"
>
</div>

<div ng-show="isGridOpen" class="kuiSideBarCollapsibleSection">
<!-- General -->
<div class="kuiSideBarSection">
<div class="kuiSideBarFormRow">
<label class="kuiSideBarFormRow__label" for="showCategoryLines">
Category lines
</label>
<div class="kuiSideBarFormRow__control">
<input class="kuiCheckBox" id="showCategoryLines" type="checkbox" ng-model="vis.params.grid.categoryLines">
</div>
</div>

<div class="kuiSideBarFormRow">
<label class="kuiSideBarFormRow__label" for="gridAxis">
Value Axis
</label>
<div class="kuiSideBarFormRow__control">
<select
id="gridAxis"
class="kuiSelect kuiSideBarSelect"
ng-model="vis.params.grid.valueAxis"
ng-options="axis.id as axis.id for axis in vis.params.valueAxes"
>
<option value="">Don't show</option>
</select>
</div>
</div>

<div class="kuiSideBarFormRow">
<label class="kuiSideBarFormRow__label" for="gridColor">
Color
</label>
<div class="kuiSideBarFormRow__control">
<input
id="gridColor"
class="kuiInput kuiSideBarInput"
ng-model="vis.params.grid.style.color"
>
</div>
</div>
</div>

</div>
Loading

0 comments on commit ec9a614

Please sign in to comment.