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
edc959c8
Commit
edc959c8
authored
Nov 08, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graph] some work on node size
parent
f07cc33d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
16 deletions
+32
-16
GraphTypes.purs
src/Gargantext/Components/GraphExplorer/GraphTypes.purs
+1
-1
Layout.purs
src/Gargantext/Components/GraphExplorer/Layout.purs
+6
-3
SlideButton.purs
...gantext/Components/GraphExplorer/Toolbar/SlideButton.purs
+1
-1
Utils.purs
src/Gargantext/Components/GraphExplorer/Utils.purs
+18
-5
Graph.purs
src/Gargantext/Components/Nodes/Graph.purs
+6
-6
No files found.
src/Gargantext/Components/GraphExplorer/GraphTypes.purs
View file @
edc959c8
...
@@ -39,7 +39,7 @@ newtype Node = Node {
...
@@ -39,7 +39,7 @@ newtype Node = Node {
, children :: Array String
, children :: Array String
, id_ :: String
, id_ :: String
, label :: String
, label :: String
, size ::
Int
, size ::
Number
, type_ :: String
, type_ :: String
, x :: Number
, x :: Number
, y :: Number
, y :: Number
...
...
src/Gargantext/Components/GraphExplorer/Layout.purs
View file @
edc959c8
...
@@ -9,7 +9,6 @@ import Data.Int (toNumber)
...
@@ -9,7 +9,6 @@ import Data.Int (toNumber)
import Data.Map as Map
import Data.Map as Map
import Data.Maybe (Maybe(..), fromJust)
import Data.Maybe (Maybe(..), fromJust)
import Data.Nullable (null, Nullable)
import Data.Nullable (null, Nullable)
import Data.Number as DN
import Data.Sequence as Seq
import Data.Sequence as Seq
import Data.Set as Set
import Data.Set as Set
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
...
@@ -290,7 +289,11 @@ graphViewCpt = R.memo' $ here.component "graphView" cpt where
...
@@ -290,7 +289,11 @@ graphViewCpt = R.memo' $ here.component "graphView" cpt where
convert :: GET.GraphData -> Tuple (Maybe GET.MetaData) SigmaxT.SGraph
convert :: GET.GraphData -> Tuple (Maybe GET.MetaData) SigmaxT.SGraph
convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges}
convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges}
where
where
nodes = foldMapWithIndex nodeFn $ GEU.normalizeNodeSize 1 10000 r.nodes
normalizedNodes :: Array GEGT.Node
normalizedNodes = GEGT.Node <$> (GEU.normalizeNodeSizeDefault $ (\(GEGT.Node n) -> n) <$> r.nodes)
nodes :: Seq.Seq (Record SigmaxT.Node)
nodes = foldMapWithIndex nodeFn normalizedNodes
nodeFn :: Int -> GEGT.Node -> Seq.Seq (Record SigmaxT.Node)
nodeFn _i nn@(GEGT.Node n) =
nodeFn _i nn@(GEGT.Node n) =
Seq.singleton {
Seq.singleton {
borderColor: color
borderColor: color
...
@@ -302,7 +305,7 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges}
...
@@ -302,7 +305,7 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges}
, highlighted: false
, highlighted: false
, id : n.id_
, id : n.id_
, label : n.label
, label : n.label
, size :
DN.log (toNumber n.size + 1.0)
, size :
n.size
--, size: toNumber n.size
--, size: toNumber n.size
, type : modeGraphType gargType
, type : modeGraphType gargType
, x : n.x -- cos (toNumber i)
, x : n.x -- cos (toNumber i)
...
...
src/Gargantext/Components/GraphExplorer/Toolbar/SlideButton.purs
View file @
edc959c8
...
@@ -94,7 +94,7 @@ labelSizeButtonCpt = here.component "labelSizeButton" cpt
...
@@ -94,7 +94,7 @@ labelSizeButtonCpt = here.component "labelSizeButton" cpt
defaultLabelSize: newValue
defaultLabelSize: newValue
, drawLabels: true
, drawLabels: true
, labelSize: newValue
, labelSize: newValue
, maxNodeSize: newValue / 2.5
--
, maxNodeSize: newValue / 2.5
--, labelSizeRatio: newValue / 2.5
--, labelSizeRatio: newValue / 2.5
}
}
T.write_ newValue state
T.write_ newValue state
...
...
src/Gargantext/Components/GraphExplorer/Utils.purs
View file @
edc959c8
module Gargantext.Components.GraphExplorer.Utils
module Gargantext.Components.GraphExplorer.Utils
( stEdgeToGET, stNodeToGET
( stEdgeToGET, stNodeToGET
, normalizeNodes
, normalizeNodes
, normalizeNodeSizeDefault
, normalizeNodeSize
, normalizeNodeSize
, takeGreatestNodeByCluster, countNodeByCluster
, takeGreatestNodeByCluster, countNodeByCluster
) where
) where
...
@@ -13,6 +14,7 @@ import Data.Lens (Lens', lens, over, traversed, (^.))
...
@@ -13,6 +14,7 @@ import Data.Lens (Lens', lens, over, traversed, (^.))
import Data.Int (floor, toNumber)
import Data.Int (floor, toNumber)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Newtype (wrap)
import Data.Newtype (wrap)
import Data.Number as DN
import Data.Sequence as Seq
import Data.Sequence as Seq
import Data.Traversable (class Traversable)
import Data.Traversable (class Traversable)
import Gargantext.Components.GraphExplorer.GraphTypes as GEGT
import Gargantext.Components.GraphExplorer.GraphTypes as GEGT
...
@@ -49,8 +51,16 @@ normalizeNodes ns = GUL.normalizeLens xLens $ GUL.normalizeLens yLens ns
...
@@ -49,8 +51,16 @@ normalizeNodes ns = GUL.normalizeLens xLens $ GUL.normalizeLens yLens ns
yLens :: Lens' GEGT.Node Number
yLens :: Lens' GEGT.Node Number
yLens = lens (\(GEGT.Node { y }) -> y) $ (\(GEGT.Node n) val -> GEGT.Node (n { y = val }))
yLens = lens (\(GEGT.Node { y }) -> y) $ (\(GEGT.Node n) val -> GEGT.Node (n { y = val }))
normalizeNodeSize :: forall t. Traversable t => Int -> Int -> t GEGT.Node -> t GEGT.Node
type NodeSize r = { size :: Number | r }
normalizeNodeSize minSize maxSize ns = over traversed (over sizeLens (\s -> toNumber minSize + (s - sizeMin') * quotient)) ns
normalizeNodeSizeDefault :: forall t r. Traversable t => t (NodeSize r) -> t (NodeSize r)
normalizeNodeSizeDefault ns = logSize <$> normalizeNodeSize 50.0 100000.0 ns
where
logSize (n@{ size }) = n { size = DN.log (size + 1.0) }
normalizeNodeSize :: forall t r. Traversable t =>
Number -> Number -> t (NodeSize r) -> t (NodeSize r)
normalizeNodeSize minSize maxSize ns = over traversed (over sizeLens (\s -> minSize + (s - sizeMin') * quotient)) ns
where
where
sizes = over traversed (_ ^. sizeLens) ns
sizes = over traversed (_ ^. sizeLens) ns
sizeMin = minimum sizes
sizeMin = minimum sizes
...
@@ -62,9 +72,12 @@ normalizeNodeSize minSize maxSize ns = over traversed (over sizeLens (\s -> toNu
...
@@ -62,9 +72,12 @@ normalizeNodeSize minSize maxSize ns = over traversed (over sizeLens (\s -> toNu
sizeMin' = fromMaybe 0.0 sizeMin
sizeMin' = fromMaybe 0.0 sizeMin
divisor = maybe 1.0 (\r -> 1.0 / r) range
divisor = maybe 1.0 (\r -> 1.0 / r) range
quotient :: Number
quotient :: Number
quotient = (toNumber $ maxSize - minSize) * divisor
quotient = (maxSize - minSize) * divisor
sizeLens :: Lens' GEGT.Node Number
--quotient = (toNumber $ maxSize - minSize) * divisor
sizeLens = lens (\(GEGT.Node { size }) -> toNumber size) $ (\(GEGT.Node n) val -> GEGT.Node (n { size = floor val }))
--sizeLens :: Lens' GEGT.Node Number
--sizeLens = lens (\(GEGT.Node { size }) -> size) $ (\(GEGT.Node n) val -> GEGT.Node (n { size = val }))
sizeLens :: Lens' { size :: Number | r } Number
sizeLens = lens (\{ size } -> size) $ \n val -> (n { size = val })
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
src/Gargantext/Components/Nodes/Graph.purs
View file @
edc959c8
...
@@ -98,22 +98,22 @@ nodeCpt = here.component "node" cpt where
...
@@ -98,22 +98,22 @@ nodeCpt = here.component "node" cpt where
Tuple mMetaData graph = convert hyperdataGraph
Tuple mMetaData graph = convert hyperdataGraph
in
in
hydrateStore
hydrateStore
{ graph
{ cacheParams: cache'
, graph
, graphId
, hyperdataGraph: loaded
, hyperdataGraph: loaded
, mMetaData
, mMetaData
, graphId
, cacheParams: cache'
}
}
}
}
--------------------------------------------------------
--------------------------------------------------------
type HydrateStoreProps =
type HydrateStoreProps =
(
mMetaData :: Maybe GET.MetaData
(
cacheParams :: GET.CacheParams
, graph :: SigmaxT.SGraph
, graph :: SigmaxT.SGraph
, hyperdataGraph :: GET.HyperdataGraph
, graphId :: GET.GraphId
, graphId :: GET.GraphId
, cacheParams :: GET.CacheParams
, hyperdataGraph :: GET.HyperdataGraph
, mMetaData :: Maybe GET.MetaData
)
)
hydrateStore :: R2.Leaf HydrateStoreProps
hydrateStore :: R2.Leaf HydrateStoreProps
...
...
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