[graph] add edge weight control

parent 15fb46ca
...@@ -450,8 +450,8 @@ transformGraph graph { edgeConfluence' ...@@ -450,8 +450,8 @@ transformGraph graph { edgeConfluence'
edge { hidden = true } edge { hidden = true }
edgeHideWeight :: Record SigmaxT.Edge -> Record SigmaxT.Edge edgeHideWeight :: Record SigmaxT.Edge -> Record SigmaxT.Edge
edgeHideWeight edge@{ weightIdx } = edgeHideWeight edge@{ weight } =
if Range.within edgeWeight' $ toNumber weightIdx then if Range.within edgeWeight' weight then
edge edge
else else
edge { hidden = true } edge { hidden = true }
......
...@@ -11,7 +11,7 @@ import Effect.Timer (setTimeout) ...@@ -11,7 +11,7 @@ import Effect.Timer (setTimeout)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.GraphExplorer.Store as GraphStore import Gargantext.Components.GraphExplorer.Store as GraphStore
import Gargantext.Components.GraphExplorer.Toolbar.Buttons (cameraButton, centerButton, edgesToggleButton, louvainButton, pauseForceAtlasButton, pauseNoverlapButton, multiSelectEnabledButton) import Gargantext.Components.GraphExplorer.Toolbar.Buttons (cameraButton, centerButton, edgesToggleButton, louvainButton, pauseForceAtlasButton, pauseNoverlapButton, multiSelectEnabledButton)
import Gargantext.Components.GraphExplorer.Toolbar.RangeControl (edgeConfluenceControl, nodeSizeControl) import Gargantext.Components.GraphExplorer.Toolbar.RangeControl (edgeConfluenceControl, edgeWeightControl, nodeSizeControl)
import Gargantext.Components.GraphExplorer.Toolbar.SlideButton (labelSizeButton, labelRenderedSizeThresholdButton, mouseSelectorSizeSlider) import Gargantext.Components.GraphExplorer.Toolbar.SlideButton (labelSizeButton, labelRenderedSizeThresholdButton, mouseSelectorSizeSlider)
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
...@@ -52,7 +52,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -52,7 +52,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
-- | -- |
{ edgeConfluence { edgeConfluence
, edgeConfluenceRange , edgeConfluenceRange
-- , edgeWeight , edgeWeight
, forceAtlasState , forceAtlasState
, noverlapState , noverlapState
, graph , graph
...@@ -80,6 +80,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -80,6 +80,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
selectedNodeIds' <- R2.useLive' selectedNodeIds selectedNodeIds' <- R2.useLive' selectedNodeIds
showSidebar' <- R2.useLive' showSidebar showSidebar' <- R2.useLive' showSidebar
edgeConfluenceRange' <- R2.useLive' edgeConfluenceRange edgeConfluenceRange' <- R2.useLive' edgeConfluenceRange
edgeWeight' <- R2.useLive' edgeWeight
nodeSizeRange' <- R2.useLive' nodeSizeRange nodeSizeRange' <- R2.useLive' nodeSizeRange
-- session <- useSession -- session <- useSession
...@@ -207,12 +208,10 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -207,12 +208,10 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
} }
, ,
gap, gap gap, gap
, , edgeWeightControl
labelRenderedSizeThresholdButton { forceAtlasState
{ forceAtlasState , range: edgeWeight'
, sigmaRef , state: edgeWeight }
, state: labelRenderedSizeThreshold
}
] ]
, ,
-- Run spatialization -- Run spatialization
...@@ -321,12 +320,12 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -321,12 +320,12 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
{ forceAtlasState { forceAtlasState
, range: edgeConfluenceRange' , range: edgeConfluenceRange'
, state: edgeConfluence } , state: edgeConfluence }
{- , , gap
edgeWeightControl , labelRenderedSizeThresholdButton
{ forceAtlasState { forceAtlasState
, range: edgeWeightRange , sigmaRef
, state: edgeWeight } , state: labelRenderedSizeThreshold
-} }
, ,
gap, gap gap, gap
, ,
......
...@@ -99,7 +99,7 @@ edgeWeightControlCpt = here.component "edgeWeightControl" cpt ...@@ -99,7 +99,7 @@ edgeWeightControlCpt = here.component "edgeWeightControl" cpt
, sliderProps: { , sliderProps: {
bounds: Range.Closed { min, max } bounds: Range.Closed { min, max }
, initialValue: state' , initialValue: state'
, epsilon: 1.0 , epsilon: (max - min) / 100.0
, height: 5.0 , height: 5.0
, onChange: \rng -> T.write_ rng state , onChange: \rng -> T.write_ rng state
, status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState' , status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState'
......
...@@ -5,8 +5,8 @@ module Gargantext.Components.Nodes.Graph ...@@ -5,8 +5,8 @@ module Gargantext.Components.Nodes.Graph
import Gargantext.Prelude import Gargantext.Prelude
import Data.Array as A import Data.Array as A
import Data.Int as I import Data.Foldable (minimum, maximum)
import Data.Maybe (Maybe(..), isJust, maybe) import Data.Maybe (Maybe(..), isJust, fromMaybe, maybe)
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import DOM.Simple (document, querySelector) import DOM.Simple (document, querySelector)
...@@ -184,10 +184,14 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where ...@@ -184,10 +184,14 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
let nodeSizeMax = maybe 100.0 _.size $ A.last nodesSorted let nodeSizeMax = maybe 100.0 _.size $ A.last nodesSorted
let nodeSizeRange = Range.Closed { min: nodeSizeMin, max: nodeSizeMax } let nodeSizeRange = Range.Closed { min: nodeSizeMin, max: nodeSizeMax }
-- let edgeWeight = Range.Closed
-- { min: 0.0
-- , max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph
-- }
let weightsSeq = Seq.map _.weight $ SigmaxT.graphEdges graph
let edgeWeight = Range.Closed let edgeWeight = Range.Closed
{ min: 0.0 { min: fromMaybe 0.0 $ minimum weightsSeq
, max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph , max: fromMaybe 1.0 $ maximum weightsSeq } :: Range.Closed Number
}
let transformedGraph = transformGraph graph { edgeConfluence': GraphStore.options.edgeConfluence let transformedGraph = transformGraph graph { edgeConfluence': GraphStore.options.edgeConfluence
, edgeWeight': edgeWeight , edgeWeight': edgeWeight
......
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