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

Fix unique values hierarchy #832

Merged
merged 3 commits into from
Nov 10, 2022
Merged
Changes from 1 commit
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
26 changes: 26 additions & 0 deletions app/configurator/components/use-hierarchy-parents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,30 @@ const useHierarchyParents = (
}, [dimension.values, hierarchy]);
};

/**
* Can be used for debugging, pass a hierarchy, and copy the output
* to graphviz.
*
* @see https://dreampuf.github.io/GraphvizOnline/
*/
export const hierarchyToGraphviz = (
hierarchy: DimensionHierarchyQueryHierarchy
) => {
const lines = [] as string[];
dfs(hierarchy, (node, { depth, parents }) => {
lines.push(`"${node.value}"[label="${node.label.replace(/"/g, "")}"]`);
if (parents.length > 0) {
const parent = parents[parents.length - 1];
lines.push(`"${parent.value}" -> "${node.value}"`);
}
});
return `
digraph G {
rankdir=LR

${lines.join("\n")}
}
`;
};

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Copy link

@FabianCretton FabianCretton Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can give an input here, and this might be an "special" situation in my data: most of the nodes are related to values in the Data, except the "list of Zolltarif" node itself -> this is kind of a "fake" node, just to regroup and display the list of Zolltarifs that are included in a basket (whithout having to look at all tarifs in the children, and also given that a tarif could be directly at that level and not coming from a child).
As discussed with Patrick, there could be a better way to show this, we can talk about it. This was just a "possible" way that I used for that POC.
Thus, for me it makes sense if the node "list of Zolltarfis" can not be selected. It is a nice handling of the situation by Visualize.

And it is the same for the node "Zolltarifs" itself: there is no value in the data for it, but its children do have a value.

export default useHierarchyParents;