-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Lens] Add metric Viz config options, title position and sizing #124124
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
Changes from 1 commit
dbdc290
b093f5e
ba3448e
932545d
b3329c2
e1b2643
c1934ed
b0aaec6
00328a7
da64340
5ebd718
9384fa1
a0514f8
b9f7a61
3bfdf0b
159ffd0
05c8b50
56c0bb4
71c3162
321f8f3
b139f93
e4d3b03
cd89b4e
8726fb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,24 @@ export const metricChart: ExpressionFunctionDefinition< | |
| defaultMessage: 'The chart title.', | ||
| }), | ||
| }, | ||
| titleSize: { | ||
| types: ['string'], | ||
| help: i18n.translate('xpack.lens.metric.titleSize.help', { | ||
| defaultMessage: 'The chart title size.', | ||
| }), | ||
| }, | ||
| titlePosition: { | ||
| types: ['string'], | ||
| help: i18n.translate('xpack.lens.metric.titlePosition.help', { | ||
| defaultMessage: 'The chart title position.', | ||
|
shahzad31 marked this conversation as resolved.
Outdated
|
||
| }), | ||
| }, | ||
|
MichaelMarcialis marked this conversation as resolved.
|
||
| titleAlignPosition: { | ||
| types: ['string'], | ||
| help: i18n.translate('xpack.lens.metric.titleAlignPosition.help', { | ||
| defaultMessage: 'The chart title align position.', | ||
| }), | ||
| }, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have doubts on the namings here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, the terms used for these text-based elements in Lens are contextual depending on the current visualization and where the text is used. For example, we use all of the following in difference circumstances:
Dashboards does use the term "panel title" for top-left text in a dashboard panel. While there could be some potential for confusion between Lens' usage of "title" and Dashboard's usage of "panel title", I don't think it's a huge concern at the moment for the following reasons:
For the time being, I'm personally fine with the term "title" in this circumstance, but I will defer to others if they feel strongly about it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MichaelMarcialis I'm a bit confused because I don't see where in Lens you are using the words The title is used on the When I think of a As always is a matter of consistency across the interface and I don't see that neither with the term |
||
| description: { | ||
| types: ['string'], | ||
| help: '', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * 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; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import React, { memo } from 'react'; | ||
| import { EuiFlexGroup, EuiFlexItem, htmlIdGenerator } from '@elastic/eui'; | ||
| import type { VisualizationToolbarProps } from '../../types'; | ||
|
|
||
| import { VisualOptionsPopover } from './visual_options_popover'; | ||
| import { MetricState } from '../../../common/expressions'; | ||
|
|
||
| export const MetricToolbar = memo(function MetricToolbar( | ||
| props: VisualizationToolbarProps<MetricState> | ||
| ) { | ||
| const { state, setState, frame } = props; | ||
|
|
||
| return ( | ||
| <EuiFlexGroup gutterSize="m" justifyContent="spaceBetween" responsive={false}> | ||
| <EuiFlexItem> | ||
| <EuiFlexGroup gutterSize="none" responsive={false}> | ||
| <VisualOptionsPopover | ||
| state={state} | ||
| setState={setState} | ||
| datasourceLayers={frame.datasourceLayers} | ||
| /> | ||
| </EuiFlexGroup> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| ); | ||
| }); | ||
|
|
||
| export const idPrefix = htmlIdGenerator()(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
|
MichaelMarcialis marked this conversation as resolved.
Outdated
|
||
| * 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; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { EuiFormRow, EuiSuperSelect } from '@elastic/eui'; | ||
| import { MetricState } from '../../../common/expressions'; | ||
|
|
||
| export interface TitlePositionProps { | ||
| state: MetricState; | ||
| setState: (newState: MetricState) => void; | ||
| } | ||
|
|
||
| const titleSizes = [ | ||
| { id: 'xs', label: 'XS' }, | ||
| { id: 's', label: 'S' }, | ||
| { id: 'm', label: 'M' }, | ||
| { id: 'l', label: 'L' }, | ||
| { id: 'xl', label: 'XL' }, | ||
| { id: 'xxl', label: 'XXL' }, | ||
|
MichaelMarcialis marked this conversation as resolved.
Outdated
|
||
| ]; | ||
|
shahzad31 marked this conversation as resolved.
Outdated
|
||
|
|
||
| export const TitleSizeOptions: React.FC<TitlePositionProps> = ({ state, setState }) => { | ||
| return ( | ||
| <EuiFormRow | ||
| display="columnCompressed" | ||
| label={ | ||
| <> | ||
| {i18n.translate('xpack.lens.metricChart.titleSizeLabel', { | ||
| defaultMessage: 'Title size', | ||
|
MichaelMarcialis marked this conversation as resolved.
Outdated
|
||
| })} | ||
| </> | ||
| } | ||
| > | ||
| <EuiSuperSelect | ||
| data-test-subj="lnsMissingValuesSelect" | ||
| compressed | ||
| options={titleSizes.map((position) => { | ||
| return { | ||
| value: position.id, | ||
| dropdownDisplay: position.label, | ||
| inputDisplay: position.label, | ||
| }; | ||
| })} | ||
| valueOfSelected={state.titleSize ?? 'xl'} | ||
| onChange={(value) => { | ||
| setState({ ...state, titleSize: value }); | ||
| }} | ||
| itemLayoutAlign="top" | ||
| hasDividers | ||
| /> | ||
| </EuiFormRow> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * 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; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { EuiFormRow, EuiSuperSelect } from '@elastic/eui'; | ||
| import { MetricState } from '../../../common/expressions'; | ||
|
|
||
| export interface TitlePositionProps { | ||
| state: MetricState; | ||
| setState: (newState: MetricState) => void; | ||
| } | ||
|
|
||
| const titleAlignPositions = [ | ||
| { id: 'top', label: 'Top', direction: 'column' }, | ||
| { id: 'bottom', label: 'Bottom', direction: 'column' }, | ||
| { id: 'middle', label: 'Middle', direction: 'column' }, | ||
| { id: 'left', label: 'Left', direction: 'row' }, | ||
| { id: 'right', label: 'Right', direction: 'row' }, | ||
| { id: 'center', label: 'Center', direction: 'row' }, | ||
| ]; | ||
|
|
||
| export const TitleAlignOptions: React.FC<TitlePositionProps> = ({ state, setState }) => { | ||
| const direction = ['top', 'bottom'].includes(state.titlePosition ?? 'top') ? 'column' : 'row'; | ||
|
|
||
| return ( | ||
| <EuiFormRow | ||
| display="columnCompressed" | ||
| label={ | ||
| <> | ||
| {i18n.translate('xpack.lens.metricChart.titleAlignLabel', { | ||
| defaultMessage: 'Title align', | ||
|
MichaelMarcialis marked this conversation as resolved.
Outdated
|
||
| })} | ||
| </> | ||
| } | ||
| > | ||
| <EuiSuperSelect | ||
| data-test-subj="lnsMissingValuesSelect" | ||
| compressed | ||
| options={titleAlignPositions | ||
| .filter((pos) => pos.direction !== direction) | ||
| .map((position) => { | ||
| return { | ||
| value: position.id, | ||
| dropdownDisplay: position.label, | ||
| inputDisplay: position.label, | ||
| }; | ||
| })} | ||
| valueOfSelected={state.titleAlignPosition ?? 'center'} | ||
| onChange={(value) => { | ||
| setState({ ...state, titleAlignPosition: value }); | ||
| }} | ||
| itemLayoutAlign="top" | ||
| hasDividers | ||
| /> | ||
|
MichaelMarcialis marked this conversation as resolved.
Outdated
|
||
| </EuiFormRow> | ||
| ); | ||
| }; | ||




Uh oh!
There was an error while loading. Please reload this page.