[XY] system_palette and palette support. (#128053)

* Added support of `system_palette` and `palette` types at the `dataLayer` `palette` arg.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>
This commit is contained in:
Yaroslav Kuznietsov 2022-03-29 11:58:26 +03:00 committed by GitHub
parent bef90a5866
commit 2dcdbbe658
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 24 deletions

View file

@ -106,11 +106,11 @@ export const dataLayerConfigFunction: ExpressionFunctionDefinition<
}),
},
palette: {
default: `{theme "palette" default={system_palette name="default"} }`,
types: ['palette', 'system_palette'],
help: i18n.translate('expressionXY.dataLayer.palette.help', {
defaultMessage: 'Palette',
}),
types: ['palette'],
default: '{palette}',
},
},
fn(input, args) {

View file

@ -113,6 +113,22 @@ Object {
"layerId": Array [
"first",
],
"palette": Array [
Object {
"chain": Array [
Object {
"arguments": Object {
"name": Array [
"default",
],
},
"function": "system_palette",
"type": "function",
},
],
"type": "expression",
},
],
"seriesType": Array [
"area",
],

View file

@ -480,29 +480,31 @@ const dataLayerToExpression = (
seriesType: [layer.seriesType],
accessors: layer.accessors,
columnToLabel: [JSON.stringify(columnToLabel)],
...(layer.palette
? {
palette: [
{
type: 'expression',
chain: [
{
type: 'function',
function: 'theme',
arguments: {
variable: ['palette'],
default: [
paletteService
.get(layer.palette.name)
.toExpression(layer.palette.params),
],
},
palette: [
{
type: 'expression',
chain: [
layer.palette
? {
type: 'function',
function: 'theme',
arguments: {
variable: ['palette'],
default: [
paletteService.get(layer.palette.name).toExpression(layer.palette.params),
],
},
],
},
],
}
: {}),
}
: {
type: 'function',
function: 'system_palette',
arguments: {
name: ['default'],
},
},
],
},
],
},
},
],