Skip to content

Commit

Permalink
removing old point series defaults (#11958)
Browse files Browse the repository at this point in the history
This fixes issues where properties from the visualizations saved in older versions were not applied to the Visualization.

This also addressed the fontSize of metrics not being applied on the Dashboard.
  • Loading branch information
ppisljar authored and thomasneirynck committed Jun 21, 2017
1 parent 1eaf83e commit 3269965
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 42 deletions.
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
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];
}
};

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

0 comments on commit 3269965

Please sign in to comment.