Skip to content

Commit 5951f4f

Browse files
feat: add pivot row limit (#8492)
* Initial implementation for pivot row limit * Fix pivit config key to include row limit * review fixes * remove limit on col dimensions * fix pagination * remove limit on derived table cell data * update key copy * remove redundant limit from measure totals query * adjust row limit label padding * collapse all when limit is changed * review * add increase limit option under nested dimensions * use common props for pivot cells * show more copy update * review updates * gray out show more row --------- Co-authored-by: Dhiraj Kumar <[email protected]>
1 parent ac66be6 commit 5951f4f

38 files changed

+1314
-792
lines changed

package-lock.json

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/rill/runtime/v1/resources.pb.go

Lines changed: 694 additions & 682 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/rill/runtime/v1/resources.pb.validate.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/rill/runtime/v1/runtime.swagger.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4720,6 +4720,9 @@ definitions:
47204720
type: boolean
47214721
pivotTableMode:
47224722
type: string
4723+
pivotRowLimit:
4724+
type: integer
4725+
format: int32
47234726
v1ExploreSortType:
47244727
type: string
47254728
enum:

proto/rill/runtime/v1/resources.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ message ExplorePreset {
525525
optional string pivot_sort_by = 26;
526526
optional bool pivot_sort_asc = 27;
527527
optional string pivot_table_mode = 28;
528+
optional int32 pivot_row_limit = 33;
528529
}
529530

530531
enum ExploreComparisonMode {

proto/rill/ui/v1/dashboard.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ message DashboardState {
145145
optional PivotTableMode pivot_table_mode = 31;
146146
// Enable comparison for pivot
147147
optional bool pivot_enable_comparison = 34;
148+
// Row limit for pivot table (number of child rows to show under each dimension)
149+
optional int32 pivot_row_limit = 41;
148150

149151
// List of all dimensions selected for rows
150152
repeated PivotElement pivot_row_all_dimensions = 35;

web-common/src/features/dashboards/pivot/NestedTable.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
type DimensionColumnProps,
1616
type MeasureColumnProps,
1717
} from "./pivot-column-definition";
18+
import { isShowMoreRow } from "./pivot-utils";
1819
import {
1920
calculateMeasureWidth,
2021
calculateRowDimensionWidth,
@@ -328,7 +329,7 @@
328329
<tr style:height="{before}px" />
329330
{#each virtualRows as row (row.index)}
330331
{@const cells = rows[row.index].getVisibleCells()}
331-
<tr>
332+
<tr class:show-more-row={isShowMoreRow(rows[row.index])}>
332333
{#each cells as cell, i (cell.id)}
333334
{@const result =
334335
typeof cell.column.columnDef.cell === "function"
@@ -512,4 +513,15 @@
512513
.active-cell.cell {
513514
@apply bg-primary-50;
514515
}
516+
517+
/* Show more row styling */
518+
.show-more-row,
519+
.show-more-row .cell {
520+
@apply bg-gray-50;
521+
}
522+
523+
.show-more-row:hover,
524+
.show-more-row:hover .cell {
525+
@apply bg-gray-100;
526+
}
515527
</style>

web-common/src/features/dashboards/pivot/PivotDisplay.svelte

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script lang="ts">
22
import { getPivotExportQuery } from "@rilldata/web-common/features/dashboards/pivot/pivot-export.ts";
3-
import ExportMenu from "@rilldata/web-common/features/exports/ExportMenu.svelte";
4-
import { dynamicHeight } from "@rilldata/web-common/layout/layout-settings.ts";
53
import PivotError from "@rilldata/web-common/features/dashboards/pivot/PivotError.svelte";
64
import { getStateManagers } from "@rilldata/web-common/features/dashboards/state-managers/state-managers";
75
import { metricsExplorerStore } from "@rilldata/web-common/features/dashboards/stores/dashboard-stores";
6+
import ExportMenu from "@rilldata/web-common/features/exports/ExportMenu.svelte";
87
import { featureFlags } from "@rilldata/web-common/features/feature-flags";
8+
import { dynamicHeight } from "@rilldata/web-common/layout/layout-settings.ts";
99
import { derived } from "svelte/store";
1010
import { useTimeControlStore } from "web-common/src/features/dashboards/time-controls/time-control-store.ts";
1111
import { getPivotConfig } from "./pivot-data-config";
@@ -102,6 +102,8 @@
102102
rows,
103103
columns,
104104
)}
105+
setRowLimit={(limit) =>
106+
metricsExplorerStore.setPivotRowLimit($exploreName, limit)}
105107
collapseAll={() =>
106108
metricsExplorerStore.setPivotExpanded($exploreName, {})}
107109
{isFetching}
@@ -148,6 +150,12 @@
148150
rowId,
149151
columnId,
150152
)}
153+
setPivotRowLimitForExpanded={(expandIndex, limit) =>
154+
metricsExplorerStore.setPivotRowLimitForExpandedRow(
155+
$exploreName,
156+
expandIndex,
157+
limit,
158+
)}
151159
/>
152160
{/if}
153161
</div>

web-common/src/features/dashboards/pivot/PivotExpandableCell.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import ChevronRight from "@rilldata/web-common/components/icons/ChevronRight.svelte";
33
import Spacer from "@rilldata/web-common/components/icons/Spacer.svelte";
4+
import { LOADING_CELL } from "@rilldata/web-common/features/dashboards/pivot/pivot-constants";
45
import type { Row } from "@tanstack/svelte-table";
56
import type { PivotDataRow } from "./types";
67
@@ -17,10 +18,9 @@
1718
role="presentation"
1819
class="dimension-cell pointer-events-none"
1920
style:padding-left="{row.depth * 14}px"
20-
class:-ml-1={assembledAndCanExpand}
2121
class:cursor-pointer={assembledAndCanExpand}
2222
>
23-
{#if value === "LOADING_CELL"}
23+
{#if value === LOADING_CELL}
2424
<span class="loading-cell" />
2525
{:else if assembledAndCanExpand}
2626
<div class="caret opacity-100 shrink-0" class:expanded>
@@ -31,7 +31,7 @@
3131
{/if}
3232

3333
<span class="truncate min-w-0">
34-
{#if value === "LOADING_CELL"}
34+
{#if value === LOADING_CELL}
3535
{""}
3636
{:else if value === ""}
3737
{"\u00A0"}

web-common/src/features/dashboards/pivot/PivotMeasureCell.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<script lang="ts">
22
export let assembled;
3+
export let isShowMoreRow = false;
34
</script>
45

5-
{#if assembled}
6+
{#if isShowMoreRow}
7+
<!-- Render blank for show more rows -->
8+
{:else if assembled}
69
<span class="text-gray-400">-</span>
710
{:else}
811
<span class="loading-cell" />

0 commit comments

Comments
 (0)