-
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 15 commits
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 |
|---|---|---|
|
|
@@ -7,11 +7,16 @@ | |
|
|
||
| import React from 'react'; | ||
| import { throttle } from 'lodash'; | ||
| import classNames from 'classnames'; | ||
| import { EuiResizeObserver } from '@elastic/eui'; | ||
| import { MetricState } from '../../common/expressions'; | ||
|
|
||
| interface Props extends React.HTMLAttributes<HTMLDivElement> { | ||
| children: React.ReactNode | React.ReactNode[]; | ||
| minScale?: number; | ||
| size?: MetricState['size']; | ||
| titlePosition?: MetricState['titlePosition']; | ||
| textAlign?: MetricState['textAlign']; | ||
| } | ||
|
|
||
| interface State { | ||
|
|
@@ -56,7 +61,7 @@ export class AutoScale extends React.Component<Props, State> { | |
| }; | ||
|
|
||
| render() { | ||
| const { children, minScale, ...rest } = this.props; | ||
| const { children, minScale, size, textAlign, titlePosition, ...rest } = this.props; | ||
| const { scale } = this.state; | ||
| const style = this.props.style || {}; | ||
|
|
||
|
|
@@ -85,6 +90,12 @@ export class AutoScale extends React.Component<Props, State> { | |
| style={{ | ||
| transform: `scale(${scale})`, | ||
| }} | ||
| className={classNames('lnsMetricExpression__containerScale', { | ||
| alignLeft: textAlign === 'left', | ||
| alignRight: textAlign === 'right', | ||
| alignCenter: textAlign === 'center', | ||
| [`titleSize${(size ?? 'xl').toUpperCase()}`]: true, | ||
|
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. Any reason why the default size isn't handled on the
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. removed default here because we use default font size in class |
||
| })} | ||
| > | ||
| {children} | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,56 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||||||
| * 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 { EuiButtonGroup } from '@elastic/eui'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { MetricState } from '../../../common/expressions'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| export interface TitlePositionProps { | ||||||||||||||||||||||||||||||||||||||||||||||||
| state: MetricState; | ||||||||||||||||||||||||||||||||||||||||||||||||
| setState: (newState: MetricState) => void; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| const alignButtonIcons = [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| id: `left`, | ||||||||||||||||||||||||||||||||||||||||||||||||
| label: i18n.translate('xpack.lens.metricChart.alignLabel.left', { | ||||||||||||||||||||||||||||||||||||||||||||||||
| defaultMessage: 'Align left', | ||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||
| iconType: 'editorAlignLeft', | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| id: `center`, | ||||||||||||||||||||||||||||||||||||||||||||||||
| label: i18n.translate('xpack.lens.metricChart.alignLabel.center', { | ||||||||||||||||||||||||||||||||||||||||||||||||
| defaultMessage: 'Align center', | ||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||
| iconType: 'editorAlignCenter', | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| id: `right`, | ||||||||||||||||||||||||||||||||||||||||||||||||
| label: i18n.translate('xpack.lens.metricChart.alignLabel.right', { | ||||||||||||||||||||||||||||||||||||||||||||||||
| defaultMessage: 'Align right', | ||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||
| iconType: 'editorAlignRight', | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| export const AlignOptions: React.FC<TitlePositionProps> = ({ state, setState }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| <EuiButtonGroup | ||||||||||||||||||||||||||||||||||||||||||||||||
| legend={i18n.translate('xpack.lens.metricChart.titleAlignLabel', { | ||||||||||||||||||||||||||||||||||||||||||||||||
| defaultMessage: 'Align', | ||||||||||||||||||||||||||||||||||||||||||||||||
| })} | ||||||||||||||||||||||||||||||||||||||||||||||||
| options={alignButtonIcons} | ||||||||||||||||||||||||||||||||||||||||||||||||
| idSelected={state.textAlign ?? 'center'} | ||||||||||||||||||||||||||||||||||||||||||||||||
| onChange={(id) => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| setState({ ...state, textAlign: id as MetricState['textAlign'] }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||||||||||
| isIconOnly | ||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+55
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. Add prop
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.