-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[XY] Mark size configuration. (#130361)
* Added tests for the case when markSizeRatio and markSizeAccessor are specified. * Added markSizeAccessor to extendedDataLayer and xyVis. * Fixed markSizeRatio default value. * Added `size` support from `pointseries`. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
d9e6ef3
commit dd8bd6f
Showing
21 changed files
with
438 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
.../expression_xy/common/expression_functions/__snapshots__/extended_data_layer.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
...sions/expression_xy/common/expression_functions/__snapshots__/layered_xy_vis.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...t_expressions/expression_xy/common/expression_functions/__snapshots__/xy_vis.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...s/chart_expressions/expression_xy/common/expression_functions/extended_data_layer.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { ExtendedDataLayerArgs } from '../types'; | ||
import { createMockExecutionContext } from '@kbn/expressions-plugin/common/mocks'; | ||
import { mockPaletteOutput, sampleArgs } from '../__mocks__'; | ||
import { LayerTypes } from '../constants'; | ||
import { extendedDataLayerFunction } from './extended_data_layer'; | ||
|
||
describe('extendedDataLayerConfig', () => { | ||
test('produces the correct arguments', async () => { | ||
const { data } = sampleArgs(); | ||
const args: ExtendedDataLayerArgs = { | ||
seriesType: 'line', | ||
xAccessor: 'c', | ||
accessors: ['a', 'b'], | ||
splitAccessor: 'd', | ||
xScaleType: 'linear', | ||
isHistogram: false, | ||
palette: mockPaletteOutput, | ||
markSizeAccessor: 'b', | ||
}; | ||
|
||
const result = await extendedDataLayerFunction.fn(data, args, createMockExecutionContext()); | ||
|
||
expect(result).toEqual({ | ||
type: 'extendedDataLayer', | ||
layerType: LayerTypes.DATA, | ||
...args, | ||
table: data, | ||
}); | ||
}); | ||
|
||
test('throws the error if markSizeAccessor is provided to the not line/area chart', async () => { | ||
const { data } = sampleArgs(); | ||
const args: ExtendedDataLayerArgs = { | ||
seriesType: 'bar', | ||
xAccessor: 'c', | ||
accessors: ['a', 'b'], | ||
splitAccessor: 'd', | ||
xScaleType: 'linear', | ||
isHistogram: false, | ||
palette: mockPaletteOutput, | ||
markSizeAccessor: 'b', | ||
}; | ||
|
||
expect( | ||
extendedDataLayerFunction.fn(data, args, createMockExecutionContext()) | ||
).rejects.toThrowErrorMatchingSnapshot(); | ||
}); | ||
|
||
test("throws the error if markSizeAccessor doesn't have the corresponding column in the table", async () => { | ||
const { data } = sampleArgs(); | ||
const args: ExtendedDataLayerArgs = { | ||
seriesType: 'line', | ||
xAccessor: 'c', | ||
accessors: ['a', 'b'], | ||
splitAccessor: 'd', | ||
xScaleType: 'linear', | ||
isHistogram: false, | ||
palette: mockPaletteOutput, | ||
markSizeAccessor: 'nonsense', | ||
}; | ||
|
||
expect( | ||
extendedDataLayerFunction.fn(data, args, createMockExecutionContext()) | ||
).rejects.toThrowErrorMatchingSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...lugins/chart_expressions/expression_xy/common/expression_functions/layered_xy_vis.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { layeredXyVisFunction } from '.'; | ||
import { createMockExecutionContext } from '@kbn/expressions-plugin/common/mocks'; | ||
import { sampleArgs, sampleExtendedLayer } from '../__mocks__'; | ||
import { XY_VIS } from '../constants'; | ||
|
||
describe('layeredXyVis', () => { | ||
test('it renders with the specified data and args', async () => { | ||
const { data, args } = sampleArgs(); | ||
const { layers, ...rest } = args; | ||
const result = await layeredXyVisFunction.fn( | ||
data, | ||
{ ...rest, layers: [sampleExtendedLayer] }, | ||
createMockExecutionContext() | ||
); | ||
|
||
expect(result).toEqual({ | ||
type: 'render', | ||
as: XY_VIS, | ||
value: { args: { ...rest, layers: [sampleExtendedLayer] } }, | ||
}); | ||
}); | ||
|
||
test('it should throw error if markSizeRatio is lower then 1 or greater then 100', async () => { | ||
const { data, args } = sampleArgs(); | ||
const { layers, ...rest } = args; | ||
|
||
expect( | ||
layeredXyVisFunction.fn( | ||
data, | ||
{ | ||
...rest, | ||
markSizeRatio: 0, | ||
layers: [sampleExtendedLayer], | ||
}, | ||
createMockExecutionContext() | ||
) | ||
).rejects.toThrowErrorMatchingSnapshot(); | ||
|
||
expect( | ||
layeredXyVisFunction.fn( | ||
data, | ||
{ | ||
...rest, | ||
markSizeRatio: 101, | ||
layers: [sampleExtendedLayer], | ||
}, | ||
createMockExecutionContext() | ||
) | ||
).rejects.toThrowErrorMatchingSnapshot(); | ||
}); | ||
|
||
test('it should throw error if markSizeRatio is specified if no markSizeAccessor is present', async () => { | ||
const { data, args } = sampleArgs(); | ||
const { layers, ...rest } = args; | ||
|
||
expect( | ||
layeredXyVisFunction.fn( | ||
data, | ||
{ | ||
...rest, | ||
markSizeRatio: 10, | ||
layers: [sampleExtendedLayer], | ||
}, | ||
createMockExecutionContext() | ||
) | ||
).rejects.toThrowErrorMatchingSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.