Skip to content

Commit

Permalink
Fix datagrid pivot render bug
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Aug 31, 2023
1 parent cf5c197 commit 56ec825
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const FORMAT_CACHE = new FormatterCache();
* @returns
*/
export function format_cell(
parts,
title,
val,
plugins = {},
use_table_schema = false
Expand All @@ -33,8 +33,6 @@ export function format_cell(
return "-";
}

// TODO don't do this on every cell render ...
const title = parts[this._config.split_by.length];
const type =
(use_table_schema && this._table_schema[title]) ||
this._schema[title] ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function* format_tree_header(paths = [], row_headers, regularTable) {
path = path.slice(0, path.length - 1).fill("");
const formatted = format_cell.call(
this,
[row_headers[path.length - 1]],
row_headers[path.length - 1],
last,
plugins,
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function createDataListener() {
column.map((x) =>
format_cell.call(
this,
path_parts,
path_parts[this._config.split_by.length],
x,
regularTable[PRIVATE_PLUGIN_SYMBOL]
)
Expand Down
22 changes: 21 additions & 1 deletion packages/perspective-viewer-datagrid/test/js/superstore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

import { test } from "@playwright/test";
import { run_standard_tests } from "@finos/perspective-test";
import {
compareContentsToSnapshot,
compareLightDOMContents,
run_standard_tests,
} from "@finos/perspective-test";

async function getDatagridContents(page) {
return await page.evaluate(async () => {
Expand Down Expand Up @@ -39,4 +43,20 @@ test.describe("Datagrid with superstore data set", () => {
});

run_standard_tests("perspective-viewer-datagrid", getDatagridContents);

test("Row headers are printed correctly", async ({ page }) => {
await page.evaluate(async () => {
await document.querySelector("perspective-viewer").restore({
plugin: "Datagrid",
group_by: ["Ship Date"],
split_by: ["Ship Mode"],
columns: ["Sales", "Quantity", "Discount", "Profit"],
});
});

compareContentsToSnapshot(
await getDatagridContents(page),
"row-headers-are-printed-correctly"
);
});
});
Binary file modified tools/perspective-test/results.tar.gz
Binary file not shown.

0 comments on commit 56ec825

Please sign in to comment.