From 1a7a9a7ef960f0a2e3d834ccb56da97b113737e7 Mon Sep 17 00:00:00 2001 From: Peter Pisljar Date: Wed, 21 Jun 2017 22:08:08 +0200 Subject: [PATCH] removing old point series defaults (#11958) 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. --- .../kbn_vislib_vis_types/public/area.js | 11 +++----- .../public/controls/point_series/grid.html | 2 +- .../kbn_vislib_vis_types/public/histogram.js | 11 +++----- .../public/horizontal_bar.js | 11 +++----- .../kbn_vislib_vis_types/public/line.js | 26 ++++++++++++------- .../public/vislib/lib/layout/layout_types.js | 1 + src/ui/public/vislib/lib/types/index.js | 3 ++- .../public/vislib/visualizations/vis_types.js | 3 ++- .../public/vislib_vis_type/vislib_vis_type.js | 21 +++++++++++---- .../page_objects/point_series_page.js | 2 +- 10 files changed, 49 insertions(+), 42 deletions(-) diff --git a/src/core_plugins/kbn_vislib_vis_types/public/area.js b/src/core_plugins/kbn_vislib_vis_types/public/area.js index d270aff7cda62..62bdf1cf0fab0 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/area.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/area.js @@ -60,7 +60,9 @@ export default function PointSeriesVisType(Private) { filter: false, truncate: 100 }, - title: {} + title: { + text: 'Count' + } } ], seriesParams: [{ @@ -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: [{ diff --git a/src/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid.html b/src/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid.html index 97936e66820a1..59bbea8bb0f3c 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid.html +++ b/src/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid.html @@ -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" > diff --git a/src/core_plugins/kbn_vislib_vis_types/public/histogram.js b/src/core_plugins/kbn_vislib_vis_types/public/histogram.js index 1eb23a052bf31..c65bce00be381 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/histogram.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/histogram.js @@ -60,7 +60,9 @@ export default function PointSeriesVisType(Private) { filter: false, truncate: 100 }, - title: {} + title: { + text: 'Count' + } } ], seriesParams: [ @@ -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: [{ diff --git a/src/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js b/src/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js index 30a81c532bf27..2f92b023ec8cb 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js @@ -62,7 +62,9 @@ export default function PointSeriesVisType(Private) { filter: true, truncate: 100 }, - title: {} + title: { + text: 'Count' + } } ], seriesParams: [{ @@ -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: [{ diff --git a/src/core_plugins/kbn_vislib_vis_types/public/line.js b/src/core_plugins/kbn_vislib_vis_types/public/line.js index d296de2c687ac..77237faa0c996 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/line.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/line.js @@ -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: [{ diff --git a/src/ui/public/vislib/lib/layout/layout_types.js b/src/ui/public/vislib/lib/layout/layout_types.js index c6158d9a846e9..613884a0c5eef 100644 --- a/src/ui/public/vislib/lib/layout/layout_types.js +++ b/src/ui/public/vislib/lib/layout/layout_types.js @@ -15,6 +15,7 @@ export function VislibLibLayoutLayoutTypesProvider(Private) { return { pie: Private(VislibLibLayoutTypesPieLayoutProvider), gauge: Private(GaugeLayoutProvider), + metric: Private(GaugeLayoutProvider), point_series: Private(VislibLibLayoutTypesColumnLayoutProvider) }; } diff --git a/src/ui/public/vislib/lib/types/index.js b/src/ui/public/vislib/lib/types/index.js index 9721e89677d2d..95c0d0a5a9871 100644 --- a/src/ui/public/vislib/lib/types/index.js +++ b/src/ui/public/vislib/lib/types/index.js @@ -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) }; } diff --git a/src/ui/public/vislib/visualizations/vis_types.js b/src/ui/public/vislib/visualizations/vis_types.js index a1219f7ea997b..953193d46fb80 100644 --- a/src/ui/public/vislib/visualizations/vis_types.js +++ b/src/ui/public/vislib/visualizations/vis_types.js @@ -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), }; } diff --git a/src/ui/public/vislib_vis_type/vislib_vis_type.js b/src/ui/public/vislib_vis_type/vislib_vis_type.js index e6100de6a1357..954515227dec2 100644 --- a/src/ui/public/vislib_vis_type/vislib_vis_type.js +++ b/src/ui/public/vislib_vis_type/vislib_vis_type.js @@ -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]; } }; @@ -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'; @@ -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); @@ -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); }; diff --git a/test/functional/page_objects/point_series_page.js b/test/functional/page_objects/point_series_page.js index 814806be03d9a..aefd682b153cc 100644 --- a/test/functional/page_objects/point_series_page.js +++ b/test/functional/page_objects/point_series_page.js @@ -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(); }