Commit 76c03a2b authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Graph] working on moving controls out of the way

parent 0918f47a
...@@ -26,5 +26,8 @@ ...@@ -26,5 +26,8 @@
display: inline; display: inline;
float: left; float: left;
} }
#graph-explorer #tree {
position: absolute;
}
/*# sourceMappingURL=Graph.css.map */ /*# sourceMappingURL=Graph.css.map */
...@@ -26,3 +26,6 @@ ...@@ -26,3 +26,6 @@
ul ul
display: inline display: inline
float : left float : left
#tree
position: absolute
...@@ -169,8 +169,8 @@ sigmaSettings = ...@@ -169,8 +169,8 @@ sigmaSettings =
, labelSizeRatio: 2.0 -- label size in ratio of node size , labelSizeRatio: 2.0 -- label size in ratio of node size
, labelThreshold: 2.0 -- min node cam size to start showing label , labelThreshold: 2.0 -- min node cam size to start showing label
, maxEdgeSize: 1.0 , maxEdgeSize: 1.0
, maxNodeSize: 30.0 , maxNodeSize: 10.0
, minEdgeSize: 1.0 -- in fact used in tina as edge size , minEdgeSize: 0.5 -- in fact used in tina as edge size
, minNodeSize: 5.0 , minNodeSize: 5.0
, mouseEnabled: true , mouseEnabled: true
, mouseZoomDuration: 150.0 , mouseZoomDuration: 150.0
......
...@@ -14,6 +14,7 @@ import Thermite (Render, Spec, simpleSpec) ...@@ -14,6 +14,7 @@ import Thermite (Render, Spec, simpleSpec)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as RH import Reactix.DOM.HTML as RH
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Sigma (Sigma) import Gargantext.Hooks.Sigmax.Sigma (Sigma)
import Gargantext.Hooks.Sigmax.Types as Sigmax import Gargantext.Hooks.Sigmax.Types as Sigmax
import Gargantext.Components.GraphExplorer.Controls as Controls import Gargantext.Components.GraphExplorer.Controls as Controls
...@@ -87,7 +88,7 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt ...@@ -87,7 +88,7 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
] ]
, row [ Controls.controls controls ] , row [ Controls.controls controls ]
, row [ tree {mCurrentRoute, treeId} controls , row [ tree {mCurrentRoute, treeId} controls
, mGraph controls {graphId, graph} , mGraph controls.sigmaRef {graphId, graph}
, Sidebar.sidebar controls ] , Sidebar.sidebar controls ]
, row [ ] , row [ ]
] ]
...@@ -102,39 +103,37 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt ...@@ -102,39 +103,37 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
pullLeft = RH.div { className: "pull-left" } pullLeft = RH.div { className: "pull-left" }
pullRight = RH.div { className: "pull-right" } pullRight = RH.div { className: "pull-right" }
tree {treeId: Nothing} _ = RH.div {} [] tree {treeId: Nothing} _ = RH.div { id: "tree" } []
tree _ {showTree: false /\ _} = RH.div {} [] tree _ {showTree: false /\ _} = RH.div { id: "tree" } []
tree {mCurrentRoute, treeId: Just treeId} _ = tree {mCurrentRoute, treeId: Just treeId} _ =
RH.div { className: "col-md-2" } [ Tree.elTreeview {mCurrentRoute, root: treeId} ] RH.div { id: "tree", className: "col-md-2" } [
Tree.elTreeview {mCurrentRoute, root: treeId}
]
mGraph :: Record Controls.Controls -> {graphId :: GraphId, graph :: Maybe Graph.Graph} -> R.Element mGraph :: R.Ref (Maybe Sigmax.Sigma) -> {graphId :: GraphId, graph :: Maybe Graph.Graph} -> R.Element
mGraph _ {graph: Nothing} = RH.div {} [] mGraph _ {graph: Nothing} = RH.div {} []
mGraph controls {graphId, graph: Just graph} = graphView controls {graphId, graph} mGraph sigmaRef {graphId, graph: Just graph} = graphView sigmaRef {graphId, graph}
type GraphProps = ( type GraphProps = (
graphId :: GraphId graphId :: GraphId
, graph :: Graph.Graph , graph :: Graph.Graph
) )
graphView :: Record Controls.Controls -> Record GraphProps -> R.Element graphView :: R.Ref (Maybe Sigmax.Sigma) -> Record GraphProps -> R.Element
graphView controls props = R.createElement el props [] graphView sigmaRef props = R.createElement (R.memo el (==)) props []
where where
el = R.hooksComponent "GraphView" cpt el = R.hooksComponent "GraphView" cpt
cpt {graphId, graph} _children = do cpt {graphId, graph} _children = do
pure $ pure $
RH.div { className: colSize controls } RH.div { id: "graph-view", className: "col-md-12" }
[ [
Graph.graph { Graph.graph {
forceAtlas2Settings: Graph.forceAtlas2Settings forceAtlas2Settings: Graph.forceAtlas2Settings
, graph , graph
, sigmaSettings: Controls.controlsToSigmaSettings controls , sigmaSettings: Graph.sigmaSettings
, sigmaRef: controls.sigmaRef , sigmaRef: sigmaRef
} }
] ]
-- TODO: this doesn't work? seems to always render "col-md-9"
colSize {showSidePanel: (true /\ _), showTree: (true /\ _)} = "col-md-8"
colSize {showSidePanel: (false /\ _), showTree: (false /\ _)} = "col-md-12"
colSize _ = "col-md-10"
convert :: GET.GraphData -> Graph.Graph convert :: GET.GraphData -> Graph.Graph
convert (GET.GraphData r) = Sigmax.Graph {nodes, edges} convert (GET.GraphData r) = Sigmax.Graph {nodes, edges}
......
...@@ -51,7 +51,7 @@ type LocalControls = ...@@ -51,7 +51,7 @@ type LocalControls =
initialLocalControls :: R.Hooks (Record LocalControls) initialLocalControls :: R.Hooks (Record LocalControls)
initialLocalControls = do initialLocalControls = do
edgeSize <- R.useState' $ Range.Closed { min: 0.5, max: 1.0 } edgeSize <- R.useState' $ Range.Closed { min: 0.5, max: 1.0 }
labelSize <- R.useState' 3.0 labelSize <- R.useState' 14.0
nodeSize <- R.useState' $ Range.Closed { min: 5.0, max: 10.0 } nodeSize <- R.useState' $ Range.Closed { min: 5.0, max: 10.0 }
pauseForceAtlas <- R.useState' true pauseForceAtlas <- R.useState' true
showEdges <- R.useState' true showEdges <- R.useState' true
......
module Gargantext.Hooks.Sigmax.Types where module Gargantext.Hooks.Sigmax.Types where
import Gargantext.Prelude
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Sequence (Seq) import Data.Sequence (Seq)
...@@ -8,5 +11,11 @@ import DOM.Simple.Types (Element) ...@@ -8,5 +11,11 @@ import DOM.Simple.Types (Element)
newtype Graph n e = Graph { nodes :: Seq {|n}, edges :: Seq {|e} } newtype Graph n e = Graph { nodes :: Seq {|n}, edges :: Seq {|e} }
derive instance eqGraph :: Eq Graph
--instance eqGraph :: Eq Graph where
-- eq (Graph {nodes: n1, edges: e1}) (Graph {nodes: n2, edges: e2}) = n1 == n2 && e1 == e2
type Renderer = { "type" :: String, container :: Element } type Renderer = { "type" :: String, container :: Element }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment