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

[ML] Add responsive layout to Index data visualizer, fix doc count chart margin #147137

Merged
merged 22 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1378f53
Add responsive layout to index data visualizer
qn895 Dec 6, 2022
a964f53
Update header, remove scss file
qn895 Dec 6, 2022
0b7ad91
Fix histogram doc count chart margin
qn895 Dec 6, 2022
90f1b1f
Fix wide time range display with sparse data (in line with #147129)
qn895 Dec 6, 2022
921ce90
Fix text
qn895 Dec 6, 2022
de185ce
More dimensions improvement
qn895 Dec 6, 2022
1832fbb
Merge remote-tracking branch 'upstream/main' into ml-index-dv-responsive
qn895 Dec 6, 2022
1fc4100
Merge branch 'main' into ml-index-dv-responsive
kibanamachine Dec 7, 2022
7727ccf
Adjust spacing
qn895 Dec 7, 2022
f4a2d74
Fix duplicate expander icon, date wrapper max width
qn895 Dec 7, 2022
6766635
Add spacer between search panel
qn895 Dec 7, 2022
29a49d7
Fix actions panel spacing
qn895 Dec 11, 2022
ab349bf
Merge remote-tracking branch 'upstream/main' into ml-index-dv-responsive
qn895 Dec 11, 2022
2c9d5ac
Merge remote-tracking branch 'upstream/main' into ml-index-dv-responsive
qn895 Dec 16, 2022
12f18c8
Fix issue with timefilter not updating correctly due to resize observer
qn895 Dec 16, 2022
57fcb2e
Merge remote-tracking branch 'upstream/main' into ml-index-dv-responsive
qn895 Dec 16, 2022
1a64c1b
Merge branch 'main' into ml-index-dv-responsive
kibanamachine Dec 19, 2022
6a07e9c
Fix search panel
qn895 Dec 20, 2022
2d35742
Change css to objects for Eui components, euiTheme
qn895 Dec 21, 2022
a32508a
Merge remote-tracking branch 'upstream/main' into ml-index-dv-responsive
qn895 Dec 21, 2022
38b8a06
Fix group direction
qn895 Dec 21, 2022
dac85b0
Merge branch 'main' into ml-index-dv-responsive
kibanamachine Dec 22, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { TimeHistoryContract, UI_SETTINGS } from '@kbn/data-plugin/public';
import { i18n } from '@kbn/i18n';
import { wrapWithTheme } from '@kbn/kibana-react-plugin/public';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';
import {
useRefreshIntervalUpdates,
useTimeRangeUpdates,
Expand Down Expand Up @@ -69,10 +70,11 @@ function updateLastRefresh(timeRange?: OnRefreshProps) {
}

// FIXME: Consolidate this component with ML and AIOps's component
export const DatePickerWrapper: FC<{ isAutoRefreshOnly?: boolean; showRefresh?: boolean }> = ({
isAutoRefreshOnly,
showRefresh,
}) => {
export const DatePickerWrapper: FC<{
isAutoRefreshOnly?: boolean;
showRefresh?: boolean;
compact?: boolean;
}> = ({ isAutoRefreshOnly, showRefresh, compact = false }) => {
const {
services,
notifications: { toasts },
Expand Down Expand Up @@ -242,9 +244,17 @@ export const DatePickerWrapper: FC<{ isAutoRefreshOnly?: boolean; showRefresh?:
<EuiFlexGroup
gutterSize="s"
alignItems="center"
className="mlNavigationMenu__datePickerWrapper"
data-test-subj="mlNavigationMenuDatePickerWrapper"
>
<EuiFlexItem grow={false}>
<EuiFlexItem
grow={false}
css={
compact &&
css`
max-width: 540px;
`
}
>
<EuiSuperDatePicker
start={time.from}
end={time.to}
Expand All @@ -257,6 +267,7 @@ export const DatePickerWrapper: FC<{ isAutoRefreshOnly?: boolean; showRefresh?:
recentlyUsedRanges={recentlyUsedRanges}
dateFormat={dateFormat}
commonlyUsedRanges={commonlyUsedRanges}
updateButtonProps={{ iconOnly: compact }}
/>
</EuiFlexItem>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { FC, useCallback, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import {
Axis,
BarSeries,
HistogramBarSeries,
BrushEndListener,
Chart,
ElementClickListener,
Expand Down Expand Up @@ -138,7 +138,7 @@ export const DocumentCountChart: FC<Props> = ({

return (
<div
style={{ width: width ?? '100%', height: 120, display: 'flex', alignItems: 'center' }}
style={{ width: width ?? '100%', display: 'flex', alignItems: 'center' }}
data-test-subj="dataVisualizerDocumentCountChart"
>
{loading ? (
Expand All @@ -147,6 +147,7 @@ export const DocumentCountChart: FC<Props> = ({
<Chart
size={{
width: '100%',
height: 120,
}}
>
<Settings
Expand All @@ -161,11 +162,13 @@ export const DocumentCountChart: FC<Props> = ({
position={Position.Bottom}
showOverlappingTicks={true}
tickFormat={(value) => xAxisFormatter.convert(value)}
// temporary fix to reduce horizontal chart margin until fixed in Elastic Charts itself
labelFormat={useLegacyTimeAxis ? undefined : () => ''}
Comment on lines +166 to +167
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please create an issue in the elastic-charts repo and mention the link in the comment?

timeAxisLayerCount={useLegacyTimeAxis ? 0 : 2}
style={useLegacyTimeAxis ? {} : MULTILAYER_TIME_AXIS_STYLE}
/>
<Axis id="left" position={Position.Left} />
<BarSeries
<HistogramBarSeries
id={SPEC_ID}
name={seriesName}
xScaleType={ScaleType.Time}
Expand All @@ -174,6 +177,7 @@ export const DocumentCountChart: FC<Props> = ({
yAccessors={['value']}
data={adjustedChartPoints}
timeZone={timeZone}
yNice
/>
</Chart>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const FieldCountPanel: FC<Props> = ({
data-test-subj="dataVisualizerFieldCountPanel"
responsive={false}
className="dvFieldCount__panel"
wrap={true}
>
<TotalFieldsCount fieldsCountStats={fieldsCountStats} />
<MetricFieldsCount metricsStats={metricsStats} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const FieldsStatsGrid: FC<Props> = ({ results }) => {
gutterSize="xs"
style={{ marginLeft: 4 }}
data-test-subj="dataVisualizerFieldCountPanel"
responsive={true}
>
<TotalFieldsCount fieldsCountStats={fieldsCountStats} />
<MetricFieldsCount metricsStats={metricsStats} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ export const LinkCard: FC<LinkCardProps> = ({
color="subdued"
{...linkHrefAndOnClickProps}
>
<EuiFlexGroup gutterSize="l" responsive={true}>
<EuiFlexItem grow={false} style={{ paddingTop: '8px' }}>
<EuiFlexGroup gutterSize="s" responsive={true}>
<EuiFlexItem grow={false} style={{ paddingTop: '4px' }}>
{typeof icon === 'string' ? (
<EuiIcon size="xl" type={icon} aria-label={iconAreaLabel} />
<EuiIcon size="m" type={icon} aria-label={iconAreaLabel} />
) : (
icon
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
import React, { FC, ReactNode, useEffect, useMemo, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { euiDarkVars as euiThemeDark, euiLightVars as euiThemeLight } from '@kbn/ui-theme';
import type { SerializedStyles } from '@emotion/react';
import { css } from '@emotion/react';
import { useDataVisualizerKibana } from '../../../kibana_context';

export interface Option {
Expand Down Expand Up @@ -53,14 +55,19 @@ export function useCurrentEuiTheme() {
);
}

interface MultiSelectPickerStyles {
filterGroup?: SerializedStyles;
filterItemContainer?: SerializedStyles;
}
export const MultiSelectPicker: FC<{
options: Option[];
onChange?: (items: string[]) => void;
title?: string;
checkedOptions: string[];
dataTestSubj: string;
postfix?: React.ReactElement;
}> = ({ options, onChange, title, checkedOptions, dataTestSubj, postfix }) => {
cssStyles?: MultiSelectPickerStyles;
}> = ({ options, onChange, title, checkedOptions, dataTestSubj, postfix, cssStyles }) => {
const euiTheme = useCurrentEuiTheme();

const [items, setItems] = useState<Option[]>(options);
Expand Down Expand Up @@ -114,7 +121,7 @@ export const MultiSelectPicker: FC<{
);

return (
<EuiFilterGroup data-test-subj={dataTestSubj} style={{ marginLeft: 8 }}>
<EuiFilterGroup data-test-subj={dataTestSubj} css={cssStyles?.filterGroup}>
<EuiPopover
ownFocus
data-test-subj={`${dataTestSubj}-popover`}
Expand All @@ -130,7 +137,15 @@ export const MultiSelectPicker: FC<{
data-test-subj={`${dataTestSubj}-searchInput`}
/>
</EuiPopoverTitle>
<div style={{ maxHeight: 250, overflow: 'auto' }}>
<div
css={
cssStyles?.filterItemContainer ??
css`
max-height: 250px;
overflow: auto;
`
}
>
{Array.isArray(items) && items.length > 0 ? (
items.map((item, index) => {
const checked =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

.dvFieldCount__item {
max-width: 300px;
min-width: 300px;
min-width: 200px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export const DataVisualizerTable = <T extends DataVisualizerTableItem>({
);
const [showDistributions, setShowDistributions] = useState<boolean>(showPreviewByDefault ?? true);
const [dimensions, setDimensions] = useState(calculateTableColumnsDimensions());
const [tableWidth, setTableWidth] = useState<number>(1400);

const toggleExpandAll = useCallback(
(shouldExpandAll: boolean) => {
Expand All @@ -109,10 +108,9 @@ export const DataVisualizerTable = <T extends DataVisualizerTableItem>({
throttle((e: { width: number; height: number }) => {
// When window or table is resized,
// update the column widths and other settings accordingly
setTableWidth(e.width);
setDimensions(calculateTableColumnsDimensions(e.width));
}, 500),
[tableWidth]
[]
);

const toggleShowDistribution = useCallback(() => {
Expand All @@ -138,6 +136,8 @@ export const DataVisualizerTable = <T extends DataVisualizerTableItem>({
const columns = useMemo(() => {
const expanderColumn: EuiTableComputedColumnType<DataVisualizerTableItem> = {
name:
// EUI will automatically show an expander button when table is mobile view (where width <700)
// so we need to not render any addition button
dimensions.breakPoint !== 'small' ? (
<EuiButtonIcon
data-test-subj={`dataVisualizerToggleDetailsForAllRowsButton ${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const getTFPercentage = (config: FileBasedFieldVisConfig) => {
// Map of DataVisualizerTable breakpoints specific to the table component
// Note that the table width is not always the full width of the browser window
const TABLE_BREAKPOINTS = {
small: 600,
small: 700,
medium: 1000,
large: Infinity, // default
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import { EuiSpacer, EuiTitle } from '@elastic/eui';
import { DataView } from '@kbn/data-views-plugin/public';
import { css } from '@emotion/react';
import { flatten } from 'lodash';
import { LinkCardProps } from '../../../common/components/link_card/link_card';
import { useDataVisualizerKibana } from '../../../kibana_context';
Expand All @@ -24,13 +25,17 @@ interface Props {
searchString?: string | { [key: string]: any };
searchQueryLanguage?: string;
getAdditionalLinks?: GetAdditionalLinks;
compact?: boolean;
}

const ACTIONS_PANEL_WIDTH = '240px';

export const ActionsPanel: FC<Props> = ({
dataView,
searchString,
searchQueryLanguage,
getAdditionalLinks,
compact,
}) => {
const [globalState] = useUrlState('_g');

Expand Down Expand Up @@ -112,23 +117,33 @@ export const ActionsPanel: FC<Props> = ({
data.query,
getAdditionalLinks,
]);
const showActionsPanel =
discoverLink || (Array.isArray(asyncHrefCards) && asyncHrefCards.length > 0);

// Note we use display:none for the DataRecognizer section as it needs to be
// passed the recognizerResults object, and then run the recognizer check which
// controls whether the recognizer section is ultimately displayed.
return (
<div data-test-subj="dataVisualizerActionsPanel">
return showActionsPanel ? (
<div
data-test-subj="dataVisualizerActionsPanel"
css={
!compact &&
css`
width: ${ACTIONS_PANEL_WIDTH};
`
}
>
<EuiTitle size="s">
<h2>
<FormattedMessage
id="xpack.dataVisualizer.index.actionsPanel.exploreTitle"
defaultMessage="Explore your data"
/>
</h2>
</EuiTitle>
<EuiSpacer size="m" />
{discoverLink && (
<>
<EuiTitle size="s">
<h2>
<FormattedMessage
id="xpack.dataVisualizer.index.actionsPanel.exploreTitle"
defaultMessage="Explore your data"
/>
</h2>
</EuiTitle>
<EuiSpacer size="m" />
<LinkCard
href={discoverLink}
icon="discoverApp"
Expand Down Expand Up @@ -164,5 +179,5 @@ export const ActionsPanel: FC<Props> = ({
</>
))}
</div>
);
) : null;
};

This file was deleted.

This file was deleted.

Loading