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
7
Merge Requests
7
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
3b832734
Commit
3b832734
authored
Nov 19, 2024
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/689-dev-dynamic-legend' into dev
parents
60edf362
b09e3070
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
9 deletions
+44
-9
Sidebar.purs
src/Gargantext/Components/GraphExplorer/Sidebar.purs
+2
-5
Legend.purs
src/Gargantext/Components/GraphExplorer/Sidebar/Legend.purs
+0
-1
Buttons.purs
src/Gargantext/Components/GraphExplorer/Toolbar/Buttons.purs
+17
-1
Controls.purs
...Gargantext/Components/GraphExplorer/Toolbar/Controls.purs
+4
-1
Utils.purs
src/Gargantext/Components/GraphExplorer/Utils.purs
+21
-1
No files found.
src/Gargantext/Components/GraphExplorer/Sidebar.purs
View file @
3b832734
...
@@ -120,7 +120,7 @@ sideTabLegend :: R2.Leaf Props
...
@@ -120,7 +120,7 @@ sideTabLegend :: R2.Leaf Props
sideTabLegend = R2.leaf sideTabLegendCpt
sideTabLegend = R2.leaf sideTabLegendCpt
sideTabLegendCpt :: R.Component Props
sideTabLegendCpt :: R.Component Props
sideTabLegendCpt = here.component "sideTabLegend" cpt where
sideTabLegendCpt = here.component "sideTabLegend" cpt where
cpt { metaData: GET.MetaData { legend }, session, graphId } _ = do
cpt { metaData: GET.MetaData { legend }, session, graphId
} _ = do
-- | States
-- | States
-- |
-- |
store <- GraphStore.use
store <- GraphStore.use
...
@@ -128,8 +128,6 @@ sideTabLegendCpt = here.component "sideTabLegend" cpt where
...
@@ -128,8 +128,6 @@ sideTabLegendCpt = here.component "sideTabLegend" cpt where
hyperdataGraph
hyperdataGraph
<- R2.useLive' store.hyperdataGraph
<- R2.useLive' store.hyperdataGraph
legend' /\ legendBox <- R2.useBox' legend
-- | Hooks
-- | Hooks
-- |
-- |
...
@@ -158,13 +156,12 @@ sideTabLegendCpt = here.component "sideTabLegend" cpt where
...
@@ -158,13 +156,12 @@ sideTabLegendCpt = here.component "sideTabLegend" cpt where
{ className: "graph-sidebar__legend-tab" }
{ className: "graph-sidebar__legend-tab" }
[
[
Legend.legend
Legend.legend
{ legendSeq: Seq.fromFoldable legend
'
{ legendSeq: Seq.fromFoldable legend
, extractedNodeList
, extractedNodeList
, nodeCountList
, nodeCountList
, selectedNodeIds: store.selectedNodeIds
, selectedNodeIds: store.selectedNodeIds
, session
, session
, graphId
, graphId
, legendBox
}
}
]
]
...
...
src/Gargantext/Components/GraphExplorer/Sidebar/Legend.purs
View file @
3b832734
...
@@ -36,7 +36,6 @@ type Props =
...
@@ -36,7 +36,6 @@ type Props =
, selectedNodeIds :: T.Box ST.NodeIds
, selectedNodeIds :: T.Box ST.NodeIds
, session :: Session
, session :: Session
, graphId :: GET.GraphId
, graphId :: GET.GraphId
, legendBox :: T.Box (Array GET.Legend)
)
)
legend :: R2.Leaf Props
legend :: R2.Leaf Props
...
...
src/Gargantext/Components/GraphExplorer/Toolbar/Buttons.purs
View file @
3b832734
...
@@ -185,6 +185,8 @@ type LouvainButtonProps =
...
@@ -185,6 +185,8 @@ type LouvainButtonProps =
, sigmaRef :: R.Ref Sigmax.Sigma
, sigmaRef :: R.Ref Sigmax.Sigma
, transformedGraph :: T.Box SigmaxTypes.SGraph
, transformedGraph :: T.Box SigmaxTypes.SGraph
, title :: String
, title :: String
, mMetaData :: T.Box (Maybe GET.MetaData)
, hyperdataGraph :: T.Box GET.HyperdataGraph
)
)
louvainButton :: R2.Leaf LouvainButtonProps
louvainButton :: R2.Leaf LouvainButtonProps
...
@@ -192,9 +194,10 @@ louvainButton = R2.leaf louvainButtonCpt
...
@@ -192,9 +194,10 @@ louvainButton = R2.leaf louvainButtonCpt
louvainButtonCpt :: R.Component LouvainButtonProps
louvainButtonCpt :: R.Component LouvainButtonProps
louvainButtonCpt = here.component "louvainButton" cpt
louvainButtonCpt = here.component "louvainButton" cpt
where
where
cpt { forceAtlasState, graph, sigmaRef, transformedGraph, title
} _ = do
cpt { forceAtlasState, graph, sigmaRef, transformedGraph, title
, mMetaData, hyperdataGraph
} _ = do
graph' <- R2.useLive' graph
graph' <- R2.useLive' graph
forceAtlasState' <- R2.useLive' forceAtlasState
forceAtlasState' <- R2.useLive' forceAtlasState
mMetaData' <- R2.useLive' mMetaData
pure $
pure $
B.button
B.button
...
@@ -208,6 +211,19 @@ louvainButtonCpt = here.component "louvainButton" cpt
...
@@ -208,6 +211,19 @@ louvainButtonCpt = here.component "louvainButton" cpt
(Map.fromFoldable $ (\{ id, color } -> Tuple id color) <$> SigmaxTypes.graphNodes
(Map.fromFoldable $ (\{ id, color } -> Tuple id color) <$> SigmaxTypes.graphNodes
lgraph))
lgraph))
graph
graph
hyperdataGraph' <- T.modify (GEU.updateHyperdataClusters cluster) hyperdataGraph
let legend' = GEU.generateLegend hyperdataGraph'
let mMetaData'' = case mMetaData' of
Just (GET.MetaData m) -> Just $ GET.MetaData $ m { legend = legend' }
Nothing -> Just $ GET.MetaData {
corpusId : []
, legend : legend'
, list: { listId : 0, version : 0 }
, metric: "Order1"
, startForceAtlas: true
, title : ""
}
T.write_ mMetaData'' mMetaData
T.write_ lgraph transformedGraph
T.write_ lgraph transformedGraph
pure unit
pure unit
...
...
src/Gargantext/Components/GraphExplorer/Toolbar/Controls.purs
View file @
3b832734
...
@@ -63,6 +63,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
...
@@ -63,6 +63,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, hyperdataGraph
, hyperdataGraph
, labelRenderedSizeThreshold
, labelRenderedSizeThreshold
, labelSize
, labelSize
, mMetaData
, mouseSelectorSize
, mouseSelectorSize
, multiSelectEnabled
, multiSelectEnabled
, nodeSize
, nodeSize
...
@@ -294,7 +295,9 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
...
@@ -294,7 +295,9 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, graph
, graph
, sigmaRef
, sigmaRef
, transformedGraph
, transformedGraph
, title: "" }
, title: ""
, mMetaData
, hyperdataGraph }
]
]
,
,
-- Selection Settings
-- Selection Settings
...
...
src/Gargantext/Components/GraphExplorer/Utils.purs
View file @
3b832734
...
@@ -4,19 +4,24 @@ module Gargantext.Components.GraphExplorer.Utils
...
@@ -4,19 +4,24 @@ module Gargantext.Components.GraphExplorer.Utils
, normalizeNodeSizeDefault
, normalizeNodeSizeDefault
, normalizeNodeSize
, normalizeNodeSize
, takeGreatestNodeByCluster, countNodeByCluster
, takeGreatestNodeByCluster, countNodeByCluster
, generateLegend
, updateHyperdataClusters
) where
) where
import Gargantext.Prelude
import Data.Array as A
import Data.Array as A
import Data.Foldable (maximum, minimum)
import Data.Foldable (maximum, minimum)
import Data.Lens (Lens', lens, over, traversed, (^.))
import Data.Lens (Lens', lens, over, traversed, (^.))
import Data.Map as Map
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.Number as DN
import Data.Traversable (class Traversable)
import Data.Traversable (class Traversable)
import Gargantext.Components.GraphExplorer.GraphTypes as GEGT
import Gargantext.Components.GraphExplorer.GraphTypes as GEGT
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Data.Louvain as Louvain
import Gargantext.Hooks.Sigmax.Types as ST
import Gargantext.Hooks.Sigmax.Types as ST
import Gargantext.Prelude
import Gargantext.Utils (getter)
import Gargantext.Utils (getter)
import Gargantext.Utils.Lens as GUL
import Gargantext.Utils.Lens as GUL
...
@@ -108,3 +113,18 @@ countNodeByCluster graphData clusterId
...
@@ -108,3 +113,18 @@ countNodeByCluster graphData clusterId
, count: _
, count: _
}
}
>>> wrap
>>> wrap
generateLegend :: GET.HyperdataGraph -> Array GET.Legend
generateLegend (GET.HyperdataGraph { graph: (GET.GraphData { nodes })}) = A.sort $ A.foldl f [] $ A.fromFoldable nodes
where
f :: Array GET.Legend -> GEGT.Node -> Array GET.Legend
f acc (GEGT.Node {attributes: (GEGT.Cluster {clustDefault: i})}) = case A.find (\(GET.Legend {id_}) -> id_ == i) acc of
Just _ -> acc
Nothing -> acc <> [GET.Legend { id_: i, color: "#FFF", label: "Cluster" <> show i }]
updateHyperdataClusters :: Louvain.LouvainCluster -> GET.HyperdataGraph -> GET.HyperdataGraph
updateHyperdataClusters cluster (GET.HyperdataGraph gd) = GET.HyperdataGraph $ gd { graph = newGraph gd.graph }
where
newGraph (GET.GraphData d ) = GET.GraphData $ d { nodes = map f $ d.nodes }
f :: GEGT.Node -> GEGT.Node
f (GEGT.Node n) = GEGT.Node $ n { attributes = GEGT.Cluster { clustDefault: fromMaybe 0 $ Map.lookup n.id_ cluster } }
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