mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* smoothLines should not override the seriesParams setting (cherry picked from commit9047b2e
) * adding new series should respect the previous settings (cherry picked from commit 6959725) * update visualization configuration (cherry picked from commitc96fec8
) * updating based on review from thomas (cherry picked from commite3023f4
) * upgrading metric fontSize setting (cherry picked from commit2bcbfff
) * remove old (malfunctioning) update function
This commit is contained in:
parent
7969d5caac
commit
3a1f8721e6
6 changed files with 50 additions and 78 deletions
|
@ -15,15 +15,15 @@ module.directive('vislibSeries', function () {
|
|||
show: true,
|
||||
mode: last ? last.mode : 'normal',
|
||||
type: last ? last.type : 'line',
|
||||
drawLinesBetweenPoints: true,
|
||||
showCircles: true,
|
||||
interpolate: 'linear',
|
||||
lineWidth: 2,
|
||||
drawLinesBetweenPoints: last ? last.drawLinesBetweenPoints : true,
|
||||
showCircles: last ? last.showCircles : true,
|
||||
interpolate: last ? last.interpolate : 'linear',
|
||||
lineWidth: last ? last.lineWidth : 2,
|
||||
data: {
|
||||
id: id,
|
||||
label: label
|
||||
},
|
||||
valueAxis: $scope.vis.params.valueAxes[0].id
|
||||
valueAxis: last ? last.valueAxis : $scope.vis.params.valueAxes[0].id
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import { AggTypesIndexProvider } from 'ui/agg_types/index';
|
|||
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
|
||||
import { VisAggConfigsProvider } from 'ui/vis/agg_configs';
|
||||
import { PersistedState } from 'ui/persisted_state';
|
||||
import { updateVisualizationConfig } from './vis_update';
|
||||
|
||||
export function VisProvider(Notifier, Private) {
|
||||
const aggTypes = Private(AggTypesIndexProvider);
|
||||
|
@ -99,6 +100,8 @@ export function VisProvider(Notifier, Private) {
|
|||
_.cloneDeep(this.type.params.defaults || {})
|
||||
);
|
||||
|
||||
updateVisualizationConfig(state.params, this.params);
|
||||
|
||||
this.aggs = new AggConfigs(this, state.aggs);
|
||||
};
|
||||
|
||||
|
|
38
src/ui/public/vis/vis_update.js
Normal file
38
src/ui/public/vis/vis_update.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
const updateVisualizationConfig = (stateConfig, config) => {
|
||||
|
||||
if (config.type === 'gauge' && config.fontSize) {
|
||||
config.gauge.style.fontSize = config.fontSize;
|
||||
delete config.fontSize;
|
||||
}
|
||||
|
||||
if (!stateConfig || stateConfig.seriesParams) return;
|
||||
if (!['line', 'area', 'histogram'].includes(config.type)) return;
|
||||
|
||||
// update value axis options
|
||||
const isUserDefinedYAxis = config.setYExtents;
|
||||
const mode = ['stacked', 'overlap'].includes(config.mode) ? 'normal' : config.mode || 'normal';
|
||||
config.valueAxes[0].scale = {
|
||||
...config.valueAxes[0].scale,
|
||||
type: config.scale || 'linear',
|
||||
setYExtents: config.setYExtents || false,
|
||||
defaultYExtents: config.defaultYExtents || false,
|
||||
min: isUserDefinedYAxis ? config.yAxis.min : undefined,
|
||||
max: isUserDefinedYAxis ? config.yAxis.max : undefined,
|
||||
mode: mode
|
||||
};
|
||||
|
||||
// update series options
|
||||
const interpolate = config.smoothLines ? 'cardinal' : config.interpolate;
|
||||
const stacked = ['stacked', 'percentage', 'wiggle', 'silhouette'].includes(config.mode);
|
||||
config.seriesParams[0] = {
|
||||
...config.seriesParams[0],
|
||||
type: config.type || 'line',
|
||||
mode: stacked ? 'stacked' : 'normal',
|
||||
interpolate: interpolate,
|
||||
drawLinesBetweenPoints: config.drawLinesBetweenPoints,
|
||||
showCircles: config.showCircles,
|
||||
radiusRatio: config.radiusRatio
|
||||
};
|
||||
};
|
||||
|
||||
export { updateVisualizationConfig };
|
|
@ -1,14 +1,6 @@
|
|||
import _ from 'lodash';
|
||||
|
||||
export function vislibGaugeProvider() {
|
||||
|
||||
return function (config) {
|
||||
if (!config.chart) {
|
||||
config.chart = _.defaults({}, config, {
|
||||
type: 'gauge'
|
||||
});
|
||||
}
|
||||
|
||||
return config;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,16 +3,14 @@ import _ from 'lodash';
|
|||
export function VislibTypesPointSeries() {
|
||||
|
||||
const createSerieFromParams = (cfg, seri) => {
|
||||
const matchingSeriParams = cfg.seriesParams ? cfg.seriesParams.find(seriConfig => {
|
||||
const matchingSeriesParams = cfg.seriesParams ? cfg.seriesParams.find(seriConfig => {
|
||||
return seri.aggId === seriConfig.data.id;
|
||||
}) : null;
|
||||
|
||||
|
||||
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';
|
||||
const interpolate = cfg.smoothLines ? 'cardinal' : cfg.interpolate;
|
||||
|
||||
if (!matchingSeriParams) {
|
||||
if (!matchingSeriesParams) {
|
||||
const stacked = ['stacked', 'percentage', 'wiggle', 'silhouette'].includes(cfg.mode);
|
||||
return {
|
||||
show: true,
|
||||
|
@ -27,15 +25,7 @@ export function VislibTypesPointSeries() {
|
|||
}
|
||||
|
||||
return {
|
||||
show: matchingSeriParams.show,
|
||||
type: matchingSeriParams.type,
|
||||
mode: matchingSeriParams.mode,
|
||||
interpolate: interpolate,
|
||||
valueAxis: matchingSeriParams.valueAxis,
|
||||
drawLinesBetweenPoints: matchingSeriParams.drawLinesBetweenPoints,
|
||||
showCircles: matchingSeriParams.showCircles,
|
||||
radiusRatio: cfg.radiusRatio,
|
||||
lineWidth: matchingSeriParams.lineWidth,
|
||||
...matchingSeriesParams,
|
||||
data: seri
|
||||
};
|
||||
};
|
||||
|
|
|
@ -15,56 +15,6 @@ 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) {
|
||||
|
||||
const updateIfSet = (from, to, prop, func) => {
|
||||
if (from[prop]) {
|
||||
to[prop] = func ? func(from[prop]) : from[prop];
|
||||
delete from[prop];
|
||||
}
|
||||
};
|
||||
|
||||
if (params.gauge) {
|
||||
updateIfSet(params, params.gauge.style, 'fontSize');
|
||||
}
|
||||
|
||||
if (params.seriesParams) {
|
||||
updateIfSet(params, params.seriesParams[0], 'drawLinesBetweenPoints');
|
||||
updateIfSet(params, params.seriesParams[0], 'showCircles');
|
||||
updateIfSet(params, params.seriesParams[0], 'radiusRatio');
|
||||
updateIfSet(params, params.seriesParams[0], 'interpolate');
|
||||
updateIfSet(params, params.seriesParams[0], 'type');
|
||||
|
||||
if (params.mode) {
|
||||
const stacked = ['stacked', 'percentage', 'wiggle', 'silhouette'].includes(params.mode);
|
||||
params.seriesParams[0].mode = stacked ? 'stacked' : 'normal';
|
||||
const axisMode = ['stacked', 'overlap'].includes(params.mode) ? 'normal' : params.mode;
|
||||
params.valueAxes[0].scale.mode = axisMode;
|
||||
delete params.mode;
|
||||
}
|
||||
|
||||
if (params.smoothLines) {
|
||||
params.seriesParams[0].interpolate = 'cardinal';
|
||||
delete params.smoothLines;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (params.categoryAxes && params.categoryAxes.length) {
|
||||
updateIfSet(params, params.categoryAxes[0], 'expandLastBucket');
|
||||
}
|
||||
};
|
||||
|
||||
_.class(VislibVisType).inherits(VisType);
|
||||
function VislibVisType(opts = {}) {
|
||||
VislibVisType.Super.call(this, opts);
|
||||
|
@ -77,7 +27,6 @@ export function VislibVisTypeVislibVisTypeProvider(Private) {
|
|||
}
|
||||
|
||||
VislibVisType.prototype.createRenderbot = function (vis, $el, uiState) {
|
||||
if (vis.type.name !== 'pie') updateParams(vis.params);
|
||||
return new VislibRenderbot(vis, $el, uiState);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue