Skip to content
Snippets Groups Projects
Commit 952c8fab authored by Aamon Paul Hoffmann's avatar Aamon Paul Hoffmann
Browse files

played with forces + selection reset button

parent 6b4717c5
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment