Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
infovis-projekt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
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
Informationsvisualisierung 2024
infovis-projekt
Commits
952c8fab
Commit
952c8fab
authored
3 months ago
by
Aamon Paul Hoffmann
Browse files
Options
Downloads
Patches
Plain Diff
played with forces + selection reset button
parent
6b4717c5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Views/ForceDirectedGraph.elm
+92
-58
92 additions, 58 deletions
src/Views/ForceDirectedGraph.elm
with
92 additions
and
58 deletions
src/Views/ForceDirectedGraph.elm
+
92
−
58
View file @
952c8fab
...
...
@@ -41,9 +41,8 @@ view global local =
[
Html
.
div
[
style
"
display"
"
flex"
,
style
"
flex-direction"
"
row"
,
style
"
align-items"
"
center"
]
[
Html
.
h2
[
style
"
margin"
"
0"
]
[
Html
.
text
"
Force directed Graph"
]
-- , Html.button [ Local.RecalcStart |> propagate |> onClick, style "margin-left" "auto" ]
-- [ Html.i [ Html.Attributes.class "fa-solid fa-repeat fa-xl" ] [] ]
,
Html
.
button
[
Local
.
RecalcStart
|>
propagate
|>
onClick
,
style
"
margin-left"
"
auto"
]
[
Html
.
i
[
Html
.
Attributes
.
class
"
fa-solid fa-repeat fa-xl"
]
[]
]
,
Html
.
div
[
style
"
margin-left"
"
auto"
]
[
Html
.
text
"
Jahr: "
,
allYears
...
...
@@ -76,7 +75,17 @@ view global local =
|>
g
[
class
[
"
nodes"
]
]
]
,
Html
.
div
[
Html
.
Attributes
.
class
"
legend"
,
style
"
width"
"
19%"
]
[
Html
.
h3
[]
[
Html
.
text
"
Legende"
]
[
Html
.
div
[
style
"
display"
"
flex"
]
[
Html
.
h3
[]
[
Html
.
text
"
Legende"
]
,
if
not
<|
local
.
highlight
==
"
"
then
Html
.
button
[
Local
.
Highlight
"
"
|>
propagate
|>
onClick
,
style
"
margin-left"
"
auto"
]
[
Html
.
i
[
Html
.
Attributes
.
class
"
fa-solid fa-repeat fa-xl"
]
[]
]
else
Html
.
div
[]
[]
]
,
List
.
map
(
\
ent
->
[
flag
ent
.
state
...
...
@@ -195,57 +204,81 @@ postInit data year =
Graph
.
mapContexts
initializeNode
<|
makeGraph
filteredData
year
forces
=
[
--Force.customLinks 1
-- (List.map link (Graph.edges graph))
-- Force.manyBodyStrength -10 <|
-- List.map .id <|
-- Graph.nodes graph
--,
-- Force.collision
-- 20
-- <|
-- List.map .id <|
-- Graph.nodes graph
--Graph.edges graph
-- |> List.map
-- (\e ->
-- let
-- meanNotIssRat =
-- rowsWithBoth (findName e.from) (findName e.to)
-- |> List.map
-- (\ent ->
-- let
-- totApp =
-- Maybe.withDefault 0 <| ent.totalVisasApplied
-- totIss =
-- Maybe.withDefault 0 <| ent.totalVisasIssued
-- notIss =
-- totApp - totIss
-- notIssRat =
-- notIss / totApp
-- in
-- if not (isNaN notIssRat) && not (notIssRat < 0) then
-- notIssRat
-- else
-- 0
-- )
-- |> List.Statistics.mean
-- |> Maybe.withDefault 0
-- in
-- { source = e.from, target = e.to, distance = min w h * (1 - meanNotIssRat) / 1.5, strength = Just 1 }
-- )
-- |> Force.customLinks 3
Graph
.
nodes
graph
[
Graph
.
nodes
graph
|>
List
.
map
(
\
n
->
let
invrejected
=
0.1
cc
=
List
.
Extra
.
getAt
(
findName
n
.
id
|>
findPos
)
allCountries
|>
Maybe
.
withDefault
"
??"
rows
=
List
.
filter
(
\
e
->
e
.
state
==
cc
)
filteredData
acceptedRatio
=
(
List
.
map
(
\
e
->
Maybe
.
withDefault
0
<|
e
.
totalVisasApplied
)
rows
|>
List
.
Statistics
.
mean
|>
Maybe
.
withDefault
1
)
/
(
List
.
map
(
\
e
->
Maybe
.
withDefault
0
<|
e
.
totalVisasIssued
)
rows
|>
List
.
Statistics
.
mean
|>
Maybe
.
withDefault
1
)
_
=
Debug
.
log
"
DEBUG"
<|
"
cc "
++
Debug
.
toString
cc
++
"
aR: "
++
Debug
.
toString
acceptedRatio
in
(
n
.
id
,
-
10
)
(
n
.
id
,
0.5
*
acceptedRatio
)
)
|>
Force
.
customManyBody
0.9
|>
Force
.
customManyBody
0.99
--Force.customLinks 1
-- (List.map link (Graph.edges graph))
-- Force.manyBodyStrength -10 <|
-- List.map .id <|
-- Graph.nodes graph
,
Graph
.
nodes
graph
|>
List
.
map
(
\
e
->
(
e
.
id
,
if
List
.
member
(
findName
e
.
id
)
countryNames
then
30
else
10
)
)
|>
Force
.
customCollision
{
iterations
=
1
,
strength
=
1.0
}
--Graph.edges graph
-- |> List.map
-- (\e ->
-- let
-- meanNotIssRat =
-- rowsWithBoth (findName e.from) (findName e.to)
-- |> List.map
-- (\ent ->
-- let
-- totApp =
-- Maybe.withDefault 0 <| ent.totalVisasApplied
-- totIss =
-- Maybe.withDefault 0 <| ent.totalVisasIssued
-- notIss =
-- totApp - totIss
-- notIssRat =
-- notIss / totApp
-- in
-- if not (isNaN notIssRat) && not (notIssRat < 0) then
-- notIssRat
-- else
-- 0
-- )
-- |> List.Statistics.mean
-- |> Maybe.withDefault 0
-- in
-- { source = e.from, target = e.to, distance = min w h * (1 - meanNotIssRat) / 1.5, strength = Just 1 }
-- )
-- |> Force.customLinks 3
--, Graph.edges graph
-- |> List.map
-- (\i ->
...
...
@@ -290,15 +323,16 @@ postInit data year =
-- { source = i.from, target = i.to, distance = 10, strength = Just 1 }
-- )
-- |> Force.customLinks 1
--, Graph.nodes graph
-- |> List.map
-- (\i ->
-- if isSchengen i data then
-- ( i.id, { strength = 4.0, x = w / 2, y = h / 2, radius = min h w / 3.0 } )
-- else
-- ( i.id, { strength = 4.0, x = w / 2, y = h / 2, radius = min h w / 1.2 } )
-- )
-- |> Force.customRadial
,
Graph
.
nodes
graph
|>
List
.
map
(
\
i
->
if
isSchengen
i
data
then
(
i
.
id
,
{
strength
=
4.0
,
x
=
w
/
2
,
y
=
h
/
2
,
radius
=
min
h
w
/
3.0
}
)
else
(
i
.
id
,
{
strength
=
4.0
,
x
=
w
/
2
,
y
=
h
/
2
,
radius
=
min
h
w
/
1.2
}
)
)
|>
Force
.
customRadial
,
Force
.
center
(
w
/
2
)
(
h
/
2
)
...
...
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