-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Introduces new chart switcher #91844
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
@@ -7,6 +7,17 @@ | |||
|
|||
import React, { ReactElement } from 'react'; | |||
import { ReactWrapper } from 'enzyme'; | |||
|
|||
// Mock the AutoSizer inside EuiSelectable (Chart Switch) and return some dimensions > 0 |
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.
Nit: Could you leave more detailed info why we have to do this (that the Autosizer behaves in particular way here)?
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.
Agreed with Marta- can you specifically say that Jest tests render using jsdom and jsdom does not implement any sizing methods
@@ -439,6 +439,9 @@ export const visualizationTypes: VisualizationType[] = [ | |||
label: i18n.translate('xpack.lens.xyVisualization.barLabel', { | |||
defaultMessage: 'Bar', | |||
}), | |||
groupLabel: i18n.translate('xpack.lens.xyVisualization.barGroupLabel', { |
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.
nit: we repeat this copy 4 times for Bar and then another one 4 times for line or area. Maybe it's worth to assign it to variable and then read it here?
@@ -16,18 +16,29 @@ export const CHART_NAMES = { | |||
label: i18n.translate('xpack.lens.pie.donutLabel', { | |||
defaultMessage: 'Donut', | |||
}), | |||
groupLabel: i18n.translate('xpack.lens.pie.groupLabel', { |
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.
nit: same comment about repeating the same copy 3 times
} | ||
return [{ key: group, label: group, isGroupLabel: true }].concat( | ||
visualizations.map((v) => ({ | ||
'aria-label': v.label, |
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.
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.
Tested in Chrome and Safari. Code LGTM with small comments. I'll approve once we'll get an OK from design team that the design changes are fine (in case if you'd have to change big chunks of code because of it)
Didn't test yet, but we've talked about an option to scroll to the currently active section on open (if available). Do you think that would be easy to add? |
@flash1293 I forgot about that. Will add it. |
@flash1293 the scroll to item behaviour is not exposed yet in the |
@dej611: This is looking great! While I was playing around with your branch this afternoon, two items caught my eye that I wanted to ask about.
Regarding the swapping of sides for the |
I see, with virtualized scrolling it's hard to add it from the outside. In that case I guess we can live with postponing this. |
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.
Found a crash when I tested it!
@@ -7,6 +7,17 @@ | |||
|
|||
import React, { ReactElement } from 'react'; | |||
import { ReactWrapper } from 'enzyme'; | |||
|
|||
// Mock the AutoSizer inside EuiSelectable (Chart Switch) and return some dimensions > 0 |
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.
Agreed with Marta- can you specifically say that Jest tests render using jsdom and jsdom does not implement any sizing methods
for (const visualizationType of v.visualizationTypes) { | ||
const isSearchMatch = | ||
visualizationType.label.toLowerCase().includes(lowercasedSearchTerm) || | ||
visualizationType.fullLabel?.toLowerCase().includes(lowercasedSearchTerm); |
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.
So we're only looking at the i18n text for the search? I guess this makes sense...
onChange={(newOptions) => { | ||
const id = newOptions.find(({ checked }) => checked === 'on')!.value!; | ||
commitSelection(visualizationsLookup[id].selection); | ||
}} |
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.
We've had this bug before, but this appears to be a pretty big one. Lens crashes if you select the currently selected option.
}, | ||
{ | ||
id: 'line', | ||
icon: LensIconChartLine, | ||
label: i18n.translate('xpack.lens.xyVisualization.lineLabel', { | ||
defaultMessage: 'Line', | ||
}), | ||
groupLabel: groupLabelForLineAndArea, |
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 is Line the last chart in the "Line and area" group?
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 assume this was done to match the designs, as the designs sort both the chart groups and chart items in alpha order.
@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.
Thanks for making those earlier changes, @dej611. I left a few additional wording suggestions below to better match the designs. After those wording changes are made, could you also ensure that the chart groups and the items within each group in alpha order?
Aside from that, this looks good from my perspective. Approving now so I don't hold you up further.
}, | ||
{ | ||
id: 'line', | ||
icon: LensIconChartLine, | ||
label: i18n.translate('xpack.lens.xyVisualization.lineLabel', { | ||
defaultMessage: 'Line', | ||
}), | ||
groupLabel: groupLabelForLineAndArea, |
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 assume this was done to match the designs, as the designs sort both the chart groups and chart items in alpha order.
<EuiIconTip | ||
aria-label={i18n.translate('xpack.lens.chartSwitch.dataLossLabel', { | ||
defaultMessage: 'Data loss', | ||
})} | ||
type="alert" | ||
color="warning" | ||
title={i18n.translate('xpack.lens.chartSwitch.dataLossLabel', { | ||
defaultMessage: 'Data loss', | ||
})} | ||
content={i18n.translate('xpack.lens.chartSwitch.dataLossDescription', { | ||
defaultMessage: | ||
'Switching to this chart will lose some of the configuration', | ||
})} | ||
iconProps={{ | ||
className: 'lnsChartSwitch__chartIcon', | ||
'data-test-subj': `lnsChartSwitchPopoverAlert_${v.id}`, | ||
}} | ||
/> |
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.
Suggesting the following changes to better match the design.
<EuiIconTip | |
aria-label={i18n.translate('xpack.lens.chartSwitch.dataLossLabel', { | |
defaultMessage: 'Data loss', | |
})} | |
type="alert" | |
color="warning" | |
title={i18n.translate('xpack.lens.chartSwitch.dataLossLabel', { | |
defaultMessage: 'Data loss', | |
})} | |
content={i18n.translate('xpack.lens.chartSwitch.dataLossDescription', { | |
defaultMessage: | |
'Switching to this chart will lose some of the configuration', | |
})} | |
iconProps={{ | |
className: 'lnsChartSwitch__chartIcon', | |
'data-test-subj': `lnsChartSwitchPopoverAlert_${v.id}`, | |
}} | |
/> | |
<EuiIconTip | |
aria-label={i18n.translate('xpack.lens.chartSwitch.dataLossLabel', { | |
defaultMessage: 'Warning', | |
})} | |
type="alert" | |
color="warning" | |
content={i18n.translate('xpack.lens.chartSwitch.dataLossDescription', { | |
defaultMessage: | |
'Selecting this chart type will result in a partial loss of currently applied configuration selections.', | |
})} | |
iconProps={{ | |
className: 'lnsChartSwitch__chartIcon', | |
'data-test-subj': `lnsChartSwitchPopoverAlert_${v.id}`, | |
}} | |
/> |
}, | ||
{ | ||
id: 'bar_stacked', | ||
icon: LensIconChartBarStacked, | ||
label: i18n.translate('xpack.lens.xyVisualization.stackedBarLabel', { | ||
defaultMessage: 'Stacked bar', | ||
defaultMessage: 'Bar stacked', |
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.
To be consistent with naming and match the designs.
defaultMessage: 'Bar stacked', | |
defaultMessage: 'Bar vertical stacked', |
}, | ||
{ | ||
id: 'bar_percentage_stacked', | ||
icon: LensIconChartBarPercentage, | ||
label: i18n.translate('xpack.lens.xyVisualization.stackedPercentageBarLabel', { | ||
defaultMessage: 'Percentage bar', | ||
defaultMessage: 'Bar percentage bar', |
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.
To be consistent with naming and match the designs.
defaultMessage: 'Bar percentage bar', | |
defaultMessage: 'Bar vertical percentage', |
@@ -439,6 +446,7 @@ export const visualizationTypes: VisualizationType[] = [ | |||
label: i18n.translate('xpack.lens.xyVisualization.barLabel', { | |||
defaultMessage: 'Bar', |
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.
To be consistent with naming and match the designs.
defaultMessage: 'Bar', | |
defaultMessage: 'Bar vertical', |
}, | ||
{ | ||
id: 'area', | ||
icon: LensIconChartArea, | ||
label: i18n.translate('xpack.lens.xyVisualization.areaLabel', { | ||
defaultMessage: 'Area', | ||
}), | ||
groupLabel: groupLabelForLineAndArea, | ||
}, | ||
{ | ||
id: 'area_stacked', | ||
icon: LensIconChartAreaStacked, | ||
label: i18n.translate('xpack.lens.xyVisualization.stackedAreaLabel', { | ||
defaultMessage: 'Stacked area', |
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.
To be consistent with naming and match the designs.
defaultMessage: 'Stacked area', | |
defaultMessage: 'Area stacked', |
}, | ||
{ | ||
id: 'area_stacked', | ||
icon: LensIconChartAreaStacked, | ||
label: i18n.translate('xpack.lens.xyVisualization.stackedAreaLabel', { | ||
defaultMessage: 'Stacked area', | ||
}), | ||
groupLabel: groupLabelForLineAndArea, | ||
}, | ||
{ | ||
id: 'area_percentage_stacked', | ||
icon: LensIconChartAreaPercentage, | ||
label: i18n.translate('xpack.lens.xyVisualization.stackedPercentageAreaLabel', { | ||
defaultMessage: 'Percentage area', |
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.
To be consistent with naming and match the designs.
defaultMessage: 'Percentage area', | |
defaultMessage: 'Area percentage', |
@@ -47,6 +47,9 @@ export const datatableVisualization: Visualization<DatatableVisualizationState> | |||
label: i18n.translate('xpack.lens.datatable.label', { | |||
defaultMessage: 'Data table', |
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.
To be consistent with naming and match the designs.
defaultMessage: 'Data table', | |
defaultMessage: 'Table', |
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.
Tested in Chrome and this LGTM. I think we should kick off a flaky test runner for this - I see some flakiness potential here :)
@@ -54,6 +51,18 @@ interface Props { | |||
>; | |||
} | |||
|
|||
interface SelectableEntry { |
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.
nit: You can replace this by type SelectableEntry = EuiSelectableOption<{ value: string }>
.
There's one small issue with the type of the array returned in 272 because concat
is not playing nice, but you can cast it using as SelectableEntry[]
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.
Yes, that was the main reason to redeclare it from scratch. I'll see if it's possible to fix it without force casting it. In case it's not possible, I'll force cast 😅
@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.
Looks good to me!
Co-authored-by: Wylie Conlon <wylieconlon@gmail.com>
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
Co-authored-by: Wylie Conlon <wylieconlon@gmail.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* master: (42 commits) [Lens] Introduces new chart switcher (elastic#91844) [Lens] fix selection when dragging (elastic#93034) Converts usage collection README to .mdx (elastic#92982) Fix expanding document when using saved search data grid (elastic#92999) [SECURITY SOLUTIONS] Bug case connector (elastic#93104) [Security Solution] [Timeline] Bugfix to include unmapped fields in the timeline event details JSON (elastic#92025) [Alerting][Docs] Changed alerting documentation to point to a single source of explaining the configurations. (elastic#92942) [APM] Fix hidden search bar in error pages while loading (elastic#84476) (elastic#93139) [DOCS] Fixes links for machine learning alerts (elastic#92744) [Security Solution][Detections] -Fixes rule edit flow bug with max_signals (elastic#92748) [SecuritySolution][Case] Disable cases on detections in read-only mode (elastic#93010) [Security Solution][Case][Bug] Prevent closing collection when pushing (elastic#93095) [Security Solution][Detections][7.12] Critical Threshold Rule Fixes (elastic#92667) Bump ems landing page to 7.12 (elastic#93065) [App Search] Implement various Relevance Tuning states and form actions (elastic#92644) [actions] for simplistic email servers, set rejectUnauthorized to false (elastic#91760) [Security Solution][Case] Migrate category & subcategory fields of ServiceNow ITSM connector (elastic#93092) Hide instances latency distribution chart (elastic#92869) [Maps] fix MapboxDraw import from pointing to dist just pointing to folder (elastic#93087) [Maps] fix results trimmed tooltip message doubles feature count for line and polygon features (elastic#92932) ...
… playwright-ftr-e2e * 'playwright-ftr-e2e' of github.com:shahzad31/kibana: (38 commits) [chore] Enable core's eslint rule: `@ts-expect-error` (elastic#93086) [Lens] Introduces new chart switcher (elastic#91844) [Lens] fix selection when dragging (elastic#93034) Converts usage collection README to .mdx (elastic#92982) Fix expanding document when using saved search data grid (elastic#92999) [SECURITY SOLUTIONS] Bug case connector (elastic#93104) [Security Solution] [Timeline] Bugfix to include unmapped fields in the timeline event details JSON (elastic#92025) [Alerting][Docs] Changed alerting documentation to point to a single source of explaining the configurations. (elastic#92942) [APM] Fix hidden search bar in error pages while loading (elastic#84476) (elastic#93139) [DOCS] Fixes links for machine learning alerts (elastic#92744) [Security Solution][Detections] -Fixes rule edit flow bug with max_signals (elastic#92748) [SecuritySolution][Case] Disable cases on detections in read-only mode (elastic#93010) [Security Solution][Case][Bug] Prevent closing collection when pushing (elastic#93095) [Security Solution][Detections][7.12] Critical Threshold Rule Fixes (elastic#92667) Bump ems landing page to 7.12 (elastic#93065) [App Search] Implement various Relevance Tuning states and form actions (elastic#92644) [actions] for simplistic email servers, set rejectUnauthorized to false (elastic#91760) [Security Solution][Case] Migrate category & subcategory fields of ServiceNow ITSM connector (elastic#93092) Hide instances latency distribution chart (elastic#92869) [Maps] fix MapboxDraw import from pointing to dist just pointing to folder (elastic#93087) ...
Co-authored-by: Wylie Conlon <wylieconlon@gmail.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Wylie Conlon <wylieconlon@gmail.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
Fixes #89708
This PR introduces the new chart switcher in Lens, which is designed to better handle more charts in the future.
One chart type selected:
With multiple XY chart types (no selection but correct label on toolbar):
In case of "data loss" when changing chart type (notice the icon is on the right rather than left as in the original mockup in the issue):
Search working:
Unit and functional tests required a small amount of changes to work, but the none has been disabled and the same behaviour can be reproduced as the previous implementation.
Checklist