Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Schengen-Visa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Jäkel
Schengen-Visa
Commits
c03fd5bc
Commit
c03fd5bc
authored
3 months ago
by
ericj
Browse files
Options
Downloads
Patches
Plain Diff
tree node size corresponding to value
parent
ec3df5f3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/tree.js
+27
-2
27 additions, 2 deletions
modules/tree.js
with
27 additions
and
2 deletions
modules/tree.js
+
27
−
2
View file @
c03fd5bc
...
...
@@ -51,6 +51,22 @@ function updateTree(filterKey) {
console
.
log
(
treeData
)
const
root
=
d3
.
hierarchy
(
treeData
);
// Funktion, um Skalierungen für finale Knoten pro Ebene zu definieren
function
createSizeScale
(
nodes
)
{
const
values
=
nodes
.
filter
(
d
=>
!
d
.
children
)
// Nur Endknoten
.
map
(
d
=>
{
const
match
=
d
.
data
.
name
.
match
(
/:
(\d
+
)
$/
);
// Extrahiere Wert aus Name
return
match
?
+
match
[
1
]
:
0
;
});
return
d3
.
scaleSqrt
()
.
domain
([
0
,
d3
.
max
(
values
)])
// Min/Max der Werte
.
range
([
5
,
40
]);
// Knotenradius
}
// Erstelle die Skalierung basierend auf der aktuellen Ebene
const
sizeScale
=
createSizeScale
(
root
.
descendants
());
function
removeChildren
(
child
)
{
if
(
child
.
children
)
{
child
.
_children
=
child
.
children
;
...
...
@@ -98,7 +114,13 @@ function updateTree(filterKey) {
node
.
append
(
"
circle
"
)
.
style
(
"
cursor
"
,
hierarchyStack
.
length
<
3
?
"
pointer
"
:
""
)
.
attr
(
"
r
"
,
5
)
.
attr
(
"
r
"
,
d
=>
{
if
(
!
d
.
children
)
{
// Nur für finale Knoten die Größe anpassen
const
match
=
d
.
data
.
name
.
match
(
/:
(\d
+
)
$/
);
return
match
?
sizeScale
(
+
match
[
1
])
:
5
;
// Skalierung anwenden
}
return
5
;
// Standardgröße für interne Knoten
})
.
on
(
"
click
"
,
(
event
,
d
)
=>
{
if
(
hierarchyStack
.
length
<
3
&&
d
.
depth
===
1
||
d
.
depth
===
2
)
{
// Go deeper for states or countries
d3
.
select
(
"
.tooltip
"
).
remove
();
...
...
@@ -125,7 +147,10 @@ function updateTree(filterKey) {
.
attr
(
"
x
"
,
d
=>
{
if
(
d
.
data
.
name
===
"
Schengen States
"
)
return
46
if
(
d
.
children
)
return
-
10
if
(
!
d
.
children
)
return
10
if
(
!
d
.
children
)
{
// Nur für finale Knoten die Größe anpassen
const
match
=
d
.
data
.
name
.
match
(
/:
(\d
+
)
$/
);
return
match
?
sizeScale
(
+
match
[
1
])
+
10
:
10
;
// Skalierung anwenden
}
})
.
attr
(
"
y
"
,
d
=>
{
if
(
d
.
data
.
name
===
"
Schengen States
"
)
return
-
12
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment