This repository has been archived by the owner on Mar 31, 2024. It is now read-only.
forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[XY] Expression chart. (elastic#127150)
* added xy plugin. * Added expressionXY limits. * Added xy expression functions to the expression_xy plugin. * Moved xy to a separate plugin. * Fixed bugs, caused by the refactoring process. * Fixed lens snapshots. * Removed new line. * Fixed xy_chart tests. * Added lazy loading for xy chart. * Fixed xy chart test. * Fixed broken chart selectors. * Fixed dashboard tests. * dashboard test fixed. * Fixed heatmap vis. * Smokescreen test fixed. * more fixes. * async dashboard tests fixed. * Fixed xy smokescreen tests selectors. * fixed show_underlying_data tests. * Updated snapshots. * updated limits. * Fixed more selectors * Fixed persistent context test. * Fixed some more test at ml. * Fixed types and imports * Fixed handlers.inspectorAdapters.tables.logDatatable * Fixed logDatatable * Translations fixed. * Fixed "Visualize App ... cleans filters and query" test. * Fixed "lens disable auto-apply tests" test. * Updated dashboard tests. * Fixed translations. * Expression tests fixed. * Cleaned up expression_xy. * cleaned up lens xy_visualization. * Moved XY state types to lens. * Update src/plugins/chart_expressions/expression_xy/README.md Co-authored-by: Marta Bondyra <[email protected]> * [CI] Auto-commit changed files from 'node scripts/build_plugin_list_docs' * Removed yConfig from *Layers types * Removed not used utils and styles. Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Marta Bondyra <[email protected]>
- Loading branch information
1 parent
0ea741d
commit 072fe63
Showing
172 changed files
with
7,945 additions
and
5,220 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# expressionXY | ||
|
||
Expression XY plugin adds a `xy` renderer and function to the expression plugin. The renderer will display the `xy` chart. | ||
|
||
--- | ||
|
||
## Development | ||
|
||
See the [kibana contributing guide](https://github.com/elastic/kibana/blob/main/CONTRIBUTING.md) for instructions setting up your development environment. |
128 changes: 128 additions & 0 deletions
128
src/plugins/chart_expressions/expression_xy/common/__mocks__/index.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,128 @@ | ||
/* | ||
* 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 { Position } from '@elastic/charts'; | ||
import { PaletteOutput } from 'src/plugins/charts/common'; | ||
import { Datatable, DatatableRow } from 'src/plugins/expressions'; | ||
import { LayerTypes } from '../constants'; | ||
import { DataLayerConfigResult, LensMultiTable, XYArgs } from '../types'; | ||
|
||
export const mockPaletteOutput: PaletteOutput = { | ||
type: 'palette', | ||
name: 'mock', | ||
params: {}, | ||
}; | ||
|
||
export const createSampleDatatableWithRows = (rows: DatatableRow[]): Datatable => ({ | ||
type: 'datatable', | ||
columns: [ | ||
{ | ||
id: 'a', | ||
name: 'a', | ||
meta: { type: 'number', params: { id: 'number', params: { pattern: '0,0.000' } } }, | ||
}, | ||
{ | ||
id: 'b', | ||
name: 'b', | ||
meta: { type: 'number', params: { id: 'number', params: { pattern: '000,0' } } }, | ||
}, | ||
{ | ||
id: 'c', | ||
name: 'c', | ||
meta: { | ||
type: 'date', | ||
field: 'order_date', | ||
sourceParams: { type: 'date-histogram', params: { interval: 'auto' } }, | ||
params: { id: 'string' }, | ||
}, | ||
}, | ||
{ id: 'd', name: 'ColD', meta: { type: 'string' } }, | ||
], | ||
rows, | ||
}); | ||
|
||
export const sampleLayer: DataLayerConfigResult = { | ||
type: 'dataLayer', | ||
layerId: 'first', | ||
layerType: LayerTypes.DATA, | ||
seriesType: 'line', | ||
xAccessor: 'c', | ||
accessors: ['a', 'b'], | ||
splitAccessor: 'd', | ||
columnToLabel: '{"a": "Label A", "b": "Label B", "d": "Label D"}', | ||
xScaleType: 'ordinal', | ||
yScaleType: 'linear', | ||
isHistogram: false, | ||
palette: mockPaletteOutput, | ||
}; | ||
|
||
export const createArgsWithLayers = (layers: DataLayerConfigResult[] = [sampleLayer]): XYArgs => ({ | ||
xTitle: '', | ||
yTitle: '', | ||
yRightTitle: '', | ||
legend: { | ||
type: 'legendConfig', | ||
isVisible: false, | ||
position: Position.Top, | ||
}, | ||
valueLabels: 'hide', | ||
valuesInLegend: false, | ||
axisTitlesVisibilitySettings: { | ||
type: 'axisTitlesVisibilityConfig', | ||
x: true, | ||
yLeft: true, | ||
yRight: true, | ||
}, | ||
tickLabelsVisibilitySettings: { | ||
type: 'tickLabelsConfig', | ||
x: true, | ||
yLeft: false, | ||
yRight: false, | ||
}, | ||
labelsOrientation: { | ||
type: 'labelsOrientationConfig', | ||
x: 0, | ||
yLeft: -90, | ||
yRight: -45, | ||
}, | ||
gridlinesVisibilitySettings: { | ||
type: 'gridlinesConfig', | ||
x: true, | ||
yLeft: false, | ||
yRight: false, | ||
}, | ||
yLeftExtent: { | ||
mode: 'full', | ||
type: 'axisExtentConfig', | ||
}, | ||
yRightExtent: { | ||
mode: 'full', | ||
type: 'axisExtentConfig', | ||
}, | ||
layers, | ||
}); | ||
|
||
export function sampleArgs() { | ||
const data: LensMultiTable = { | ||
type: 'lens_multitable', | ||
tables: { | ||
first: createSampleDatatableWithRows([ | ||
{ a: 1, b: 2, c: 'I', d: 'Foo' }, | ||
{ a: 1, b: 5, c: 'J', d: 'Bar' }, | ||
]), | ||
}, | ||
dateRange: { | ||
fromDate: new Date('2019-01-02T05:00:00.000Z'), | ||
toDate: new Date('2019-01-03T05:00:00.000Z'), | ||
}, | ||
}; | ||
|
||
const args: XYArgs = createArgsWithLayers(); | ||
|
||
return { data, args }; | ||
} |
111 changes: 111 additions & 0 deletions
111
src/plugins/chart_expressions/expression_xy/common/constants.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,111 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export const XY_VIS = 'xyVis'; | ||
export const Y_CONFIG = 'yConfig'; | ||
export const MULTITABLE = 'lens_multitable'; | ||
export const DATA_LAYER = 'dataLayer'; | ||
export const LEGEND_CONFIG = 'legendConfig'; | ||
export const XY_VIS_RENDERER = 'xyVis'; | ||
export const GRID_LINES_CONFIG = 'gridlinesConfig'; | ||
export const ANNOTATION_LAYER = 'annotationLayer'; | ||
export const TICK_LABELS_CONFIG = 'tickLabelsConfig'; | ||
export const AXIS_EXTENT_CONFIG = 'axisExtentConfig'; | ||
export const REFERENCE_LINE_LAYER = 'referenceLineLayer'; | ||
export const LABELS_ORIENTATION_CONFIG = 'labelsOrientationConfig'; | ||
export const AXIS_TITLES_VISIBILITY_CONFIG = 'axisTitlesVisibilityConfig'; | ||
|
||
export const LayerTypes = { | ||
DATA: 'data', | ||
REFERENCELINE: 'referenceLine', | ||
ANNOTATIONS: 'annotations', | ||
} as const; | ||
|
||
export const FittingFunctions = { | ||
NONE: 'None', | ||
ZERO: 'Zero', | ||
LINEAR: 'Linear', | ||
CARRY: 'Carry', | ||
LOOKAHEAD: 'Lookahead', | ||
} as const; | ||
|
||
export const EndValues = { | ||
NONE: 'None', | ||
ZERO: 'Zero', | ||
NEAREST: 'Nearest', | ||
} as const; | ||
|
||
export const YAxisModes = { | ||
AUTO: 'auto', | ||
LEFT: 'left', | ||
RIGHT: 'right', | ||
BOTTOM: 'bottom', | ||
} as const; | ||
|
||
export const AxisExtentModes = { | ||
FULL: 'full', | ||
CUSTOM: 'custom', | ||
DATA_BOUNDS: 'dataBounds', | ||
} as const; | ||
|
||
export const LineStyles = { | ||
SOLID: 'solid', | ||
DASHED: 'dashed', | ||
DOTTED: 'dotted', | ||
} as const; | ||
|
||
export const FillStyles = { | ||
NONE: 'none', | ||
ABOVE: 'above', | ||
BELOW: 'below', | ||
} as const; | ||
|
||
export const IconPositions = { | ||
AUTO: 'auto', | ||
LEFT: 'left', | ||
RIGHT: 'right', | ||
ABOVE: 'above', | ||
BELOW: 'below', | ||
} as const; | ||
|
||
export const SeriesTypes = { | ||
BAR: 'bar', | ||
LINE: 'line', | ||
AREA: 'area', | ||
BAR_STACKED: 'bar_stacked', | ||
AREA_STACKED: 'area_stacked', | ||
BAR_HORIZONTAL: 'bar_horizontal', | ||
BAR_PERCENTAGE_STACKED: 'bar_percentage_stacked', | ||
BAR_HORIZONTAL_STACKED: 'bar_horizontal_stacked', | ||
AREA_PERCENTAGE_STACKED: 'area_percentage_stacked', | ||
BAR_HORIZONTAL_PERCENTAGE_STACKED: 'bar_horizontal_percentage_stacked', | ||
} as const; | ||
|
||
export const YScaleTypes = { | ||
TIME: 'time', | ||
LINEAR: 'linear', | ||
LOG: 'log', | ||
SQRT: 'sqrt', | ||
} as const; | ||
|
||
export const XScaleTypes = { | ||
TIME: 'time', | ||
LINEAR: 'linear', | ||
ORDINAL: 'ordinal', | ||
} as const; | ||
|
||
export const XYCurveTypes = { | ||
LINEAR: 'LINEAR', | ||
CURVE_MONOTONE_X: 'CURVE_MONOTONE_X', | ||
} as const; | ||
|
||
export const ValueLabelModes = { | ||
HIDE: 'hide', | ||
INSIDE: 'inside', | ||
OUTSIDE: 'outside', | ||
} as const; |
49 changes: 49 additions & 0 deletions
49
...ns/chart_expressions/expression_xy/common/expression_functions/annotation_layer_config.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,49 @@ | ||
/* | ||
* 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 type { ExpressionFunctionDefinition } from '../../../../expressions/common'; | ||
import { LayerTypes, ANNOTATION_LAYER } from '../constants'; | ||
import { AnnotationLayerArgs, AnnotationLayerConfigResult } from '../types'; | ||
|
||
export function annotationLayerConfigFunction(): ExpressionFunctionDefinition< | ||
typeof ANNOTATION_LAYER, | ||
null, | ||
AnnotationLayerArgs, | ||
AnnotationLayerConfigResult | ||
> { | ||
return { | ||
name: ANNOTATION_LAYER, | ||
aliases: [], | ||
type: ANNOTATION_LAYER, | ||
inputTypes: ['null'], | ||
help: 'Annotation layer in lens', | ||
args: { | ||
layerId: { | ||
types: ['string'], | ||
help: '', | ||
}, | ||
hide: { | ||
types: ['boolean'], | ||
default: false, | ||
help: 'Show details', | ||
}, | ||
annotations: { | ||
types: ['manual_event_annotation'], | ||
help: '', | ||
multi: true, | ||
}, | ||
}, | ||
fn: (input, args) => { | ||
return { | ||
type: ANNOTATION_LAYER, | ||
...args, | ||
layerType: LayerTypes.ANNOTATIONS, | ||
}; | ||
}, | ||
}; | ||
} |
54 changes: 54 additions & 0 deletions
54
...plugins/chart_expressions/expression_xy/common/expression_functions/axis_extent_config.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,54 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import type { ExpressionFunctionDefinition } from '../../../../expressions/common'; | ||
import { AxisExtentConfig, AxisExtentConfigResult } from '../types'; | ||
import { AxisExtentModes, AXIS_EXTENT_CONFIG } from '../constants'; | ||
|
||
export const axisExtentConfigFunction: ExpressionFunctionDefinition< | ||
typeof AXIS_EXTENT_CONFIG, | ||
null, | ||
AxisExtentConfig, | ||
AxisExtentConfigResult | ||
> = { | ||
name: AXIS_EXTENT_CONFIG, | ||
aliases: [], | ||
type: AXIS_EXTENT_CONFIG, | ||
help: i18n.translate('expressionXY.axisExtentConfig.help', { | ||
defaultMessage: `Configure the xy chart's axis extents`, | ||
}), | ||
inputTypes: ['null'], | ||
args: { | ||
mode: { | ||
types: ['string'], | ||
options: [...Object.values(AxisExtentModes)], | ||
help: i18n.translate('expressionXY.axisExtentConfig.extentMode.help', { | ||
defaultMessage: 'The extent mode', | ||
}), | ||
}, | ||
lowerBound: { | ||
types: ['number'], | ||
help: i18n.translate('expressionXY.axisExtentConfig.lowerBound.help', { | ||
defaultMessage: 'Lower bound', | ||
}), | ||
}, | ||
upperBound: { | ||
types: ['number'], | ||
help: i18n.translate('expressionXY.axisExtentConfig.upperBound.help', { | ||
defaultMessage: 'Upper bound', | ||
}), | ||
}, | ||
}, | ||
fn(input, args) { | ||
return { | ||
type: AXIS_EXTENT_CONFIG, | ||
...args, | ||
}; | ||
}, | ||
}; |
Oops, something went wrong.