Skip to content

Commit

Permalink
Sankey tree fix (#204)
Browse files Browse the repository at this point in the history
* fix typo

* fix no split into nodes on methods

* fix no split into nodes on .jar-modules

* fix error on config import; displays root now without error

* fix tooltip for root

* autofix

* replace text filtering in sankey tree help with image
  • Loading branch information
LinaUr authored Apr 1, 2023
1 parent ea20910 commit dd92305
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
Binary file added observatory/src/assets/images/sankey/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions observatory/src/components/help/HelpDialogSankeyTree.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<script setup lang="ts">
import img1 from '../../assets/images/sankey/1.png'
import img2 from '../../assets/images/sankey/2.png'
import img3 from '../../assets/images/sankey/3.png'
const slides = [
{ content: '', src: img1 },
{ content: '', src: img2 },
{
content:
'Filtering for a custom nodes selection: Please, note that when filtering for a custom selection, branches where nodes other than the node at the end of a hierarchy level X is selected get filtered out and do not appear on screen. For example, only when node ci or code (=last node on the branch) from ;jdk.internal.vm.ci;jdk.vm.ci.code is selected, the branch containing this node is filtered in. Selecting any other node here (e.g., ;jdk), filters this branch out. The position of a node in the hierarchy is indicated by its path, shown in the tooltip.'
}
{ content: '', src: img3 }
]
</script>

Expand Down
6 changes: 3 additions & 3 deletions observatory/src/ts/Visualizations/SankeyTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class SankeyTree implements MultiverseVisualization {
})

if (this.tree.root.children) {
this.expandFistBranchToLeaves(this.tree.root.children[0])
this.expandFirstBranchToLeaves(this.tree.root.children[0])
}

// clear the selections, to redraw the change in a node's color and nodeSize
Expand All @@ -233,12 +233,12 @@ export class SankeyTree implements MultiverseVisualization {
)
}

private expandFistBranchToLeaves(vizNode: SankeyHierarchyPointNode) {
private expandFirstBranchToLeaves(vizNode: SankeyHierarchyPointNode) {
if (!vizNode) return

toggleChildren(vizNode, false, this.filteredNodes)
if (!vizNode.children) return
this.expandFistBranchToLeaves(vizNode.children[0])
this.expandFirstBranchToLeaves(vizNode.children[0])
}

private buildTree(): SankeyTreeCompound {
Expand Down
39 changes: 32 additions & 7 deletions observatory/src/ts/Visualizations/SankeyTree/SankeyTreeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { HIERARCHY_NAME_SEPARATOR, SUB_HIERARCHY_NAME_SEPARATOR } from '../../gl
import { ROOT_NODE_NAME } from '../SankeyTree'
import { ExclusiveSizes } from '../../Math/Universes'
import { UniverseCombination } from '../../UniverseTypes/UniverseCombination'
import { Layers } from '../../enums/Layers'

// #################################################################################################
// ##### (PRE-)PROCESSING ##########################################################################
Expand All @@ -27,7 +28,20 @@ export function createHierarchyFromPackages(
const pathSegments = node.identifier.substring(1).split(HIERARCHY_NAME_SEPARATOR)
for (let i = 0; i < pathSegments.length; i++) {
let hierarchySeparator = HIERARCHY_NAME_SEPARATOR
const subPathSegments = pathSegments[i].split(SUB_HIERARCHY_NAME_SEPARATOR)
let subPathSegments: string[] = []
switch (i + 1) {
case Layers.METHODS:
subPathSegments = [pathSegments[i]]
break
case Layers.MODULES:
if (/.+[0-9]+.+\.jar$/.test(pathSegments[i])) {
subPathSegments = [pathSegments[i]]
break
}
default:
subPathSegments = pathSegments[i].split(SUB_HIERARCHY_NAME_SEPARATOR)
}

for (let j = 0; j < subPathSegments.length; j++) {
let child = current.children.find((child) => child.name === subPathSegments[j])
if (child) {
Expand Down Expand Up @@ -123,9 +137,10 @@ export function collapseChildren(vizNode: SankeyHierarchyPointNode) {

export function filterDiffingUniverses(vizNode: SankeyHierarchyPointNode, filteredNodes: Node[]) {
if (!vizNode._children) return
return vizNode._children.filter((child: SankeyHierarchyPointNode) =>
const filteredChildren = vizNode._children.filter((child: SankeyHierarchyPointNode) =>
filteredNodes.includes(child.data)
)
return filteredChildren.length === 0 ? undefined : filteredChildren
}

export function sortPrivateChildren(vizNode: SankeyHierarchyPointNode, filter: NodesSortingFilter) {
Expand Down Expand Up @@ -167,11 +182,21 @@ export function asHTML(
if (Object.keys(metadata).length == 1) {
}
const node: Node = vizNode.data
return `<b>Exists in</b>: ${Array.from(node.sources.keys())
.map((uniIndex) => metadata[uniIndex].name)
.join(' ∩ ')}
<b>Path</b>: ${getWithoutRoot(node.identifier)}
${printCodeSizePerUniverse(vizNode, exclusiveCodeSizes, metadata)}`
return `<b>Exists in</b>: ${
node.name === ROOT_NODE_NAME
? 'None'
: Array.from(node.sources.keys())
.map((uniIndex) => metadata[uniIndex].name)
.join(' ∩ ')
}
<b>Path</b>: ${
node.name === ROOT_NODE_NAME ? ROOT_NODE_NAME : getWithoutRoot(node.identifier)
}
${
node.name === ROOT_NODE_NAME
? `<b>Code Size</b>: ${formatBytes(node.codeSize)}`
: printCodeSizePerUniverse(vizNode, exclusiveCodeSizes, metadata)
}`
}

function printCodeSizePerUniverse(
Expand Down

0 comments on commit dd92305

Please sign in to comment.