[graph] some edge weight work, but unfinished and this doesn't compile!

parent 1a54188e
...@@ -20,6 +20,7 @@ workspace: ...@@ -20,6 +20,7 @@ workspace:
- d3: "*" - d3: "*"
- data-default: "*" - data-default: "*"
- datetime: ">=6.1.0 <7.0.0" - datetime: ">=6.1.0 <7.0.0"
- debounce
- debug: ">=6.0.2 <7.0.0" - debug: ">=6.0.2 <7.0.0"
- dom-filereader: ">=7.0.0 <8.0.0" - dom-filereader: ">=7.0.0 <8.0.0"
- dom-simple: ">=0.4.0 <0.5.0" - dom-simple: ">=0.4.0 <0.5.0"
...@@ -118,6 +119,7 @@ workspace: ...@@ -118,6 +119,7 @@ workspace:
- d3 - d3
- data-default - data-default
- datetime - datetime
- debounce
- debug - debug
- distributive - distributive
- dom-filereader - dom-filereader
...@@ -728,6 +730,8 @@ workspace: ...@@ -728,6 +730,8 @@ workspace:
data-default: data-default:
git: https://github.com/garganscript/purescript-data-default.git git: https://github.com/garganscript/purescript-data-default.git
ref: v0.4.0 ref: v0.4.0
debounce:
path: /data/git-work/github/PURESCRIPT/purescript-debounce
graphql-client: graphql-client:
git: https://github.com/garganscript/purescript-graphql-client.git git: https://github.com/garganscript/purescript-graphql-client.git
ref: spago-next-9.3.2 ref: spago-next-9.3.2
...@@ -1050,6 +1054,13 @@ packages: ...@@ -1050,6 +1054,13 @@ packages:
- partial - partial
- prelude - prelude
- tuples - tuples
debounce:
type: local
path: /data/git-work/github/PURESCRIPT/purescript-debounce
dependencies:
- effect
- ffi-simple
- prelude
debug: debug:
type: registry type: registry
version: 6.0.2 version: 6.0.2
......
...@@ -6,6 +6,8 @@ workspace: ...@@ -6,6 +6,8 @@ workspace:
d3: d3:
git: https://github.com/garganscript/purescript-d3.git git: https://github.com/garganscript/purescript-d3.git
ref: v0.11.0 ref: v0.11.0
debounce:
path: /data/git-work/github/PURESCRIPT/purescript-debounce
string-search: string-search:
git: https://gitlab.iscpif.fr/gargantext/purescript-string-search.git git: https://gitlab.iscpif.fr/gargantext/purescript-string-search.git
ref: spago-next ref: spago-next
...@@ -58,6 +60,7 @@ package: ...@@ -58,6 +60,7 @@ package:
- d3: "*" - d3: "*"
- data-default: "*" - data-default: "*"
- datetime: ">=6.1.0 <7.0.0" - datetime: ">=6.1.0 <7.0.0"
- debounce
- debug: ">=6.0.2 <7.0.0" - debug: ">=6.0.2 <7.0.0"
- dom-filereader: ">=7.0.0 <8.0.0" - dom-filereader: ">=7.0.0 <8.0.0"
- dom-simple: ">=0.4.0 <0.5.0" - dom-simple: ">=0.4.0 <0.5.0"
......
...@@ -235,6 +235,8 @@ graphViewCpt = R.memo' $ here.component "graphView" cpt where ...@@ -235,6 +235,8 @@ graphViewCpt = R.memo' $ here.component "graphView" cpt where
, sigmaRef , sigmaRef
} _ = do } _ = do
-- { edgeConfluence, edgeWeight } <- GraphStore.use
-- edgeConfluence' <- R2.useLive' edgeConfluence -- edgeConfluence' <- R2.useLive' edgeConfluence
-- edgeWeight' <- R2.useLive' edgeWeight -- edgeWeight' <- R2.useLive' edgeWeight
-- nodeSize' <- R2.useLive' nodeSize -- nodeSize' <- R2.useLive' nodeSize
...@@ -410,7 +412,11 @@ hooksTransformGraph = do ...@@ -410,7 +412,11 @@ hooksTransformGraph = do
params <- transformGraphStoreParams params <- transformGraphStoreParams
graph' <- R2.useLive' store.graph graph' <- R2.useLive' store.graph
R.useEffect' $ do
here.log2 "[hooksTransformGraph] hashed" $ hashLiveProps params
R.useEffect2' (hashLiveProps params) graph' $ do R.useEffect2' (hashLiveProps params) graph' $ do
here.log2 "[hooksTransformGraph] transformed" $ transformGraph graph' params
T.write_ (transformGraph graph' params) store.transformedGraph T.write_ (transformGraph graph' params) store.transformedGraph
transformGraph :: SigmaxT.SGraph -> Record LiveProps -> SigmaxT.SGraph transformGraph :: SigmaxT.SGraph -> Record LiveProps -> SigmaxT.SGraph
......
...@@ -44,6 +44,7 @@ type Store = ...@@ -44,6 +44,7 @@ type Store =
, edgeConfluence :: T.Box Range.NumberRange , edgeConfluence :: T.Box Range.NumberRange
, edgeConfluenceRange :: T.Box Range.NumberRange , edgeConfluenceRange :: T.Box Range.NumberRange
, edgeWeight :: T.Box Range.NumberRange , edgeWeight :: T.Box Range.NumberRange
, edgeWeightRange :: T.Box Range.NumberRange
, forceAtlasState :: T.Box SigmaxT.ForceAtlasState , forceAtlasState :: T.Box SigmaxT.ForceAtlasState
, noverlapState :: T.Box SigmaxT.NoverlapState , noverlapState :: T.Box SigmaxT.NoverlapState
, graphStage :: T.Box GET.Stage , graphStage :: T.Box GET.Stage
...@@ -79,6 +80,7 @@ type State = ...@@ -79,6 +80,7 @@ type State =
, edgeConfluence :: Range.NumberRange , edgeConfluence :: Range.NumberRange
, edgeConfluenceRange :: Range.NumberRange , edgeConfluenceRange :: Range.NumberRange
, edgeWeight :: Range.NumberRange , edgeWeight :: Range.NumberRange
, edgeWeightRange :: Range.NumberRange
, forceAtlasState :: SigmaxT.ForceAtlasState , forceAtlasState :: SigmaxT.ForceAtlasState
, noverlapState :: SigmaxT.NoverlapState , noverlapState :: SigmaxT.NoverlapState
, graphStage :: GET.Stage , graphStage :: GET.Stage
...@@ -109,6 +111,7 @@ options :: ...@@ -109,6 +111,7 @@ options ::
, mouseSelectorSize :: Number , mouseSelectorSize :: Number
, multiSelectEnabled :: Boolean , multiSelectEnabled :: Boolean
, edgeConfluence :: Range.NumberRange , edgeConfluence :: Range.NumberRange
, edgeWeight :: Range.NumberRange
, graphStage :: GET.Stage , graphStage :: GET.Stage
, nodeSize :: Range.NumberRange , nodeSize :: Range.NumberRange
--, showLouvain :: Boolean --, showLouvain :: Boolean
...@@ -131,6 +134,7 @@ options = ...@@ -131,6 +134,7 @@ options =
, labelRenderedSizeThreshold : 2.0 , labelRenderedSizeThreshold : 2.0
, mouseSelectorSize : 15.0 , mouseSelectorSize : 15.0
, edgeConfluence : Range.Closed { min: 0.0, max: 1.0 } , edgeConfluence : Range.Closed { min: 0.0, max: 1.0 }
, edgeWeight : Range.Closed { min: 0.0, max: 1.0 }
, graphStage : GET.Init , graphStage : GET.Init
, nodeSize : Range.Closed { min: 0.0, max: 100.0 } , nodeSize : Range.Closed { min: 0.0, max: 100.0 }
--, showLouvain : false --, showLouvain : false
......
...@@ -53,6 +53,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -53,6 +53,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
{ edgeConfluence { edgeConfluence
, edgeConfluenceRange , edgeConfluenceRange
, edgeWeight , edgeWeight
, edgeWeightRange
, forceAtlasState , forceAtlasState
, noverlapState , noverlapState
, graph , graph
...@@ -80,7 +81,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -80,7 +81,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 edgeWeightRange' <- R2.useLive' edgeWeightRange
nodeSizeRange' <- R2.useLive' nodeSizeRange nodeSizeRange' <- R2.useLive' nodeSizeRange
-- session <- useSession -- session <- useSession
...@@ -210,7 +211,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -210,7 +211,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
gap, gap gap, gap
, edgeWeightControl , edgeWeightControl
{ forceAtlasState { forceAtlasState
, range: edgeWeight' , range: edgeWeightRange'
, state: edgeWeight } , state: edgeWeight }
] ]
, ,
......
...@@ -6,6 +6,9 @@ module Gargantext.Components.GraphExplorer.Toolbar.RangeControl ...@@ -6,6 +6,9 @@ module Gargantext.Components.GraphExplorer.Toolbar.RangeControl
, nodeSizeControl , nodeSizeControl
) where ) where
import Data.Tuple.Nested((/\))
import Debug (spy)
import Effect.Debounce as Debounce
import Prelude import Prelude
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -54,20 +57,50 @@ edgeConfluenceControlCpt :: R.Component EdgeConfluenceControlProps ...@@ -54,20 +57,50 @@ edgeConfluenceControlCpt :: R.Component EdgeConfluenceControlProps
edgeConfluenceControlCpt = here.component "edgeConfluenceControl" cpt edgeConfluenceControlCpt = here.component "edgeConfluenceControl" cpt
where where
cpt { forceAtlasState cpt { forceAtlasState
, range
, state
} _ = do
let onChange' rng = do
-- here.log2 "[edgeWeightControl] debounce rng" rng
let _ = spy "debounce rng" rng
T.write_ rng state
onChange = Debounce.debounce onChange' 1000
pure $ edgeConfluenceControlInternal { forceAtlasState
, onChange
, range
, state }
type EdgeConfluenceControlInternalProps =
( forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
, onChange :: Debounce.Debounce
, range :: Range.NumberRange
, state :: T.Box Range.NumberRange
)
edgeConfluenceControlInternal :: R2.Leaf EdgeConfluenceControlInternalProps
edgeConfluenceControlInternal = R2.leaf edgeConfluenceControlInternalCpt
edgeConfluenceControlInternalCpt :: R.Component EdgeConfluenceControlInternalProps
edgeConfluenceControlInternalCpt = here.component "edgeConfluenceControlInternal" cpt
where
cpt { forceAtlasState
, onChange
, range: Range.Closed { min, max } , range: Range.Closed { min, max }
, state , state
} _ = do } _ = do
forceAtlasState' <- R2.useLive' forceAtlasState forceAtlasState' <- R2.useLive' forceAtlasState
state' <- T.useLive T.unequal state state' <- T.useLive T.unequal state
pure $ rangeControl { pure $ rangeControl {
caption: "Edge Confluence Weight" caption: "Edge Confluence Weight"
, sliderProps: { , sliderProps: {
bounds: Range.Closed { min, max } bounds: Range.Closed { min, max }
, epsilon: 0.01 , epsilon: 0.01
, height: 5.0 , height: 5.0
, initialValue: state' , initialValue: state'
, onChange: \rng -> T.write_ rng state , onChange: \rng -> Debounce.call onChange rng
, status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState' , status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState'
, step: 1.0 , step: 1.0
, width: 10.0 , width: 10.0
...@@ -88,20 +121,72 @@ edgeWeightControlCpt :: R.Component EdgeWeightControlProps ...@@ -88,20 +121,72 @@ edgeWeightControlCpt :: R.Component EdgeWeightControlProps
edgeWeightControlCpt = here.component "edgeWeightControl" cpt edgeWeightControlCpt = here.component "edgeWeightControl" cpt
where where
cpt { forceAtlasState cpt { forceAtlasState
, range: range@(Range.Closed { min, max })
, state
} _ = do
-- TODO
useTransition
let onChange' rng = do
-- here.log2 "[edgeWeightControl] debounce rng" rng
let _ = spy "debounce rng" rng
let _ = spy "debounce state" state
T.write_ rng state
onChange = Debounce.debounce onChange' 1000
forceAtlasState' <- R2.useLive' forceAtlasState
state' <- T.useLive T.unequal state
let _ = spy "[edgeWeightControlInteral] onChange" onChange
pure $ rangeControl {
caption: "Edge Weight"
, sliderProps: {
bounds: range
, initialValue: state'
, epsilon: (max - min) / 100.0
, height: 5.0
, onChange: \rng -> Debounce.call onChange rng
, status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState'
, step: 1.0
, width: 10.0
}
}
-- pure $ edgeWeightControlInternal { forceAtlasState
-- , onChange
-- , range
-- , state }
type EdgeWeightControlInternalProps =
( forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
, onChange :: Debounce.Debounce
, range :: Range.NumberRange
, state :: T.Box Range.NumberRange
)
edgeWeightControlInternal :: R2.Leaf EdgeWeightControlInternalProps
edgeWeightControlInternal = R2.leaf edgeWeightControlInternalCpt
edgeWeightControlInternalCpt :: R.Component EdgeWeightControlInternalProps
edgeWeightControlInternalCpt = here.component "edgeWeightControlInternal" cpt
where
cpt { forceAtlasState
, onChange
, range: Range.Closed { min, max } , range: Range.Closed { min, max }
, state , state
} _ = do } _ = do
forceAtlasState' <- R2.useLive' forceAtlasState forceAtlasState' <- R2.useLive' forceAtlasState
state' <- T.useLive T.unequal state state' <- T.useLive T.unequal state
let _ = spy "[edgeWeightControlInteral] onChange" onChange
pure $ rangeControl { pure $ rangeControl {
caption: "Edge Weight" caption: "Edge Weight"
, sliderProps: { , sliderProps: {
bounds: Range.Closed { min, max } bounds: Range.Closed { min, max }
, initialValue: state' , initialValue: state'
, epsilon: (max - min) / 100.0 , epsilon: (max - min) / 100.0
, height: 5.0 , height: 5.0
, onChange: \rng -> T.write_ rng state , onChange: \rng -> Debounce.call onChange rng
, status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState' , status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState'
, step: 1.0 , step: 1.0
, width: 10.0 , width: 10.0
......
...@@ -5,8 +5,7 @@ module Gargantext.Components.Nodes.Graph ...@@ -5,8 +5,7 @@ module Gargantext.Components.Nodes.Graph
import Gargantext.Prelude import Gargantext.Prelude
import Data.Array as A import Data.Array as A
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)
...@@ -165,6 +164,11 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where ...@@ -165,6 +164,11 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
-- | Precompute some values -- | Precompute some values
-- | -- |
let edgesWeightSorted = A.sortWith (_.weight) $ Seq.toUnfoldable $ SigmaxT.graphEdges graph
let edgeWeightMin = maybe 0.0 _.weight $ A.head edgesWeightSorted
let edgeWeightMax = maybe 100.0 _.weight $ A.last edgesWeightSorted
let edgeWeightRange = Range.Closed { min: edgeWeightMin, max: edgeWeightMax }
let edgesConfluenceSorted = A.sortWith (_.confluence) $ Seq.toUnfoldable $ SigmaxT.graphEdges graph let edgesConfluenceSorted = A.sortWith (_.confluence) $ Seq.toUnfoldable $ SigmaxT.graphEdges graph
let edgeConfluenceMin = maybe 0.0 _.confluence $ A.head edgesConfluenceSorted let edgeConfluenceMin = maybe 0.0 _.confluence $ A.head edgesConfluenceSorted
let edgeConfluenceMax = maybe 100.0 _.confluence $ A.last edgesConfluenceSorted let edgeConfluenceMax = maybe 100.0 _.confluence $ A.last edgesConfluenceSorted
...@@ -188,13 +192,13 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where ...@@ -188,13 +192,13 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
-- { min: 0.0 -- { min: 0.0
-- , max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph -- , max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph
-- } -- }
let weightsSeq = Seq.map _.weight $ SigmaxT.graphEdges graph -- let weightsSeq = Seq.map _.weight $ SigmaxT.graphEdges graph
let edgeWeight = Range.Closed -- let edgeWeight = Range.Closed
{ min: fromMaybe 0.0 $ minimum weightsSeq -- { min: fromMaybe 0.0 $ minimum weightsSeq
, max: fromMaybe 1.0 $ maximum weightsSeq } :: Range.Closed Number -- , 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': GraphStore.options.edgeWeight
, nodeSize': GraphStore.options.nodeSize , nodeSize': GraphStore.options.nodeSize
, removedNodeIds': GraphStore.options.removedNodeIds , removedNodeIds': GraphStore.options.removedNodeIds
, selectedNodeIds': GraphStore.options.selectedNodeIds , selectedNodeIds': GraphStore.options.selectedNodeIds
...@@ -212,7 +216,8 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where ...@@ -212,7 +216,8 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
, startForceAtlas , startForceAtlas
, forceAtlasState , forceAtlasState
, noverlapState: SigmaxT.NoverlapPaused , noverlapState: SigmaxT.NoverlapPaused
, edgeWeight -- , edgeWeight
, edgeWeightRange
, edgeConfluenceRange , edgeConfluenceRange
, nodeSizeRange , nodeSizeRange
-- (cache options) -- (cache options)
......
'use strict'; 'use strict';
import { useTransition } from 'react';
export function _addRootElement(rootElem) { export function _addRootElement(rootElem) {
document.body.insertBefore( document.body.insertBefore(
rootElem, rootElem,
...@@ -61,4 +63,6 @@ export function _scrollIntoView(el) { ...@@ -61,4 +63,6 @@ export function _scrollIntoView(el) {
inline: 'center' inline: 'center'
}); });
} }
\ No newline at end of file
export const useTransition;
...@@ -648,3 +648,8 @@ setInputValue elNullableRef val = case toMaybe (R.readRef elNullableRef) of ...@@ -648,3 +648,8 @@ setInputValue elNullableRef val = case toMaybe (R.readRef elNullableRef) of
_ <- pure $ (el .= "value") val _ <- pure $ (el .= "value") val
triggerEvent el "change" triggerEvent el "change"
triggerEvent el "input" triggerEvent el "input"
-- TODO useTransition?
foreign import data Transition :: Type
foreign import useTransitionImpl ::
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