Skip to content

Commit

Permalink
Merge pull request finos#1676 from finos/fix-treemap-null-groups
Browse files Browse the repository at this point in the history
Fix Treemap zoom when a group level is `null`
  • Loading branch information
texodus authored Dec 16, 2021
2 parents 5b04783 + 5c809c2 commit 04ab687
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
5 changes: 3 additions & 2 deletions packages/perspective-viewer-d3fc/src/js/data/treeData.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ export function treeData(settings) {
: [d.value, d.data.color]
.concat(d.data.tooltip || [])
.filter((x) => x !== undefined);

d.crossValue = d
.ancestors()
.slice(0, -1)
.reverse()
.map((cross) => cross.data.name)
.join("|");
.map((cross) => cross.data.name);

d.key = set[0];
d.label = toValue(
settings.crossValues[d.depth - 1 < 0 ? 0 : d.depth - 1].type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const textLevelHelper = (d, treemapLevel, crossValues) => {
if (
!crossValues
.filter((x) => x !== "")
.every((x) => d.crossValue.split("|").includes(x))
.every((x) => d.crossValue.includes(x))
)
return textVisability.zero;
switch (d.depth) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import treemapLayout from "./treemapLayout";
import {textOpacity} from "./treemapLabel";

const includesAllCrossValues = (d, crossValues) =>
crossValues.every((val) => d.crossValue.split("|").includes(val));
crossValues.every((val) => d.crossValue.includes(val));

export function calculateSubTreeMap(
d,
Expand Down Expand Up @@ -103,7 +103,7 @@ function approximateAttributesForAllNodes(
const height = calcHeight(d) * dimensionMultiplier.height;
const visible =
includesAllCrossValues(d, crossValues) &&
d.data.name != crossValues[treemapLevel - 1];
d.data.name !== crossValues[treemapLevel - 1];

d.mapLevel[treemapLevel] = {
x0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function treemapSeries() {
.attr("y", (d) => d.y0 + calcHeight(d) / 2)
.text((d) => d.label);

const rootNode = rects.filter((d) => d.crossValue === "").datum();
const rootNode = rects.filter((d) => d.crossValue.length === 0).datum();
calculateRootLevelMap(nodesMerge, rootNode);

toggleLabels(nodesMerge, 0, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function returnToLevel(
root_settings
) {
if (settings.treemapLevel > 0) {
const crossValues = rootNode.crossValue.split("|");
const crossValues = rootNode.crossValue;
executeTransition(
rootNode,
rects,
Expand All @@ -57,7 +57,7 @@ export function returnToLevel(
.slice(1, settings.treemapRoute.length)
.forEach((cv) => {
const d = nodesMerge.filter((d) => d.crossValue === cv).datum();
const crossValues = d.crossValue.split("|");
const crossValues = d.crossValue;
calculateSubTreeMap(
d,
crossValues,
Expand Down Expand Up @@ -108,7 +108,8 @@ export function changeLevel(

settings.treemapLevel = d.depth;

const crossValues = d.crossValue.split("|");
const crossValues = d.crossValue;

if (
!d.mapLevel[settings.treemapLevel] ||
!d.mapLevel[settings.treemapLevel].levelRoot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ function tests(extract) {
await workspace.duplicate(widget);
});

await page.evaluate(async () => {
await workspace.notifyResize(true);
});

return extract(page);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ impl Component for ConfigSelector {
""
};

// web_sys::console::log_1(&"redraw".into());
let dragend = Callback::from({
let dragdrop = self.props.dragdrop.clone();
move |_event| dragdrop.drag_end()
Expand Down
1 change: 0 additions & 1 deletion rust/perspective-viewer/src/rust/config/view_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ impl ViewConfig {
config.expressions = self.expressions.clone();
}
std::mem::swap(self, &mut config);
web_sys::console::log_1(&format!("{:?}", &self).into());
}

/// Apply `ViewConfigUpdate` to a `ViewConfig`, ignoring any fields in `update`
Expand Down

0 comments on commit 04ab687

Please sign in to comment.