Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing old point series defaults #11958

Merged
merged 8 commits into from
Jun 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/core_plugins/kbn_vislib_vis_types/public/area.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export default function PointSeriesVisType(Private) {
filter: false,
truncate: 100
},
title: {}
title: {
text: 'Count'
}
}
],
seriesParams: [{
Expand All @@ -79,15 +81,8 @@ export default function PointSeriesVisType(Private) {
addTooltip: true,
addLegend: true,
legendPosition: 'right',
showCircles: true,
interpolate: 'linear',
scale: 'linear',
drawLinesBetweenPoints: true,
radiusRatio: 9,
times: [],
addTimeMarker: false,
defaultYExtents: false,
setYExtents: false
},
positions: ['top', 'left', 'right', 'bottom'],
chartTypes: [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
id="gridAxis"
class="kuiSelect kuiSideBarSelect"
ng-model="vis.params.grid.valueAxis"
ng-options="axis.id as axis.name for axis in vis.params.valueAxes"
ng-options="axis.id as axis.name for axis in vis.params.valueAxes track by axis.id"
>
<option value="">Don't show</option>
</select>
Expand Down
11 changes: 3 additions & 8 deletions src/core_plugins/kbn_vislib_vis_types/public/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export default function PointSeriesVisType(Private) {
filter: false,
truncate: 100
},
title: {}
title: {
text: 'Count'
}
}
],
seriesParams: [
Expand All @@ -80,15 +82,8 @@ export default function PointSeriesVisType(Private) {
addTooltip: true,
addLegend: true,
legendPosition: 'right',
showCircles: true,
interpolate: 'linear',
scale: 'linear',
drawLinesBetweenPoints: true,
radiusRatio: 9,
times: [],
addTimeMarker: false,
defaultYExtents: false,
setYExtents: false
},
positions: ['top', 'left', 'right', 'bottom'],
chartTypes: [{
Expand Down
11 changes: 3 additions & 8 deletions src/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export default function PointSeriesVisType(Private) {
filter: true,
truncate: 100
},
title: {}
title: {
text: 'Count'
}
}
],
seriesParams: [{
Expand All @@ -80,15 +82,8 @@ export default function PointSeriesVisType(Private) {
addTooltip: true,
addLegend: true,
legendPosition: 'right',
showCircles: true,
interpolate: 'linear',
scale: 'linear',
drawLinesBetweenPoints: true,
radiusRatio: 9,
times: [],
addTimeMarker: false,
defaultYExtents: false,
setYExtents: false
},
positions: ['top', 'left', 'right', 'bottom'],
chartTypes: [{
Expand Down
26 changes: 17 additions & 9 deletions src/core_plugins/kbn_vislib_vis_types/public/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,30 @@ export default function PointSeriesVisType(Private) {
filter: false,
truncate: 100
},
title: {}
title: {
text: 'Count'
}
}
],
seriesParams: [
{
show: 'true',
type: 'line',
mode: 'normal',
data: {
label: 'Count',
id: '1'
},
valueAxis: 'ValueAxis-1',
drawLinesBetweenPoints: true,
showCircles: true
}
],
seriesParams: [],
addTooltip: true,
addLegend: true,
legendPosition: 'right',
showCircles: true,
interpolate: 'linear',
scale: 'linear',
drawLinesBetweenPoints: true,
radiusRatio: 9,
times: [],
addTimeMarker: false,
defaultYExtents: false,
setYExtents: false
},
positions: ['top', 'left', 'right', 'bottom'],
chartTypes: [{
Expand Down
1 change: 1 addition & 0 deletions src/ui/public/vislib/lib/layout/layout_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function VislibLibLayoutLayoutTypesProvider(Private) {
return {
pie: Private(VislibLibLayoutTypesPieLayoutProvider),
gauge: Private(GaugeLayoutProvider),
metric: Private(GaugeLayoutProvider),
point_series: Private(VislibLibLayoutTypesColumnLayoutProvider)
};
}
3 changes: 2 additions & 1 deletion src/ui/public/vislib/lib/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function VislibTypesProvider(Private) {
area: pointSeries.area,
point_series: pointSeries.line,
heatmap: pointSeries.heatmap,
gauge: Private(vislibGaugeProvider)
gauge: Private(vislibGaugeProvider),
metric: Private(vislibGaugeProvider)
};
}
3 changes: 2 additions & 1 deletion src/ui/public/vislib/visualizations/vis_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function VislibVisualizationsVisTypesProvider(Private) {
return {
pie: Private(VislibVisualizationsPieChartProvider),
point_series: Private(VislibVisualizationsPointSeriesProvider),
gauge: Private(GaugeChartProvider)
gauge: Private(GaugeChartProvider),
metric: Private(GaugeChartProvider),
};
}
21 changes: 16 additions & 5 deletions src/ui/public/vislib_vis_type/vislib_vis_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ export function VislibVisTypeVislibVisTypeProvider(Private) {
const pointSeries = Private(AggResponsePointSeriesProvider);
const VislibRenderbot = Private(VislibVisTypeVislibRenderbotProvider);

// converts old config format (pre 5.2) to the new one
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archanid ... i was refering to this comment

const updateParams = function (params) {
if (!params.seriesParams || !params.seriesParams.length) return;
if (params.seriesParams && params.seriesParams.length) return;
params.seriesParams = [{}];

const updateIfSet = (from, to, prop, func) => {
if (from[prop]) {
to[prop] = func ? func(from[prop]) : from[prop];
delete from[prop];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool thanks for fixing this!

Minor, unrelated to this PR feedback - I think a comment for this updateParams function would be helpful. It was hard for me to figure out what was it was for. :) Plus then at some point way down the line if we stop supporting pre 5.2 we can get rid of the code.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see the comment added in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is there @archanid

}
};

Expand All @@ -30,6 +33,10 @@ export function VislibVisTypeVislibVisTypeProvider(Private) {
updateIfSet(params, params.seriesParams[0], 'interpolate');
updateIfSet(params, params.seriesParams[0], 'type');

if (params.gauge) {
updateIfSet(params, params.gauge.style, 'fontSize');
}

if (params.mode) {
const stacked = ['stacked', 'percentage', 'wiggle', 'silhouette'].includes(params.mode);
params.seriesParams[0].mode = stacked ? 'stacked' : 'normal';
Expand All @@ -43,15 +50,19 @@ export function VislibVisTypeVislibVisTypeProvider(Private) {
delete params.smoothLines;
}

updateIfSet(params, params.valueAxes[0].scale, 'setYExtents');
updateIfSet(params, params.valueAxes[0].scale, 'defaultYExtents');
if (params.valueAxes) {
updateIfSet(params, params.valueAxes[0].scale, 'setYExtents');
updateIfSet(params, params.valueAxes[0].scale, 'defaultYExtents');
}

if (params.scale) {
params.valueAxes[0].scale.type = params.scale;
delete params.scale;
}

updateIfSet(params, params.categoryAxes[0], 'expandLastBucket');
if (params.categoryAxis && params.categoryAxis.length) {
updateIfSet(params, params.categoryAxes[0], 'expandLastBucket');
}
};

_.class(VislibVisType).inherits(VisType);
Expand All @@ -66,7 +77,7 @@ export function VislibVisTypeVislibVisTypeProvider(Private) {
}

VislibVisType.prototype.createRenderbot = function (vis, $el, uiState) {
updateParams(vis.params);
if (vis.type.name !== 'pie') updateParams(vis.params);
return new VislibRenderbot(vis, $el, uiState);
};

Expand Down
2 changes: 1 addition & 1 deletion test/functional/page_objects/point_series_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function PointSeriesPageProvider({ getService }) {
setGridValueAxis(axis) {
return remote
.setFindTimeout(defaultFindTimeout)
.findByCssSelector(`select#gridAxis option[value="string:${axis}"]`)
.findByCssSelector(`select#gridAxis option[value="${axis}"]`)
.click();
}

Expand Down