Skip to content

Commit 8570a4b

Browse files
committed
[ML] Improve legend text when chart not available or no data available.
1 parent 6c6d9f7 commit 8570a4b

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

x-pack/plugins/ml/public/application/components/data_grid/column_chart.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const ColumnChart: FC<Props> = ({ chartData, columnType }) => {
3434
<Chart>
3535
<Settings
3636
theme={{
37+
background: { color: 'transparent' },
3738
chartMargins: {
3839
left: 4,
3940
right: 4,
@@ -64,7 +65,7 @@ export const ColumnChart: FC<Props> = ({ chartData, columnType }) => {
6465
)}
6566
<div
6667
className={classNames('mlDataGridChart__legend', {
67-
'mlDataGridChart__legend--numeric': isNumericChartData(chartData),
68+
'mlDataGridChart__legend--numeric': columnType.schema === 'number',
6869
})}
6970
>
7071
{legendText}

x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export const DataGrid: FC<Props> = memo(
180180
<EuiDataGrid
181181
aria-label={isWithHeader(props) ? props.title : ''}
182182
columns={columnsWithCharts.map((c) => {
183-
c.initialWidth = 150;
183+
c.initialWidth = 165;
184184
return c;
185185
})}
186186
columnVisibility={{ visibleColumns, setVisibleColumns }}

x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,16 @@ type LegendText = string | JSX.Element;
321321
const getLegendText = (chartData: ChartData): LegendText => {
322322
if (chartData.type === 'unsupported') {
323323
return i18n.translate('xpack.ml.dataGridChart.histogramNotAvailable', {
324-
defaultMessage: `Histogram chart not supported for this type of column.`,
324+
defaultMessage: 'Chart not supported.',
325325
});
326326
}
327+
328+
if (chartData.data.length === 0) {
329+
return i18n.translate('xpack.ml.dataGridChart.notEnoughData', {
330+
defaultMessage: `0 documents contain field.`,
331+
});
332+
}
333+
327334
if (chartData.type === 'boolean') {
328335
return (
329336
<table className="mlDataGridChart__legendBoolean">

0 commit comments

Comments
 (0)