mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[XY] Defaults the point size to 1 and corrects the vislib migrations (#118994)
* [XY] Changes the default point size to 1 and corrects the vislib migrations * Fixes the unit test * Change the migration function to default te fitting function to linear * Update src/plugins/visualizations/server/migrations/visualization_saved_object_migrations.test.ts Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com> * Update src/plugins/visualizations/server/migrations/visualization_saved_object_migrations.ts Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com> * Fixes on PR review Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
This commit is contained in:
parent
3da312a127
commit
82979a345f
8 changed files with 54 additions and 8 deletions
|
@ -45,7 +45,7 @@ describe('getSeriesParams', () => {
|
|||
);
|
||||
expect(seriesParams).toStrictEqual([
|
||||
{
|
||||
circlesRadius: 3,
|
||||
circlesRadius: 1,
|
||||
data: {
|
||||
id: '1',
|
||||
label: 'Total quantity',
|
||||
|
|
|
@ -22,7 +22,7 @@ const makeSerie = (
|
|||
type: ChartType.Line,
|
||||
drawLinesBetweenPoints: true,
|
||||
showCircles: true,
|
||||
circlesRadius: 3,
|
||||
circlesRadius: 1,
|
||||
interpolate: InterpolationMode.Linear,
|
||||
lineWidth: 2,
|
||||
valueAxis: defaultValueAxis,
|
||||
|
|
|
@ -97,7 +97,7 @@ export const areaVisTypeDefinition = {
|
|||
drawLinesBetweenPoints: true,
|
||||
lineWidth: 2,
|
||||
showCircles: true,
|
||||
circlesRadius: 3,
|
||||
circlesRadius: 1,
|
||||
interpolate: InterpolationMode.Linear,
|
||||
valueAxis: 'ValueAxis-1',
|
||||
},
|
||||
|
|
|
@ -101,7 +101,7 @@ export const histogramVisTypeDefinition = {
|
|||
drawLinesBetweenPoints: true,
|
||||
lineWidth: 2,
|
||||
showCircles: true,
|
||||
circlesRadius: 3,
|
||||
circlesRadius: 1,
|
||||
},
|
||||
],
|
||||
radiusRatio: 0,
|
||||
|
|
|
@ -102,7 +102,7 @@ export const horizontalBarVisTypeDefinition = {
|
|||
drawLinesBetweenPoints: true,
|
||||
lineWidth: 2,
|
||||
showCircles: true,
|
||||
circlesRadius: 3,
|
||||
circlesRadius: 1,
|
||||
},
|
||||
],
|
||||
addTooltip: true,
|
||||
|
|
|
@ -99,7 +99,7 @@ export const lineVisTypeDefinition = {
|
|||
lineWidth: 2,
|
||||
interpolate: InterpolationMode.Linear,
|
||||
showCircles: true,
|
||||
circlesRadius: 3,
|
||||
circlesRadius: 1,
|
||||
},
|
||||
],
|
||||
addTooltip: true,
|
||||
|
|
|
@ -1674,7 +1674,8 @@ describe('migration visualization', () => {
|
|||
type = 'area',
|
||||
categoryAxes?: object[],
|
||||
valueAxes?: object[],
|
||||
hasPalette = false
|
||||
hasPalette = false,
|
||||
hasCirclesRadius = false
|
||||
) => ({
|
||||
attributes: {
|
||||
title: 'My Vis',
|
||||
|
@ -1694,6 +1695,21 @@ describe('migration visualization', () => {
|
|||
labels: {},
|
||||
},
|
||||
],
|
||||
seriesParams: [
|
||||
{
|
||||
show: true,
|
||||
type,
|
||||
mode: 'stacked',
|
||||
drawLinesBetweenPoints: true,
|
||||
lineWidth: 2,
|
||||
showCircles: true,
|
||||
interpolate: 'linear',
|
||||
valueAxis: 'ValueAxis-1',
|
||||
...(hasCirclesRadius && {
|
||||
circlesRadius: 3,
|
||||
}),
|
||||
},
|
||||
],
|
||||
...(hasPalette && {
|
||||
palette: {
|
||||
type: 'palette',
|
||||
|
@ -1732,6 +1748,20 @@ describe('migration visualization', () => {
|
|||
expect(palette.name).toEqual('default');
|
||||
});
|
||||
|
||||
it("should decorate existing docs with the circlesRadius attribute if it doesn't exist", () => {
|
||||
const migratedTestDoc = migrate(getTestDoc());
|
||||
const [result] = JSON.parse(migratedTestDoc.attributes.visState).params.seriesParams;
|
||||
|
||||
expect(result.circlesRadius).toEqual(1);
|
||||
});
|
||||
|
||||
it('should not decorate existing docs with the circlesRadius attribute if it exists', () => {
|
||||
const migratedTestDoc = migrate(getTestDoc('area', undefined, undefined, true, true));
|
||||
const [result] = JSON.parse(migratedTestDoc.attributes.visState).params.seriesParams;
|
||||
|
||||
expect(result.circlesRadius).toEqual(3);
|
||||
});
|
||||
|
||||
describe('labels.filter', () => {
|
||||
it('should keep existing categoryAxes labels.filter value', () => {
|
||||
const migratedTestDoc = migrate(getTestDoc('area', [{ labels: { filter: false } }]));
|
||||
|
|
|
@ -867,6 +867,20 @@ const decorateAxes = <T extends { labels: { filter?: boolean } }>(
|
|||
},
|
||||
}));
|
||||
|
||||
/**
|
||||
* Defaults circlesRadius to 1 if it is not configured
|
||||
*/
|
||||
const addCirclesRadius = <T extends { circlesRadius: number }>(axes: T[]): T[] =>
|
||||
axes.map((axis) => {
|
||||
const hasCircleRadiusAttribute = Number.isFinite(axis?.circlesRadius);
|
||||
return {
|
||||
...axis,
|
||||
...(!hasCircleRadiusAttribute && {
|
||||
circlesRadius: 1,
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
// Inlined from vis_type_xy
|
||||
const CHART_TYPE_AREA = 'area';
|
||||
const CHART_TYPE_LINE = 'line';
|
||||
|
@ -913,10 +927,12 @@ const migrateVislibAreaLineBarTypes: SavedObjectMigrationFn<any, any> = (doc) =>
|
|||
valueAxes:
|
||||
visState.params.valueAxes &&
|
||||
decorateAxes(visState.params.valueAxes, isHorizontalBar),
|
||||
seriesParams:
|
||||
visState.params.seriesParams && addCirclesRadius(visState.params.seriesParams),
|
||||
isVislibVis: true,
|
||||
detailedTooltip: true,
|
||||
...(isLineOrArea && {
|
||||
fittingFunction: 'zero',
|
||||
fittingFunction: 'linear',
|
||||
}),
|
||||
},
|
||||
}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue