-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Add metric Viz config options, title position and sizing #124124
Conversation
related to #120386 |
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.', | ||
}), | ||
}, | ||
titleAlignPosition: { | ||
types: ['string'], | ||
help: i18n.translate('xpack.lens.metric.titleAlignPosition.help', { | ||
defaultMessage: 'The chart title align position.', | ||
}), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have doubts on the namings here. title
is usually referred to the title of the chart (the one that appears on the dashboard on the top/left corner of the embeddable).
In this case, this is a label on the visualization. In the Lens editor is called Display name
so I think we should align the two namings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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:
- Display name: Used as text for layer dimension items. Also used as to supply default text for XY visualization axis names and single metric visualization titles.
- Title: Used as the primary text in for single metric visualizations.
- Subtitle: Used as the secondary text in for single metric visualizations.
- Axis name: Used for text adjacent to axes in in XY visualizations.
- Label: Used for text on individual pie/donut slices and text anchored to ticks in XY visualizations.
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:
- Dashboard's term is prefixed with the word "panel".
- I don't believe there is a current situation where these two terms would exist simultaneously (i.e. editing a panel title and editing a visualization title). However, this may change in the future depending on the direction that the seamless UX endeavor goes.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 title
and subtitle
in the single metric visualizations.
I see a Display name
field that I can change to change the metric name, but I don't see any title or subtitle in any of our options. The only place I see the title
word is in the CSS class name.
In the other metric vis (aggregated) I can see a Custom label
that can be used to change the metric name.
This is actually badly aligned with the option to show and hide that name called Show title
The title is used on the Axis
instead, where you can configure the Axis title
in the top menu that changes the Display name
of the vertical or horizontal axis.
When I think of a title
, to me always refers to something more descriptive like: Memory consumption in the last week
and is more suitable to be places on the top-left part of the visualization (aka panel title). A label
instead, is used in various places and contains usually less information, just a tag: RAM
, CPU %
, really similar to what name
is about.
As always is a matter of consistency across the interface and I don't see that neither with the term title
or the label
.
cc @gvnmagni
x-pack/plugins/lens/public/metric_visualization/metric_config_panel/title_aize_option.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/metric_visualization/expression.scss
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/common/expressions/metric_chart/metric_chart.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this together, @shahzad31! Left you a few comments and questions for your review.
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.', | ||
}), | ||
}, | ||
titleAlignPosition: { | ||
types: ['string'], | ||
help: i18n.translate('xpack.lens.metric.titleAlignPosition.help', { | ||
defaultMessage: 'The chart title align position.', | ||
}), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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:
- Display name: Used as text for layer dimension items. Also used as to supply default text for XY visualization axis names and single metric visualization titles.
- Title: Used as the primary text in for single metric visualizations.
- Subtitle: Used as the secondary text in for single metric visualizations.
- Axis name: Used for text adjacent to axes in in XY visualizations.
- Label: Used for text on individual pie/donut slices and text anchored to ticks in XY visualizations.
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:
- Dashboard's term is prefixed with the word "panel".
- I don't believe there is a current situation where these two terms would exist simultaneously (i.e. editing a panel title and editing a visualization title). However, this may change in the future depending on the direction that the seamless UX endeavor goes.
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.
x-pack/plugins/lens/public/metric_visualization/metric_config_panel/visual_options_popover.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/metric_visualization/metric_config_panel/visual_options_popover.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/common/expressions/metric_chart/metric_chart.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/common/expressions/metric_chart/metric_chart.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/metric_visualization/metric_config_panel/title_align_option.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/metric_visualization/metric_config_panel/title_align_option.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/metric_visualization/metric_config_panel/title_position_option.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/metric_visualization/metric_config_panel/visual_options_popover.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/metric_visualization/metric_config_panel/visual_options_popover.tsx
Outdated
Show resolved
Hide resolved
Thanks @markov00 and @MichaelMarcialis i have address most of your feedback
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for addressing those comments, @shahzad31! After re-reviewing, I have a few additional comments.
Also, if it's cool with you, I took a quick design pass at the appearance toolbar menu (see image below). Changes include:
- Tightened up a bit of the vertical space by consolidating the size and alignment options to a single form row.
- Changed the title position select component to a button group.
- Provided new prepend/append buttons to increase/decrease the text size as a faster alternative (in addition to being able to open the text size select dropdown as they can currently).
Any interest in making these changes as part of this PR? FYI, for the sake of space, I did end up changing the text size names back to abbreviations. Apologies for the back-and-forth on that!
x-pack/plugins/lens/common/expressions/metric_chart/metric_chart.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/common/expressions/metric_chart/metric_chart.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/common/expressions/metric_chart/metric_chart.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/metric_visualization/expression.scss
Outdated
Show resolved
Hide resolved
@MichaelMarcialis Sure, i like the update, will push the changes. |
@MichaelMarcialis i have updated , there is one small issue when XXL is selected, First row bit overflows, i am not sure, if we need to increase popover width. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @shahzad31. Thanks so much for making those suggested changes. Apologies for my delayed response; I'm just returning from PTO.
This looks great. Upon re-review, the majority of issues I discovered were those related to the form fields overflowing outside of the popover, which you mentioned earlier. Below is a list of suggested changes that should resolve that issue. In addition to these changes, you'll need to also change the width of the popovers via the toolbar_popover.scss
styles (as it's currently too narrow to house these updated form elements). I used 440px
in my quick mockups, so feel free to use that assuming it doesn't break anything.
Otherwise, I'm good to approve this, assuming those changes get made. Thanks so much again!
<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 | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add prop buttonSize="compressed"
to match the rest of the UI.
<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 | |
/> | |
<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 | |
buttonSize="compressed" | |
/> |
<EuiButtonGroup | ||
isFullWidth={true} | ||
data-test-subj="lnsMissingValuesSelect" | ||
legend="This is a basic group" | ||
options={titlePositions} | ||
idSelected={state.titlePosition ?? 'top'} | ||
onChange={(value) => { | ||
setState({ ...state, titlePosition: value as MetricState['titlePosition'] }); | ||
}} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add prop buttonSize="compressed"
to match the rest of the UI.
<EuiButtonGroup | |
isFullWidth={true} | |
data-test-subj="lnsMissingValuesSelect" | |
legend="This is a basic group" | |
options={titlePositions} | |
idSelected={state.titlePosition ?? 'top'} | |
onChange={(value) => { | |
setState({ ...state, titlePosition: value as MetricState['titlePosition'] }); | |
}} | |
/> | |
<EuiButtonGroup | |
isFullWidth | |
data-test-subj="lnsMissingValuesSelect" | |
legend="This is a basic group" | |
options={titlePositions} | |
idSelected={state.titlePosition ?? 'top'} | |
onChange={(value) => { | |
setState({ ...state, titlePosition: value as MetricState['titlePosition'] }); | |
}} | |
buttonSize="compressed" | |
/> |
</> | ||
} | ||
> | ||
<EuiFlexGroup gutterSize="s"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply prop responsive={false}
to prevent breaking at small viewport sizes.
<EuiFlexGroup gutterSize="s"> | |
<EuiFlexGroup gutterSize="s" responsive={false}> |
<EuiFlexItem> | ||
<SizeOptions state={state} setState={setState} /> | ||
</EuiFlexItem> | ||
<EuiFlexItem> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent flex item growing with grow={false}
prop.
<EuiFlexItem> | |
<EuiFlexItem grow={false}> |
<EuiFormRow | ||
display="columnCompressed" | ||
label={ | ||
<> | ||
{i18n.translate('xpack.lens.metricChart.titlePositionLabel', { | ||
defaultMessage: 'Title position', | ||
})} | ||
</> | ||
} | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add fullWidth
prop to match previous form row.
<EuiFormRow | |
display="columnCompressed" | |
label={ | |
<> | |
{i18n.translate('xpack.lens.metricChart.titlePositionLabel', { | |
defaultMessage: 'Title position', | |
})} | |
</> | |
} | |
> | |
<EuiFormRow | |
display="columnCompressed" | |
fullWidth | |
label={ | |
<> | |
{i18n.translate('xpack.lens.metricChart.titlePositionLabel', { | |
defaultMessage: 'Title position', | |
})} | |
</> | |
} | |
> |
<EuiSuperSelect | ||
append={ | ||
<EuiButtonIcon | ||
iconType="plus" | ||
onClick={() => changeSize(1)} | ||
isDisabled={currSizeIndex === titleSizes.length - 1} | ||
/> | ||
} | ||
prepend={ | ||
<EuiButtonIcon | ||
iconType="minus" | ||
onClick={() => changeSize(-1)} | ||
isDisabled={currSizeIndex === 0} | ||
/> | ||
} | ||
data-test-subj="lnsMetricSizeSelect" | ||
compressed | ||
options={titleSizes.map((position) => { | ||
return { | ||
value: position.id, | ||
dropdownDisplay: position.label, | ||
inputDisplay: position.label, | ||
}; | ||
})} | ||
valueOfSelected={state.size ?? 'xl'} | ||
onChange={(value) => { | ||
setState({ ...state, size: value }); | ||
}} | ||
itemLayoutAlign="top" | ||
hasDividers | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add fullWidth
prop to ensure the component fills the available space.
<EuiSuperSelect | |
append={ | |
<EuiButtonIcon | |
iconType="plus" | |
onClick={() => changeSize(1)} | |
isDisabled={currSizeIndex === titleSizes.length - 1} | |
/> | |
} | |
prepend={ | |
<EuiButtonIcon | |
iconType="minus" | |
onClick={() => changeSize(-1)} | |
isDisabled={currSizeIndex === 0} | |
/> | |
} | |
data-test-subj="lnsMetricSizeSelect" | |
compressed | |
options={titleSizes.map((position) => { | |
return { | |
value: position.id, | |
dropdownDisplay: position.label, | |
inputDisplay: position.label, | |
}; | |
})} | |
valueOfSelected={state.size ?? 'xl'} | |
onChange={(value) => { | |
setState({ ...state, size: value }); | |
}} | |
itemLayoutAlign="top" | |
hasDividers | |
/> | |
<EuiSuperSelect | |
append={ | |
<EuiButtonIcon | |
iconType="plus" | |
onClick={() => changeSize(1)} | |
isDisabled={currSizeIndex === titleSizes.length - 1} | |
/> | |
} | |
prepend={ | |
<EuiButtonIcon | |
iconType="minus" | |
onClick={() => changeSize(-1)} | |
isDisabled={currSizeIndex === 0} | |
/> | |
} | |
data-test-subj="lnsMetricSizeSelect" | |
compressed | |
options={titleSizes.map((position) => { | |
return { | |
value: position.id, | |
dropdownDisplay: position.label, | |
inputDisplay: position.label, | |
}; | |
})} | |
valueOfSelected={state.size ?? 'xl'} | |
onChange={(value) => { | |
setState({ ...state, size: value }); | |
}} | |
itemLayoutAlign="top" | |
hasDividers | |
fullWidth | |
/> |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for working on this @shahzad31 ! This will do wonders for Lens based dashboards.
I left two smallish issues, but otherwise it looks great to me
alignLeft: textAlign === 'left', | ||
alignRight: textAlign === 'right', | ||
alignCenter: textAlign === 'center', | ||
[`titleSize${(size ?? 'xl').toUpperCase()}`]: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why the default size isn't handled on the toExpression
level like position and alignment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed default here because we use default font size in class lnsMetricExpression__value
and don't needed to add this class if size is not defained.
@@ -59,6 +60,9 @@ const toExpression = ( | |||
function: 'lens_metric_chart', | |||
arguments: { | |||
title: [attributes?.title || ''], | |||
size: [state?.size || ''], | |||
titlePosition: [state?.titlePosition || 'top'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not opposed to default to "top" for new visualizations, but the old default was "bottom". So if we want to keep the default value here we have to add a migration to add in the bottom
for the existing ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we decide to use top
as default? It can confuse users because previously we show label in the bottom in any case, is not?
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great job!
💚 Build SucceededMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
Thanks for this @shahzad31 ! This will really help us in improving the visual appearance of dashboards. |
Summary
Adds options to set title position and sizing in the metric viz
i am hoping this makes sense, we need to use this User experience app.
Potential use cases