Skip to content

Commit

Permalink
[ML] Update stylings
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Dec 14, 2020
1 parent 37ac282 commit 0c34e8a
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@import 'file_based/index';
@import 'index_based/index';
@import "stats_datagrid/components/expanded_row";
@import "stats_datagrid/index";
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const DateContent: FC<FieldDataCardProps> = ({ config }) => {
{
name: '',
render: (summaryItem: { display: ReactNode }) => summaryItem.display,
width: '75px',
},
{
field: 'value',
Expand All @@ -65,6 +66,7 @@ export const DateContent: FC<FieldDataCardProps> = ({ config }) => {
<EuiFlexItem>
<ExpandedRowFieldHeader>{summaryTableTitle}</ExpandedRowFieldHeader>
<EuiBasicTable<SummaryTableItem>
className={'mlDataVisualizerSummaryTable'}
data-test-subj={'mlDateSummaryTable'}
compressed
items={summaryTableItems}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const MetricDistributionChart: FC<Props> = ({
left: 0,
right: 0,
top: 0,
bottom: 1,
bottom: 0,
},
chartPaddings: {
left: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface Props {
stats: any;
fieldFormat?: any;
barColor?: 'primary' | 'secondary' | 'danger' | 'subdued' | 'accent';
compressed?: boolean;
}

function getPercentLabel(docCount: number, topValuesSampleSize: number): string {
Expand All @@ -34,7 +35,7 @@ function getPercentLabel(docCount: number, topValuesSampleSize: number): string
}
}

export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor }) => {
export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor, compressed }) => {
const {
topValues,
topValuesSampleSize,
Expand All @@ -48,9 +49,13 @@ export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor }) => {
{Array.isArray(topValues) &&
topValues.map((value: any) => (
<EuiFlexGroup gutterSize="xs" alignItems="center" key={value.key}>
<EuiFlexItem grow={false} style={{ width: 100 }} className="eui-textTruncate">
<EuiFlexItem
grow={false}
style={{ width: compressed === true ? 100 : 300 }}
className="eui-textTruncate"
>
<EuiToolTip content={kibanaFieldFormat(value.key, fieldFormat)} position="right">
<EuiText size="xs" textAlign="right" color="subdued">
<EuiText size="xs" textAlign="left" color="subdued">
{kibanaFieldFormat(value.key, fieldFormat)}
</EuiText>
</EuiToolTip>
Expand All @@ -68,7 +73,7 @@ export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor }) => {
{isTopValuesSampled === true && (
<Fragment>
<EuiSpacer size="xs" />
<EuiText size="xs" textAlign={'center'}>
<EuiText size="xs" textAlign={'left'}>
<FormattedMessage
id="xpack.ml.fieldDataCard.topValues.calculatedFromSampleDescription"
defaultMessage="Calculated from sample of {topValuesSamplerShardSize} documents per shard"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.mlDataVisualizerFieldExpandedRow {
padding-left: $euiSize * 4;
width: 100%;

.mlFieldDataCard__valuesTitle {
text-transform: uppercase;
text-align: left;
color: $euiColorDarkShade;
font-weight: bold;
}
.mlFieldDataCard__codeContent {
@include euiCodeFont;
font-family: $euiCodeFontFamily;
}
}

.mlDataVisualizer {
.euiTableRow > .euiTableRowCell {
border-bottom: 0px;
border-top: 1px solid $euiColorLightShade;

}
.euiTableRow-isExpandedRow {

.euiTableRowCell{
background-color: transparent !important;
border-top: 0px;
border-bottom: 1px solid $euiColorLightShade;

}
}
.mlDataVisualizerSummaryTable {
.euiTableRow > .euiTableRowCell{
border-bottom: 0px;
}
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.mlDataVisualizerFieldExpandedRow {
padding-left: $euiSizeL * 2;
padding-left: $euiSize * 4;
width: 100%;

.mlFieldDataCard__valuesTitle {
text-transform: uppercase;
text-align: center;
text-align: left;
color: $euiColorDarkShade;
font-weight: bold;
}
Expand All @@ -13,3 +13,26 @@
font-family: $euiCodeFontFamily;
}
}

.mlDataVisualizer {
.euiTableRow > .euiTableRowCell {
border-bottom: 0px;
border-top: 1px solid $euiColorLightShade;

}
.euiTableRow-isExpandedRow {

.euiTableRowCell{
background-color: transparent !important;
border-top: 0px;
border-bottom: 1px solid $euiColorLightShade;

}
}
.mlDataVisualizerSummaryTable {
.euiTableRow > .euiTableRowCell{
border-bottom: 0px;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { FC, Fragment, ReactNode, useEffect, useState } from 'react';
import React, { FC, ReactNode, useEffect, useState } from 'react';
import { EuiBasicTable, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n/react';
Expand All @@ -22,14 +22,16 @@ import { TopValues } from '../../../index_based/components/field_data_card/top_v
import { ExpandedRowFieldHeader } from '../expanded_row_field_header';

const METRIC_DISTRIBUTION_CHART_WIDTH = 325;
const METRIC_DISTRIBUTION_CHART_HEIGHT = 210;
const METRIC_DISTRIBUTION_CHART_HEIGHT = 200;

interface SummaryTableItem {
function: string;
display: ReactNode;
value: number | string | undefined | null;
}

export const VerticalSpacer = () => <div style={{ width: 16 }} />;

export const NumberContent: FC<FieldDataCardProps> = ({ config }) => {
const { stats, fieldFormat } = config;

Expand Down Expand Up @@ -80,6 +82,7 @@ export const NumberContent: FC<FieldDataCardProps> = ({ config }) => {
{
name: '',
render: (summaryItem: { display: ReactNode }) => summaryItem.display,
width: '75px',
},
{
field: 'value',
Expand All @@ -99,16 +102,17 @@ export const NumberContent: FC<FieldDataCardProps> = ({ config }) => {
<EuiFlexItem>
<ExpandedRowFieldHeader>{summaryTableTitle}</ExpandedRowFieldHeader>
<EuiBasicTable<SummaryTableItem>
className={'mlDataVisualizerSummaryTable'}
compressed
items={summaryTableItems}
columns={summaryTableColumns}
tableCaption={summaryTableTitle}
tableLayout="auto"
/>
</EuiFlexItem>
<VerticalSpacer />
{stats && (
<EuiFlexItem>
<EuiFlexGroup direction={'column'} alignItems={'center'} data-test-subj={'mlTopValues'}>
<EuiFlexGroup direction={'column'} data-test-subj={'mlTopValues'}>
<EuiFlexItem grow={false}>
<ExpandedRowFieldHeader>
<FormattedMessage
Expand All @@ -118,18 +122,21 @@ export const NumberContent: FC<FieldDataCardProps> = ({ config }) => {
</ExpandedRowFieldHeader>
</EuiFlexItem>
<EuiFlexItem>
<TopValues stats={stats} fieldFormat={fieldFormat} barColor="primary" />
<TopValues
stats={stats}
fieldFormat={fieldFormat}
barColor="primary"
compressed={true}
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
)}
<VerticalSpacer />

{distribution && (
<EuiFlexItem>
<EuiFlexGroup
direction={'column'}
alignItems={'center'}
data-test-subj={'mlMetricDistribution'}
>
<EuiFlexGroup direction={'column'} data-test-subj={'mlMetricDistribution'}>
<EuiFlexItem>
<ExpandedRowFieldHeader>
<FormattedMessage
Expand All @@ -139,30 +146,26 @@ export const NumberContent: FC<FieldDataCardProps> = ({ config }) => {
</ExpandedRowFieldHeader>
</EuiFlexItem>

<Fragment>
<EuiFlexGroup justifyContent="spaceAround" gutterSize="xs">
<EuiFlexItem grow={false}>
<EuiText size="xs">
<FormattedMessage
id="xpack.ml.fieldDataCardExpandedRow.numberContent.displayingPercentilesLabel"
defaultMessage="Displaying {minPercent} - {maxPercent} percentiles"
values={{
minPercent: numberAsOrdinal(distribution.minPercentile),
maxPercent: numberAsOrdinal(distribution.maxPercentile),
}}
/>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexItem style={{ width: '100%' }}>
<MetricDistributionChart
width={METRIC_DISTRIBUTION_CHART_WIDTH}
height={METRIC_DISTRIBUTION_CHART_HEIGHT}
chartData={distributionChartData}
fieldFormat={fieldFormat}
<EuiFlexItem style={{ width: '100%' }}>
<MetricDistributionChart
width={METRIC_DISTRIBUTION_CHART_WIDTH}
height={METRIC_DISTRIBUTION_CHART_HEIGHT}
chartData={distributionChartData}
fieldFormat={fieldFormat}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="xs">
<FormattedMessage
id="xpack.ml.fieldDataCardExpandedRow.numberContent.displayingPercentilesLabel"
defaultMessage="Displaying {minPercent} - {maxPercent} percentiles"
values={{
minPercent: numberAsOrdinal(distribution.minPercentile),
maxPercent: numberAsOrdinal(distribution.maxPercentile),
}}
/>
</EuiFlexItem>
</Fragment>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
)}
Expand Down

0 comments on commit 0c34e8a

Please sign in to comment.