Skip to content

Commit 576660b

Browse files
committed
Merge pull request #3002 from finos/aggregate-depth
Add `aggregate_depth` datagrid style config Signed-off-by: Andrew Stein <[email protected]>
2 parents a2d4b18 + 9f9688a commit 576660b

File tree

40 files changed

+444
-189
lines changed

40 files changed

+444
-189
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,11 @@ jobs:
358358
PACKAGE: "perspective-rs"
359359

360360
- name: Package
361-
if: ${{ !contains(matrix.os, 'windows') }}
362-
run: cargo package --allow-dirty -p perspective -p perspective-viewer -p perspective-js -p perspective-client -p perspective-server -p perspective-python
361+
if: ${{ !contains(matrix.os, 'windows') && steps.config-step.outputs.FULL_RUN }}
362+
run: cargo package --no-verify --allow-dirty -p perspective -p perspective-viewer -p perspective-js -p perspective-client -p perspective-server -p perspective-python
363363

364364
- uses: actions/upload-artifact@v4
365-
if: ${{ !contains(matrix.os, 'windows') }}
365+
if: ${{ !contains(matrix.os, 'windows') && steps.config-step.outputs.FULL_RUN }}
366366
with:
367367
name: perspective-rust
368368
path: rust/target/package/*.crate

packages/perspective-viewer-datagrid/src/js/data_listener/index.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,26 @@ export function createDataListener(viewer) {
8282
const path = this._column_paths[ipath];
8383
const path_parts = path.split("|");
8484
const column = columns[path] || new Array(y1 - y0).fill(null);
85+
const agg_depth = Math.min(
86+
regularTable[PRIVATE_PLUGIN_SYMBOL]?.[
87+
path_parts[this._config.split_by.length]
88+
]?.aggregate_depth || 0,
89+
this._config.group_by.length
90+
);
91+
8592
data.push(
86-
column.map((x) =>
87-
format_cell.call(
88-
this,
89-
path_parts[this._config.split_by.length],
90-
x,
91-
regularTable[PRIVATE_PLUGIN_SYMBOL]
92-
)
93-
)
93+
column.map((x, i) => {
94+
if (columns?.__ROW_PATH__?.[i]?.length < agg_depth) {
95+
return "";
96+
} else {
97+
return format_cell.call(
98+
this,
99+
path_parts[this._config.split_by.length],
100+
x,
101+
regularTable[PRIVATE_PLUGIN_SYMBOL]
102+
);
103+
}
104+
})
94105
);
95106
metadata.push(column);
96107
if (is_settings_open) {

packages/perspective-viewer-datagrid/src/js/style_handlers/table_cell/boolean.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

1313
export function cell_style_boolean(plugin, td, metadata) {
14-
const [hex] =
15-
metadata.user === true
16-
? this._pos_fg_color
17-
: metadata.user === false
18-
? this._neg_fg_color
19-
: ["", 0, 0, 0, ""];
20-
21-
td.style.backgroundColor = "";
22-
td.style.color = hex;
14+
if (metadata._is_hidden_by_aggregate_depth) {
15+
td.style.backgroundColor = "";
16+
td.style.color = "";
17+
} else {
18+
const [hex] =
19+
metadata.user === true
20+
? this._pos_fg_color
21+
: metadata.user === false
22+
? this._neg_fg_color
23+
: ["", 0, 0, 0, ""];
24+
td.style.backgroundColor = "";
25+
td.style.color = hex;
26+
}
2327
}

packages/perspective-viewer-datagrid/src/js/style_handlers/table_cell/datetime.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export function cell_style_datetime(plugin, td, metadata) {
2727
}
2828
})();
2929

30-
if (
30+
if (metadata._is_hidden_by_aggregate_depth) {
31+
td.style.backgroundColor = "";
32+
td.style.color = "";
33+
} else if (
3134
plugin?.datetime_color_mode === "foreground" &&
3235
metadata.user !== null
3336
) {

packages/perspective-viewer-datagrid/src/js/style_handlers/table_cell/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,26 @@ export function table_cell_style_listener(regularTable, viewer) {
3333
for (const tr of regularTable.children[0].children[1].children) {
3434
for (const td of tr.children) {
3535
const metadata = regularTable.getMeta(td);
36+
3637
const column_name =
3738
metadata.column_header?.[this._config.split_by.length];
3839

3940
let type = get_psp_type.call(this, metadata);
4041
const plugin = plugins[column_name];
4142
const is_numeric = type === "integer" || type === "float";
4243

44+
// Check if aggregate depth hides this cell
45+
metadata._is_hidden_by_aggregate_depth = ((x) =>
46+
x === 0
47+
? false
48+
: x - 1 <
49+
Math.min(
50+
this._config.group_by.length,
51+
plugin?.aggregate_depth
52+
))(
53+
metadata.row_header?.filter((x) => x !== undefined)?.length
54+
);
55+
4356
if (is_numeric) {
4457
cell_style_numeric.call(
4558
this,

packages/perspective-viewer-datagrid/src/js/style_handlers/table_cell/numeric.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ export function cell_style_numeric(plugin, td, metadata, is_settings_open) {
4444
const [hex, r, g, b, _gradhex] = bg_tuple;
4545

4646
td.style.position = "";
47-
if (plugin?.number_bg_mode === "color") {
47+
if (metadata._is_hidden_by_aggregate_depth) {
48+
td.style.animation = "";
49+
td.style.backgroundColor = "";
50+
} else if (plugin?.number_bg_mode === "color") {
4851
td.style.animation = "";
4952
td.style.backgroundColor = hex;
5053
} else if (plugin?.number_bg_mode === "gradient") {
@@ -99,7 +102,10 @@ export function cell_style_numeric(plugin, td, metadata, is_settings_open) {
99102
}
100103
})();
101104

102-
if (plugin?.number_fg_mode === "disabled") {
105+
if (metadata._is_hidden_by_aggregate_depth) {
106+
td.style.backgroundColor = "";
107+
td.style.color = "";
108+
} else if (plugin?.number_fg_mode === "disabled") {
103109
if (plugin?.number_bg_mode === "color") {
104110
const source = this._plugin_background;
105111
const foreground = infer_foreground_from_background(

packages/perspective-viewer-datagrid/src/js/style_handlers/table_cell/string.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ export function cell_style_string(plugin, td, metadata) {
2626
}
2727
})();
2828

29-
if (plugin?.string_color_mode === "foreground" && metadata.user !== null) {
29+
if (metadata._is_hidden_by_aggregate_depth) {
30+
td.style.backgroundColor = "";
31+
td.style.color = "";
32+
} else if (
33+
plugin?.string_color_mode === "foreground" &&
34+
metadata.user !== null
35+
) {
3036
td.style.color = hex;
3137
td.style.backgroundColor = "";
3238
if (plugin?.format === "link") {

rust/perspective-js/src/ts/perspective.node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function make_client(
8888
const CONTENT_TYPES: Record<string, string> = {
8989
".js": "text/javascript",
9090
".mjs": "text/javascript",
91-
".css": "text/css",
91+
".css": "text/css; charset=utf-8",
9292
".json": "application/json",
9393
".arrow": "arraybuffer",
9494
".feather": "arraybuffer",

rust/perspective-viewer/src/less/column-dropdown.less

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
1111
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

13+
@import "dom/scrollbar.less";
14+
1315
@mixin icon {
1416
background-repeat: no-repeat;
1517
background-color: var(--icon--color);
@@ -35,7 +37,8 @@
3537
max-width: 300px;
3638
overflow: hidden;
3739
max-height: 600px;
38-
overflow: scroll;
40+
overflow: auto;
41+
@include scrollbar;
3942

4043
display: flex;
4144
flex-direction: column;

rust/perspective-viewer/src/less/column-settings-panel.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@
178178
content: var(--sign-display-label--content, "Sign Display");
179179
}
180180

181+
label#aggregate-depth-label:before {
182+
content: var(--aggregate-depth-label--content, "Aggregate Depth");
183+
}
184+
181185
label#max-value-label:before {
182186
content: var(--max-value-label--content, "Max Value");
183187
}

0 commit comments

Comments
 (0)