Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -6,6 +6,7 @@

import { Chrome } from 'ui/chrome';
import { ToastNotifications } from 'ui/notify/toasts/toast_notifications';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { SavedObjectAttributes } from 'src/core/server/saved_objects';
import { IndexPatternField } from './indexpattern';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { VisualizationProps } from '../types';
import { NativeRenderer } from '../native_renderer';
import { MultiColumnEditor } from './multi_column_editor';

const chartTypeIcons: Array<{ id: SeriesType; label: string; iconType: IconType }> = [
export const chartTypeIcons: Array<{ id: SeriesType; label: string; iconType: IconType }> = [
{
id: 'line',
label: i18n.translate('xpack.lens.xyVisualization.lineChartLabel', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ import {
BarSeries,
} from '@elastic/charts';
import { ExpressionFunction } from 'src/legacy/core_plugins/interpreter/types';
import { XYArgs } from './types';
import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiText, IconType } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { XYArgs, SeriesType } from './types';
import { KibanaDatatable } from '../types';
import { RenderFunction } from '../interpreter_types';
import { chartTypeIcons } from './xy_config_panel';

export interface XYChartProps {
data: KibanaDatatable;
Expand Down Expand Up @@ -101,7 +104,29 @@ export const xyChartRenderer: RenderFunction<XYChartProps> = {
},
};

function getIconForSeriesType(seriesType: SeriesType): IconType {
return chartTypeIcons.find(chartTypeIcon => chartTypeIcon.id === seriesType)!.iconType;
}

export function XYChart({ data, args }: XYChartProps) {
if (data.rows.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is about to change with layers, especially if we change the type of the Visualization expression args. But this makes sense.

return (
<EuiFlexGroup gutterSize="s" direction="column" alignItems="center" justifyContent="center">
<EuiFlexItem>
<EuiIcon type={getIconForSeriesType(args.seriesType)} color="subdued" size="l" />
</EuiFlexItem>
<EuiFlexItem>
<EuiText color="subdued" size="xs">
<FormattedMessage
id="xpack.lens.xyVisualization.noDataLabel"
defaultMessage="No results found"
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that there's some custom stuff here for the XY vis, but what if this was done by the frame on behalf of all visualizations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should leave this to the visualization to be more flexible in how to show "no data". E.g. a gauge or a metric could just displayed as a dash - a map on the other hand probably just wants to show a map without data.

Screenshot 2019-07-22 at 09 20 47

This is a current dashboard without any data.

/>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
);
}

const { legend, x, y, splitSeriesAccessors, seriesType } = args;
// TODO: Stop mapping data once elastic-charts allows axis naming
// https://github.com/elastic/elastic-charts/issues/245
Expand Down