Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lens] Xy expression building #37967

Merged
merged 28 commits into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d2f3702
Use data plugin expression renderer for rendering expression
flash1293 May 31, 2019
fc85182
remove unused typings
flash1293 May 31, 2019
1333bad
start wiring up expressions and stuff which is already there
flash1293 May 31, 2019
6cd0027
register xy charts
flash1293 May 31, 2019
acd6126
remove unused import
flash1293 May 31, 2019
aff1980
Merge branch 'feature/lens' into lens/expression-rendering-2
flash1293 May 31, 2019
9a54c1e
Merge branch 'lens/expression-rendering-2' into lens/expression-regis…
flash1293 May 31, 2019
88aef13
Merge branch 'feature/lens' into lens/expression-rendering-2
flash1293 Jun 3, 2019
71f2699
Merge branch 'lens/expression-rendering-2' into lens/expression-regis…
flash1293 Jun 3, 2019
f6c7ca9
error handling for expressions
flash1293 Jun 3, 2019
fcf0993
Merge branch 'feature/lens' into lens/expression-registering
flash1293 Jun 3, 2019
3d4cf08
remove unused type definition
flash1293 Jun 3, 2019
7d7a072
clean up imports
flash1293 Jun 3, 2019
616985c
fix comment
flash1293 Jun 3, 2019
843c541
only re-render once per expression change
flash1293 Jun 3, 2019
bcc847c
remove unused import
flash1293 Jun 3, 2019
fc629ce
add typing for toExpression
flash1293 Jun 4, 2019
df15757
add types for expression parsing
flash1293 Jun 4, 2019
8e4169d
build expression out of XY vis state
flash1293 Jun 4, 2019
5a6f644
fix test
flash1293 Jun 4, 2019
9226e85
Merge branch 'lens/expression-registering' into lens/xy-expression-bu…
flash1293 Jun 4, 2019
44d9238
Merge branch 'feature/lens' into lens/expression-registering
flash1293 Jun 4, 2019
c6f3df9
Merge branch 'lens/expression-registering' into lens/xy-expression-bu…
flash1293 Jun 4, 2019
ff143b7
Merge branch 'feature/lens' into lens/xy-expression-building
flash1293 Jun 5, 2019
83e6fbe
add autoload to have working angular dependencies
flash1293 Jun 5, 2019
606da5f
add all necessary legcay dependency imports to plugin
flash1293 Jun 6, 2019
d4fb0bd
Merge branch 'feature/lens' into lens/xy-expression-building
flash1293 Jun 6, 2019
06ba998
Merge branch 'feature/lens' into lens/xy-expression-building
flash1293 Jun 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions x-pack/plugins/lens/public/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Import the EUI global scope so we can use EUI constants
@import 'src/legacy/ui/public/styles/_styling_constants';

@import "./drag_drop/drag_drop.scss";
@import "./xy_visualization_plugin/xy_expression.scss";
6 changes: 6 additions & 0 deletions x-pack/plugins/lens/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

export * from './types';

import 'ui/autoload/all';
import 'uiExports/fieldFormats';
import 'uiExports/search';
import 'uiExports/visRequestHandlers';
import 'uiExports/visResponseHandlers';

import { render, unmountComponentAtNode } from 'react-dom';
import { IScope } from 'angular';
import chrome from 'ui/chrome';
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.lnsChart {
// TODO style this dependent on the screen height (see POC)
height: 500px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { xyVisualization } from './xy_visualization';
import { Position } from '@elastic/charts';
import { DatasourcePublicAPI } from '../types';
import { State } from './types';

function exampleState(): State {
Expand All @@ -30,7 +31,7 @@ function exampleState(): State {
};
}

describe('IndexPattern Data Source', () => {
describe('XY visualization', () => {
describe('#initialize', () => {
it('loads default state', () => {
const initialState = xyVisualization.initialize();
Expand Down Expand Up @@ -78,4 +79,12 @@ Object {
expect(xyVisualization.getPersistableState(exampleState())).toEqual(exampleState());
});
});

describe('#toExpression', () => {
it('should map to a valid AST', () => {
expect(
xyVisualization.toExpression(exampleState(), {} as DatasourcePublicAPI)
).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,68 @@ export const xyVisualization: Visualization<State, PersistableState> = {
domElement
),

toExpression: () => '',
toExpression: state => ({
type: 'expression',
chain: [
{
type: 'function',
function: 'lens_xy_chart',
arguments: {
seriesType: [state.seriesType],
title: [state.title],
legend: [
{
type: 'expression',
chain: [
{
type: 'function',
function: 'lens_xy_legendConfig',
arguments: {
isVisible: [state.legend.isVisible],
position: [state.legend.position],
},
},
],
},
],
x: [
{
type: 'expression',
chain: [
{
type: 'function',
function: 'lens_xy_xConfig',
arguments: {
title: [state.x.title],
showGridlines: [state.x.showGridlines],
position: [state.x.position],
accessor: [state.x.accessor],
},
},
],
},
],
y: [
{
type: 'expression',
chain: [
{
type: 'function',
function: 'lens_xy_yConfig',
arguments: {
title: [state.y.title],
showGridlines: [state.y.showGridlines],
position: [state.y.position],
accessors: state.y.accessors,
},
},
],
},
],
splitSeriesAccessors: state.splitSeriesAccessors,
stackAccessors: state.stackAccessors,
},
},
],
}),
};