Skip to content

Commit

Permalink
cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Dec 30, 2016
1 parent 7c1f77b commit f13a9cd
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 33 deletions.
4 changes: 1 addition & 3 deletions src/core_plugins/kbn_vislib_vis_types/public/area.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export default function PointSeriesVisType(Private) {
params: {
defaults: {
grid: {
show: false,
categoryLines: true,
categoryLines: false,
style: {
color: '#eee'
}
Expand Down Expand Up @@ -73,7 +72,6 @@ export default function PointSeriesVisType(Private) {
addLegend: true,
legendPosition: 'right',
showCircles: true,
smoothLines: false,
interpolate: 'linear',
scale: 'linear',
drawLinesBetweenPoints: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@

<div ng-show="chart.type == 'line' || chart.type == 'area'">
<div class="kuiSideBarFormRow">
<label class="kuiSideBarFormRow__label" for="{{ 'smoothLine' + $index }}">
Smooth lines
<label class="kuiSideBarFormRow__label" for="{{ 'lineMode' + $index }}">
Line Mode
</label>
<div class="kuiSideBarFormRow__control">
<input class="kuiCheckBox" id="{{ 'smoothLine' + $index }}" type="checkbox" ng-model="chart.smoothLines">
<select
id="{{ 'lineMode' + $index }}"
class="kuiSelect kuiSideBarSelect"
ng-model="chart.interpolate"
ng-options="mode.value as mode.text for mode in vis.type.params.interpolationModes"
>
</select>
</div>
</div>
</div>
Expand Down
14 changes: 11 additions & 3 deletions src/core_plugins/kbn_vislib_vis_types/public/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export default function PointSeriesVisType(Private) {
params: {
defaults: {
grid: {
show: false,
categoryLines: true,
categoryLines: false,
style: {
color: '#eee'
}
Expand Down Expand Up @@ -73,7 +72,6 @@ export default function PointSeriesVisType(Private) {
addLegend: true,
legendPosition: 'right',
showCircles: true,
smoothLines: false,
interpolate: 'linear',
scale: 'linear',
drawLinesBetweenPoints: true,
Expand All @@ -88,6 +86,16 @@ export default function PointSeriesVisType(Private) {
axisModes: ['normal', 'percentage', 'wiggle', 'silhouette'],
scaleTypes: ['linear', 'log', 'square root'],
chartModes: ['normal', 'stacked'],
interpolationModes: [{
value: 'linear',
text: 'straight',
}, {
value: 'cardinal',
text: 'smoothed',
}, {
value: 'step-after',
text: 'stepped',
}],
editor: pointSeriesTemplate
},
schemas: new Schemas([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ export default function PointSeriesVisType(Private) {
const Schemas = Private(VisSchemasProvider);

return new VislibVisType({
name: 'point_series',
name: 'horizontal_bar',
title: 'Horizontal bar chart',
icon: 'fa-bars',
description: 'Like histogram chart but with horizontal bars.',
params: {
defaults: {
grid: {
show: false,
categoryLines: true,
categoryLines: false,
color: '#eee'
},
categoryAxes: [
Expand Down Expand Up @@ -71,7 +70,6 @@ export default function PointSeriesVisType(Private) {
addLegend: true,
legendPosition: 'right',
showCircles: true,
smoothLines: false,
interpolate: 'linear',
scale: 'linear',
drawLinesBetweenPoints: true,
Expand All @@ -86,6 +84,16 @@ export default function PointSeriesVisType(Private) {
axisModes: ['normal', 'percentage', 'wiggle', 'silhouette'],
scaleTypes: ['linear', 'log', 'square root'],
chartModes: ['normal', 'stacked'],
interpolationModes: [{
value: 'linear',
text: 'straight',
}, {
value: 'cardinal',
text: 'smoothed',
}, {
value: 'step-after',
text: 'stepped',
}],
editor: pointSeriesTemplate
},
schemas: new Schemas([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ visTypes.register(require('plugins/kbn_vislib_vis_types/pie'));
visTypes.register(require('plugins/kbn_vislib_vis_types/area'));
visTypes.register(require('plugins/kbn_vislib_vis_types/tile_map'));
visTypes.register(require('plugins/kbn_vislib_vis_types/heatmap'));
visTypes.register(require('plugins/kbn_vislib_vis_types/point_series'));
visTypes.register(require('plugins/kbn_vislib_vis_types/horizontal_bar'));
3 changes: 1 addition & 2 deletions src/core_plugins/kbn_vislib_vis_types/public/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export default function PointSeriesVisType(Private) {
params: {
defaults: {
grid: {
show: false,
categoryLines: true,
categoryLines: false,
style: {
color: '#eee'
}
Expand Down
8 changes: 4 additions & 4 deletions src/ui/public/vislib/lib/axis/axis_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ export default function AxisConfigFactory() {
const typeDefaults = axisConfigArgs.type === 'category' ? categoryDefaults : valueDefaults;
// _.defaultsDeep mutates axisConfigArgs nested values so we clone it first
const axisConfigArgsClone = _.cloneDeep(axisConfigArgs);
const isHorizontal = (axisConfigArgsClone.position &&
['top', 'bottom'].includes(axisConfigArgsClone.position)) ||
axisConfigArgsClone.type === 'category';
_.merge(typeDefaults, isHorizontal ? horizontalDefaults : verticalDefaults);
const isCategoryAxis = axisConfigArgsClone.type === 'category';
const isHorizontal = axisConfigArgsClone.position && ['top', 'bottom'].includes(axisConfigArgsClone.position);

_.merge(typeDefaults, isHorizontal || isCategoryAxis ? horizontalDefaults : verticalDefaults);
this._values = _.defaultsDeep({}, axisConfigArgsClone, typeDefaults, defaults);

this._values.elSelector = this._values.elSelector.replace('{pos}', this._values.position);
Expand Down
5 changes: 3 additions & 2 deletions src/ui/public/vislib/lib/axis/axis_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function AxisTitleFactory(Private) {
const div = d3.select(el);
const width = $(el).width();
const height = $(el).height();
const titlePadding = 15;

const svg = div.append('svg')
.attr('width', width)
Expand All @@ -35,9 +36,9 @@ export default function AxisTitleFactory(Private) {
const bbox = svg.append('text')
.attr('transform', function () {
if (config.isHorizontal()) {
return 'translate(' + width / 2 + ',15)';
return `translate(${width / 2},${titlePadding})`;
}
return 'translate(15,' + height / 2 + ') rotate(270)';
return `translate(${titlePadding},${height / 2}) rotate(270)`;
})
.attr('text-anchor', 'middle')
.text(config.get('title.text'))
Expand Down
5 changes: 2 additions & 3 deletions src/ui/public/vislib/lib/chart_grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export default function ChartTitleFactory(Private) {
style: {
color: '#eee'
},
show: false,
categoryLines: true,
categoryLines: false,
valueAxis: undefined,
};

Expand Down Expand Up @@ -54,7 +53,7 @@ export default function ChartTitleFactory(Private) {
draw(width, height) {
const self = this;
return function (selection) {
if (!self._values || !self.get('show')) return;
if (!self._values) return;
selection.each(function () {
if (self.get('categoryLines')) self.drawCategoryLines(d3.select(this), width, height);
if (self.get('valueAxis', false)) self.drawValueLines(d3.select(this), width, height);
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/vislib/lib/types/point_series.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function ColumnHandler(Private) {
}) : null;


let interpolate = cfg.interpolate;
let interpolate = matchingSeriParams ? matchingSeriParams.interpolate : cfg.interpolate;
// for backward compatibility when loading URLs or configs we need to check smoothLines
if (cfg.smoothLines) interpolate = 'cardinal';

Expand All @@ -32,8 +32,8 @@ export default function ColumnHandler(Private) {
show: matchingSeriParams.show,
type: matchingSeriParams.type,
mode: matchingSeriParams.mode,
interpolate: interpolate,
valueAxis: matchingSeriParams.valueAxis,
smoothLines: matchingSeriParams.smoothLines,
drawLinesBetweenPoints: matchingSeriParams.drawLinesBetweenPoints,
showCircles: matchingSeriParams.showCircles,
radiusRatio: matchingSeriParams.radiusRatio,
Expand Down

0 comments on commit f13a9cd

Please sign in to comment.