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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
6277f784
Commit
6277f784
authored
Feb 02, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graph explorer] normalize nodes before making a snapshot
parent
11855438
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
5 deletions
+51
-5
Button.purs
src/Gargantext/Components/GraphExplorer/Button.purs
+1
-1
Utils.purs
src/Gargantext/Components/GraphExplorer/Utils.purs
+30
-2
Array.purs
src/Gargantext/Utils/Array.purs
+20
-2
No files found.
src/Gargantext/Components/GraphExplorer/Button.purs
View file @
6277f784
...
@@ -89,7 +89,7 @@ cameraButton { id
...
@@ -89,7 +89,7 @@ cameraButton { id
edges <- Sigmax.getEdges s
edges <- Sigmax.getEdges s
nodes <- Sigmax.getNodes s
nodes <- Sigmax.getNodes s
let graphData = GET.GraphData $ hyperdataGraph { edges = map GEU.stEdgeToGET edges
let graphData = GET.GraphData $ hyperdataGraph { edges = map GEU.stEdgeToGET edges
, nodes = map GEU.stNodeToGET nodes }
, nodes =
GEU.normalizeNodes $
map GEU.stNodeToGET nodes }
let cameras = map Sigma.toCamera $ Sigma.cameras s
let cameras = map Sigma.toCamera $ Sigma.cameras s
let camera = case cameras of
let camera = case cameras of
[c] -> GET.Camera { ratio: c.ratio
[c] -> GET.Camera { ratio: c.ratio
...
...
src/Gargantext/Components/GraphExplorer/Utils.purs
View file @
6277f784
module Gargantext.Components.GraphExplorer.Utils
module Gargantext.Components.GraphExplorer.Utils where
where
import Data.Maybe (Maybe(..))
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Sigmax.Types as ST
import Gargantext.Hooks.Sigmax.Types as ST
import Gargantext.Utils.Array as GUA
stEdgeToGET :: Record ST.Edge -> GET.Edge
stEdgeToGET :: Record ST.Edge -> GET.Edge
...
@@ -20,3 +22,29 @@ stNodeToGET { id, label, x, y, _original: GET.Node { attributes, size, type_ } }
...
@@ -20,3 +22,29 @@ stNodeToGET { id, label, x, y, _original: GET.Node { attributes, size, type_ } }
, x
, x
, y
, y
}
}
normalizeNodes :: Array GET.Node -> Array GET.Node
normalizeNodes ns = map normalizeNode ns
where
xs = map (\(GET.Node { x }) -> x) ns
ys = map (\(GET.Node { y }) -> y) ns
mMinx = GUA.min xs
mMaxx = GUA.max xs
mMiny = GUA.min ys
mMaxy = GUA.max 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 (GET.Node n@{ x, y }) = GET.Node $ n { x = x * xdivisor
, y = y * ydivisor }
src/Gargantext/Utils/Array.purs
View file @
6277f784
module Gargantext.Utils.Array (push) where
module Gargantext.Utils.Array (
max, min,
push) where
import Data.Array as A
import Data.Foldable (foldr)
import Data.Maybe (Maybe(..))
import Data.Ord as Ord
import Effect (Effect)
import Effect (Effect)
import Data.Unit (Unit)
import Effect.Uncurried (EffectFn2, runEffectFn2)
import Effect.Uncurried (EffectFn2, runEffectFn2)
import Gargantext.Prelude
foreign import _push :: forall a. EffectFn2 (Array a) a Unit
foreign import _push :: forall a. EffectFn2 (Array a) a Unit
push :: forall a. Array a -> a -> Effect Unit
push :: forall a. Array a -> a -> Effect Unit
push = runEffectFn2 _push
push = runEffectFn2 _push
max :: forall a. Ord a => Array a -> Maybe a
max xs = foldr reducer (A.head xs) xs
where
reducer _ Nothing = Nothing
reducer v (Just acc) = Just $ Ord.max acc v
min :: forall a. Ord a => Array a -> Maybe a
min xs = foldr reducer (A.head xs) xs
where
reducer _ Nothing = Nothing
reducer v (Just acc) = Just $ Ord.min acc v
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