Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D3FC Treemap bug fixes #1652

Merged
merged 2 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/perspective-viewer-d3fc/src/js/charts/treemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function treemap(container, settings) {
if (!settings.treemaps[split]) settings.treemaps[split] = {};

treemapSeries()
.settings(settings.treemaps[split])
.settings(settings.treemaps[split], settings)
.data(data)
.container(
d3.select(d3.select(this.parentNode).node().parentNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const nodeLevelHelper = (maxDepth, d) =>

export function treemapSeries() {
let settings = null;
let root_settings = null;
let data = null;
let color = null;
let treemapDiv = null;
Expand Down Expand Up @@ -96,7 +97,7 @@ export function treemapSeries() {
settings.treemapRoute.push(rootNode.crossValue);
rects
.filter((d) => d.children)
.on("click", (d) =>
.on("click", (_event, d) =>
changeLevel(
d,
rects,
Expand All @@ -106,7 +107,8 @@ export function treemapSeries() {
treemapDiv,
treemapSvg,
rootNode,
parentCtrls
parentCtrls,
root_settings
)
);

Expand All @@ -118,7 +120,8 @@ export function treemapSeries() {
treemapDiv,
treemapSvg,
rootNode,
parentCtrls
parentCtrls,
root_settings
);
};

Expand All @@ -127,6 +130,7 @@ export function treemapSeries() {
return settings;
}
settings = args[0];
root_settings = args[1];
return _treemapSeries;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
restoreLabels,
} from "./treemapLabel";
import {calculateSubTreeMap, saveLabelMap} from "./treemapLevelCalculation";
import {raiseEvent} from "../../tooltip/selectionEvent";

export function returnToLevel(
rects,
Expand All @@ -30,7 +31,8 @@ export function returnToLevel(
treemapDiv,
treemapSvg,
rootNode,
parentCtrls
parentCtrls,
root_settings
) {
if (settings.treemapLevel > 0) {
const crossValues = rootNode.crossValue.split("|");
Expand All @@ -46,6 +48,7 @@ export function returnToLevel(
0,
crossValues,
parentCtrls,
root_settings,
1,
false
);
Expand Down Expand Up @@ -75,6 +78,7 @@ export function returnToLevel(
d.depth,
crossValues,
parentCtrls,
root_settings,
1,
false
);
Expand All @@ -91,7 +95,8 @@ export function changeLevel(
treemapDiv,
treemapSvg,
rootNode,
parentCtrls
parentCtrls,
root_settings
) {
if (!d.children) return;

Expand Down Expand Up @@ -129,7 +134,8 @@ export function changeLevel(
rootNode,
settings.treemapLevel,
crossValues,
parentCtrls
parentCtrls,
root_settings
);
}

Expand All @@ -145,6 +151,7 @@ function executeTransition(
treemapLevel,
crossValues,
parentCtrls,
root_settings,
duration = 500,
recordLabelMap = true
) {
Expand Down Expand Up @@ -217,7 +224,7 @@ function executeTransition(
parentCtrls
.hide(false)
.text(d.label)
.onClick(() =>
.onClick(() => {
changeLevel(
parent,
rects,
Expand All @@ -228,9 +235,13 @@ function executeTransition(
treemapSvg,
rootNode,
parentCtrls,
duration
)
)();
root_settings
// duration
);
const viewer = treemapDiv.node().getRootNode()
.host.parentElement;
raiseEvent(viewer, parent, root_settings);
})();
} else {
parentCtrls.hide(true)();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function toValue(type, value) {

export function getGroupValues(data, settings) {
if (settings.crossValues.length === 0) return [];
if (data.crossValue.length === 0) return [];
const groupValues = (data.crossValue.split
? data.crossValue.split("|")
: [data.crossValue]) || [data.key];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export const selectionEvent = () => {

const _event = (selection) => {
const node = selection.node();
selection.on("click", (data) => raiseEvent(node, data, settings));
selection.on("click", (_event, data) =>
raiseEvent(node, data, settings)
);
};

_event.settings = (...args) => {
Expand Down