Skip to content

Commit

Permalink
Fix: Empty data on exclusive filters on pivot (#5084)
Browse files Browse the repository at this point in the history
  • Loading branch information
djbarnwal authored and ericpgreen2 committed Jun 17, 2024
1 parent 37de9fb commit c745b9e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
7 changes: 5 additions & 2 deletions web-common/src/features/dashboards/pivot/PivotDisplay.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
let showPanels = true;
$: pivotDataStore = usePivotDataStore(stateManagers);
$: isFetching = $pivotDataStore.isFetching;
$: assembled = $pivotDataStore.assembled;
</script>

<div class="layout">
Expand All @@ -22,10 +25,10 @@
{#if showPanels}
<PivotHeader />
{/if}
<PivotToolbar isFetching={$pivotDataStore.isFetching} bind:showPanels />
<PivotToolbar {isFetching} bind:showPanels />
<div class="table-view">
{#if !$pivotDataStore?.data || $pivotDataStore?.data?.length === 0}
<PivotEmpty isFetching={$pivotDataStore?.isFetching} />
<PivotEmpty {assembled} {isFetching} />
{:else}
<PivotTable {pivotDataStore} />
{/if}
Expand Down
6 changes: 6 additions & 0 deletions web-common/src/features/dashboards/pivot/PivotEmpty.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import EmptyTableIcon from "./EmptyTableIcon.svelte";
export let isFetching = false;
export let assembled = false;
const stateManagers = getStateManagers();
const {
Expand Down Expand Up @@ -46,6 +47,11 @@
href="https://docs.rilldata.com/explore/filters/pivot">docs</a
>.
</div>
{:else if assembled}
<EmptyTableIcon />
<div class="text-gray-600 text-base">
No data to show for the selected filters.
</div>
{:else}
<EmptyTableIcon />
<div class="flex flex-col items-center gap-y-2">
Expand Down
17 changes: 17 additions & 0 deletions web-common/src/features/dashboards/pivot/pivot-data-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,23 @@ function createPivotDataStore(ctx: StateManagers): PivotDataStore {
});
}

/**
* If there are no axes values, return an empty table
*/
if (
rowDimensionAxes?.data?.[anchorDimension]?.length === 0 ||
totalsRowResponse?.data?.data?.length === 0
) {
return axesSet({
isFetching: false,
data: [],
columnDef: [],
assembled: true,
totalColumns: 0,
totalsRowData: displayTotalsRow ? [] : undefined,
});
}

const totalsRowData = getTotalsRow(
config,
columnDimensionAxes?.data,
Expand Down

2 comments on commit c745b9e

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉 Published on https://ui.rilldata.com as production
🚀 Deployed on https://66707364ff903d0d3f9ec556--rill-ui.netlify.app

Please sign in to comment.