-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Lens] Lens/xy config panel (#37391)
Basic xy chart configuration panel
- Loading branch information
1 parent
bbf80f2
commit 717eaff
Showing
16 changed files
with
902 additions
and
324 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
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
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
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
146 changes: 146 additions & 0 deletions
146
x-pack/plugins/lens/public/xy_visualization_plugin/types.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,146 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { Position } from '@elastic/charts'; | ||
import { | ||
ExpressionFunction, | ||
ArgumentType, | ||
} from '../../../../../src/legacy/core_plugins/interpreter/public'; | ||
|
||
export interface LegendConfig { | ||
isVisible: boolean; | ||
position: Position; | ||
} | ||
|
||
type LegendConfigResult = LegendConfig & { type: 'lens_xy_legendConfig' }; | ||
|
||
export const legendConfig: ExpressionFunction< | ||
'lens_xy_legendConfig', | ||
null, | ||
LegendConfig, | ||
LegendConfigResult | ||
> = { | ||
name: 'lens_xy_legendConfig', | ||
aliases: [], | ||
type: 'lens_xy_legendConfig', | ||
help: `Configure the xy chart's legend`, | ||
context: { | ||
types: ['null'], | ||
}, | ||
args: { | ||
isVisible: { | ||
types: ['boolean'], | ||
help: 'Specifies whether or not the legend is visible.', | ||
}, | ||
position: { | ||
types: ['string'], | ||
options: [Position.Top, Position.Right, Position.Bottom, Position.Left], | ||
help: 'Specifies the legend position.', | ||
}, | ||
}, | ||
fn: function fn(_context: unknown, args: LegendConfig) { | ||
return { | ||
type: 'lens_xy_legendConfig', | ||
...args, | ||
}; | ||
}, | ||
}; | ||
|
||
interface AxisConfig { | ||
title: string; | ||
showGridlines: boolean; | ||
position: Position; | ||
} | ||
|
||
const axisConfig: { [key in keyof AxisConfig]: ArgumentType<AxisConfig[key]> } = { | ||
title: { | ||
types: ['string'], | ||
help: 'The axis title', | ||
}, | ||
showGridlines: { | ||
types: ['boolean'], | ||
help: 'Show / hide axis grid lines.', | ||
}, | ||
position: { | ||
types: ['string'], | ||
options: [Position.Top, Position.Right, Position.Bottom, Position.Left], | ||
help: 'The position of the axis', | ||
}, | ||
}; | ||
|
||
export interface YConfig extends AxisConfig { | ||
accessors: string[]; | ||
} | ||
|
||
type YConfigResult = YConfig & { type: 'lens_xy_yConfig' }; | ||
|
||
export const yConfig: ExpressionFunction<'lens_xy_yConfig', null, YConfig, YConfigResult> = { | ||
name: 'lens_xy_yConfig', | ||
aliases: [], | ||
type: 'lens_xy_yConfig', | ||
help: `Configure the xy chart's y axis`, | ||
context: { | ||
types: ['null'], | ||
}, | ||
args: { | ||
...axisConfig, | ||
accessors: { | ||
types: ['string'], | ||
help: 'The columns to display on the y axis.', | ||
multi: true, | ||
}, | ||
}, | ||
fn: function fn(_context: unknown, args: YConfig) { | ||
return { | ||
type: 'lens_xy_yConfig', | ||
...args, | ||
}; | ||
}, | ||
}; | ||
|
||
export interface XConfig extends AxisConfig { | ||
accessor: string; | ||
} | ||
|
||
type XConfigResult = XConfig & { type: 'lens_xy_xConfig' }; | ||
|
||
export const xConfig: ExpressionFunction<'lens_xy_xConfig', null, XConfig, XConfigResult> = { | ||
name: 'lens_xy_xConfig', | ||
aliases: [], | ||
type: 'lens_xy_xConfig', | ||
help: `Configure the xy chart's x axis`, | ||
context: { | ||
types: ['null'], | ||
}, | ||
args: { | ||
...axisConfig, | ||
accessor: { | ||
types: ['string'], | ||
help: 'The column to display on the x axis.', | ||
}, | ||
}, | ||
fn: function fn(_context: unknown, args: XConfig) { | ||
return { | ||
type: 'lens_xy_xConfig', | ||
...args, | ||
}; | ||
}, | ||
}; | ||
|
||
export type SeriesType = 'bar' | 'horizontal_bar' | 'line' | 'area'; | ||
|
||
export interface XYArgs { | ||
seriesType: SeriesType; | ||
title: string; | ||
legend: LegendConfig; | ||
y: YConfig; | ||
x: XConfig; | ||
splitSeriesAccessors: string[]; | ||
stackAccessors: string[]; | ||
} | ||
|
||
export type State = XYArgs; | ||
export type PersistableState = XYArgs; |
Oops, something went wrong.