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] Move XY chart config into popover and fix layering #41927

Merged
merged 5 commits into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"@babel/core": "7.4.5",
"@babel/polyfill": "7.4.4",
"@babel/register": "7.4.4",
"@elastic/charts": "^7.2.1",
"@elastic/charts": "^8.1.0",
"@elastic/datemath": "5.0.2",
"@elastic/eui": "12.4.0",
"@elastic/filesaver": "1.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ export const ConfigPanelWrapper = memo(function ConfigPanelWrapper(props: Config
}}
/>
{props.activeVisualizationId && props.visualizationState !== null && (
<NativeRenderer
render={props.visualizationMap[props.activeVisualizationId].renderConfigPanel}
nativeProps={{
dragDropContext: context,
state: props.visualizationState,
setState: setVisualizationState,
frame: props.framePublicAPI,
}}
/>
<div className="lnsConfigPanelWrapper">
<NativeRenderer
render={props.visualizationMap[props.activeVisualizationId].renderConfigPanel}
nativeProps={{
dragDropContext: context,
state: props.visualizationState,
setState: setVisualizationState,
frame: props.framePublicAPI,
}}
/>
</div>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,8 @@
font-size: 1.2em;
}

.lnsConfigPanelWrapper {
padding: $euiSize 0;
}

@import './suggestion_panel.scss';
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const IndexPatternDimensionPanel = memo(function IndexPatternDimensionPan
data-test-subj="indexPattern-dimensionPopover-remove"
iconType="cross"
iconSize="s"
size="s"
color="danger"
aria-label={i18n.translate('xpack.lens.indexPattern.removeColumnLabel', {
defaultMessage: 'Remove',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export function PopoverEditor(props: PopoverEditorProps) {
data-test-subj="indexPattern-configure-dimension"
onClick={() => setPopoverOpen(true)}
iconType="plusInCircle"
size="s"
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import _ from 'lodash';
import React from 'react';
import { render } from 'react-dom';
import { I18nProvider } from '@kbn/i18n/react';
import { EuiText } from '@elastic/eui';
import {
DatasourceDimensionPanelProps,
DatasourceDataPanelProps,
Expand Down Expand Up @@ -338,7 +339,9 @@ export function getIndexPatternDatasource({
renderLayerPanel: (domElement: Element, props: DatasourceLayerPanelProps) => {
render(
<I18nProvider>
<span>{state.indexPatterns[state.layers[props.layerId].indexPatternId].title}</span>
<EuiText size="s">
{state.indexPatterns[state.layers[props.layerId].indexPatternId].title}
</EuiText>
</I18nProvider>,
domElement
);
Expand Down

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

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
Expand Up @@ -71,6 +71,7 @@ export const buildExpression = (
arguments: {
xTitle: [xTitle],
yTitle: [yTitle],
isHorizontal: [state.isHorizontal],
legend: [
{
type: 'expression',
Expand Down Expand Up @@ -109,8 +110,6 @@ export const buildExpression = (
layerId: [layer.layerId],

title: [layer.title],
showGridlines: [layer.showGridlines],
position: [layer.position],
hide: [Boolean(layer.hide)],

xAccessor: [layer.xAccessor],
Expand Down
32 changes: 4 additions & 28 deletions x-pack/legacy/plugins/lens/public/xy_visualization_plugin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ export const legendConfig: ExpressionFunction<

interface AxisConfig {
title: string;
showGridlines: boolean;
position: Position;
hide?: boolean;
}

Expand All @@ -61,15 +59,6 @@ const axisConfig: { [key in keyof AxisConfig]: ArgumentType<AxisConfig[key]> } =
types: ['string'],
help: 'The axis title',
},
showGridlines: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense that we don't want to support them in the first release, but we could leave them in on the expression level and just pass in defaults for now. This might be a pattern - we don't have to expose every single thing in the UI, but it should be possible on the expression.

Just a suggestion, I'm also happy with removing it for now and revisiting this later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, but I'm not yet confident in either direction. The most flexible API is probably to wrap the elastic-charts library in an expression DSL, that way other teams can use this too- that feels like the better long-term plan to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a fan of removing unused stuff. If we need it in the future, we can always add it back.

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',
},
hide: {
types: ['boolean'],
default: false,
Expand Down Expand Up @@ -137,15 +126,7 @@ export const layerConfig: ExpressionFunction<
},
seriesType: {
types: ['string'],
options: [
'bar',
'line',
'area',
'horizontal_bar',
'bar_stacked',
'area_stacked',
'horizontal_bar_stacked',
],
options: ['bar', 'line', 'area', 'bar_stacked', 'area_stacked'],
help: 'The type of chart to display.',
},
splitAccessor: {
Expand All @@ -171,14 +152,7 @@ export const layerConfig: ExpressionFunction<
},
};

export type SeriesType =
| 'bar'
| 'horizontal_bar'
| 'line'
| 'area'
| 'bar_stacked'
| 'horizontal_bar_stacked'
| 'area_stacked';
export type SeriesType = 'bar' | 'line' | 'area' | 'bar_stacked' | 'area_stacked';

export type LayerConfig = AxisConfig & {
layerId: string;
Expand All @@ -198,12 +172,14 @@ export interface XYArgs {
yTitle: string;
legend: LegendConfig;
layers: LayerArgs[];
isHorizontal: boolean;
}

// Persisted parts of the state
export interface XYState {
legend: LegendConfig;
layers: LayerConfig[];
isHorizontal: boolean;
}

export type State = XYState;
Expand Down
Loading