Skip to content

Commit

Permalink
[Lens] Fixes bug with empty data and a reference line (#131922)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
stratoula and kibanamachine authored May 11, 2022
1 parent e3e9e00 commit 63f2d66
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 63f2d66

Please sign in to comment.