Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
037ea73b
Commit
037ea73b
authored
Oct 12, 2022
by
Przemyslaw Kaminski
Committed by
Alexandre Delanoë
Oct 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[utils] fix node normalization, add size normalization
parent
81c77cb9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
25 deletions
+13
-25
Utils.purs
src/Gargantext/Components/GraphExplorer/Utils.purs
+13
-25
No files found.
src/Gargantext/Components/GraphExplorer/Utils.purs
View file @
037ea73b
module Gargantext.Components.GraphExplorer.Utils
( stEdgeToGET, stNodeToGET
, normalizeNodes
, normalizeNodeSize
, takeGreatestNodeByCluster, countNodeByCluster
) where
...
...
@@ -8,7 +9,8 @@ import Gargantext.Prelude
import Data.Array as A
import Data.Foldable (maximum, minimum)
import Data.Lens (lens)
import Data.Lens (Lens', lens, over, traversed)
import Data.Int (floor, toNumber)
import Data.Maybe (Maybe(..))
import Data.Newtype (wrap)
import Data.Sequence as Seq
...
...
@@ -41,32 +43,18 @@ stNodeToGET { id, label, x, y, _original: GEGT.Node { attributes, size, type_ }
normalizeNodes :: Seq.Seq GEGT.Node -> Seq.Seq GEGT.Node
normalizeNodes ns = GUL.normalizeLens xLens $ GUL.normalizeLens yLens ns
where
xLens :: Lens' GEGT.Node Number
xLens = lens (\(GEGT.Node { x }) -> x) $ (\(GEGT.Node n) val -> GEGT.Node (n { x = val }))
yLens :: Lens' GEGT.Node Number
yLens = lens (\(GEGT.Node { y }) -> y) $ (\(GEGT.Node n) val -> GEGT.Node (n { y = val }))
-- normalizeNodes ns = Seq.map normalizeNode ns
-- where
-- xs = map (\(GEGT.Node { x }) -> x) ns
-- ys = map (\(GEGT.Node { y }) -> y) ns
-- mMinx = minimum xs
-- mMaxx = maximum xs
-- mMiny = minimum ys
-- mMaxy = maximum ys
-- mXrange = do
-- minx <- mMinx
-- maxx <- mMaxx
-- pure $ maxx - minx
-- mYrange = do
-- miny <- mMiny
-- maxy <- mMaxy
-- pure $ maxy - miny
-- xdivisor = case mXrange of
-- Nothing -> 1.0
-- Just xdiv -> 1.0 / xdiv
-- ydivisor = case mYrange of
-- Nothing -> 1.0
-- Just ydiv -> 1.0 / ydiv
-- normalizeNode (GEGT.Node n@{ x, y }) = GEGT.Node $ n { x = x * xdivisor
-- , y = y * ydivisor }
normalizeNodeSize :: Int -> Int -> Seq.Seq GEGT.Node -> Seq.Seq GEGT.Node
normalizeNodeSize minSize maxSize ns = over traversed (over sizeLens (\s -> toNumber minSize + s * quotient)) $ GUL.normalizeLens sizeLens ns
where
quotient :: Number
quotient = toNumber $ maxSize - minSize
sizeLens :: Lens' GEGT.Node Number
sizeLens = lens (\(GEGT.Node { size }) -> toNumber size) $ (\(GEGT.Node n) val -> GEGT.Node (n { size = floor val }))
------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment