[Lens] Fixes bug with empty data and a reference line (#131922)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Stratoula Kalafateli 2022-05-11 14:16:34 +03:00 committed by GitHub
parent e3e9e009fd
commit 63f2d66471
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View file

@ -757,6 +757,29 @@ describe('XYChart component', () => {
expect(component.find(EmptyPlaceholder).prop('icon')).toBeDefined();
});
test('it renders empty placeholder for no results with references layer', () => {
const { data, args } = sampleArgsWithReferenceLine();
const emptyDataLayers = args.layers.map((layer) => {
if (layer.type === 'dataLayer') {
return { ...layer, table: { ...data, rows: [] } };
} else {
return layer;
}
});
const component = shallow(
<XYChart
{...defaultProps}
args={{
...args,
layers: emptyDataLayers,
}}
/>
);
expect(component.find(BarSeries)).toHaveLength(0);
expect(component.find(EmptyPlaceholder).prop('icon')).toBeDefined();
});
test('onBrushEnd returns correct context data for date histogram data', () => {
const { args } = sampleArgs();

View file

@ -172,7 +172,7 @@ export function XYChart({
[dataLayers, formatFactory]
);
if (filteredLayers.length === 0) {
if (dataLayers.length === 0) {
const icon: IconType = getIconForSeriesType(
getDataLayers(layers)?.[0]?.seriesType || SeriesTypes.BAR
);
@ -253,7 +253,7 @@ export function XYChart({
const annotationsLayers = getAnnotationsLayers(layers);
const firstTable = dataLayers[0]?.table;
const xColumnId = firstTable.columns.find((col) => col.id === dataLayers[0]?.xAccessor)?.id;
const xColumnId = firstTable?.columns.find((col) => col.id === dataLayers[0]?.xAccessor)?.id;
const groupedLineAnnotations = getAnnotationsGroupedByInterval(
annotationsLayers,