Commit c57efdc4 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Graph] edge range slider ranges are based on graph data now

parent 749eea82
...@@ -114,6 +114,16 @@ controlsCpt = R.hooksComponent "GraphControls" cpt ...@@ -114,6 +114,16 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
else else
pure unit pure unit
let edgesConfluenceSorted = A.sortWith (_.confluence) $ Seq.toUnfoldable $ SigmaxTypes.graphEdges props.graph
let edgeConfluenceMin = maybe 0.0 _.confluence $ A.head edgesConfluenceSorted
let edgeConfluenceMax = maybe 100.0 _.confluence $ A.last edgesConfluenceSorted
let edgeConfluenceRange = Range.Closed { min: edgeConfluenceMin, max: edgeConfluenceMax }
let edgesWeightSorted = A.sortWith (_.weight) $ Seq.toUnfoldable $ SigmaxTypes.graphEdges props.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 nodesSorted = A.sortWith (_.size) $ Seq.toUnfoldable $ SigmaxTypes.graphNodes props.graph let nodesSorted = A.sortWith (_.size) $ Seq.toUnfoldable $ SigmaxTypes.graphNodes props.graph
let nodeSizeMin = maybe 0.0 _.size $ A.head nodesSorted let nodeSizeMin = maybe 0.0 _.size $ A.head nodesSorted
let nodeSizeMax = maybe 100.0 _.size $ A.last nodesSorted let nodeSizeMax = maybe 100.0 _.size $ A.last nodesSorted
...@@ -128,8 +138,8 @@ controlsCpt = R.hooksComponent "GraphControls" cpt ...@@ -128,8 +138,8 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
RH.li {} [ centerButton props.sigmaRef ] RH.li {} [ centerButton props.sigmaRef ]
, RH.li {} [ pauseForceAtlasButton {state: props.forceAtlasState} ] , RH.li {} [ pauseForceAtlasButton {state: props.forceAtlasState} ]
, RH.li {} [ edgesToggleButton {state: props.showEdges} ] , RH.li {} [ edgesToggleButton {state: props.showEdges} ]
, RH.li {} [ edgeConfluenceControl props.sigmaRef props.edgeConfluence ] , RH.li {} [ edgeConfluenceControl edgeConfluenceRange props.edgeConfluence ]
, RH.li {} [ edgeWeightControl props.sigmaRef props.edgeWeight ] , RH.li {} [ edgeWeightControl edgeWeightRange props.edgeWeight ]
-- change level -- change level
-- file upload -- file upload
-- run demo -- run demo
...@@ -148,9 +158,6 @@ controlsCpt = R.hooksComponent "GraphControls" cpt ...@@ -148,9 +158,6 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
useGraphControls :: SigmaxTypes.SGraph -> R.Hooks (Record Controls) useGraphControls :: SigmaxTypes.SGraph -> R.Hooks (Record Controls)
useGraphControls graph = do useGraphControls graph = do
let edges = SigmaxTypes.graphEdges graph
let nodes = SigmaxTypes.graphNodes graph
cursorSize <- R.useState' 10.0 cursorSize <- R.useState' 10.0
edgeConfluence <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 } edgeConfluence <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 }
edgeWeight <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 } edgeWeight <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 }
......
...@@ -34,12 +34,12 @@ rangeControlCpt = R.hooksComponent "RangeButton" cpt ...@@ -34,12 +34,12 @@ rangeControlCpt = R.hooksComponent "RangeButton" cpt
, RS.rangeSlider sliderProps , RS.rangeSlider sliderProps
] ]
edgeConfluenceControl :: R.Ref Sigmax.Sigma -> R.State Range.NumberRange -> R.Element edgeConfluenceControl :: Range.NumberRange -> R.State Range.NumberRange -> R.Element
edgeConfluenceControl sigmaRef (state /\ setState) = edgeConfluenceControl (Range.Closed { min, max }) (state /\ setState) =
rangeControl { rangeControl {
caption: "Edge Confluence Weight" caption: "Edge Confluence Weight"
, sliderProps: { , sliderProps: {
bounds: Range.Closed { min: 0.0, max: 1.0 } bounds: Range.Closed { min, max }
, initialValue: state , initialValue: state
, epsilon: 0.01 , epsilon: 0.01
, step: 1.0 , step: 1.0
...@@ -49,47 +49,32 @@ edgeConfluenceControl sigmaRef (state /\ setState) = ...@@ -49,47 +49,32 @@ edgeConfluenceControl sigmaRef (state /\ setState) =
} }
} }
edgeWeightControl :: R.Ref Sigmax.Sigma -> R.State Range.NumberRange -> R.Element edgeWeightControl :: Range.NumberRange -> R.State Range.NumberRange -> R.Element
edgeWeightControl sigmaRef (state /\ setState) = edgeWeightControl (Range.Closed { min, max }) (state /\ setState) =
rangeControl { rangeControl {
caption: "Edge Weight" caption: "Edge Weight"
, sliderProps: { , sliderProps: {
bounds: Range.Closed { min: 0.0, max: 3.0 } bounds: Range.Closed { min, max }
, initialValue: state , initialValue: state
, epsilon: 0.01 , epsilon: 0.01
, step: 1.0 , step: 1.0
, width: 10.0 , width: 10.0
, height: 5.0 , height: 5.0
, onChange: setState <<< const , onChange: setState <<< const
-- , onChange: \range@(Range.Closed {min, max}) -> do
-- let sigma = R.readRef sigmaRef
-- Sigmax.dependOnSigma sigma "[edgeWeightControl] sigma: Nothing" $ \s -> do
-- Sigma.setSettings s {
-- minEdgeSize: min
-- , maxEdgeSize: max
-- }
-- setState $ const range
} }
} }
nodeSizeControl :: Range.NumberRange -> R.State Range.NumberRange -> R.Element nodeSizeControl :: Range.NumberRange -> R.State Range.NumberRange -> R.Element
nodeSizeControl (Range.Closed { min: rangeMin, max: rangeMax }) (state /\ setState) = nodeSizeControl (Range.Closed { min, max }) (state /\ setState) =
rangeControl { rangeControl {
caption: "Node Size" caption: "Node Size"
, sliderProps: { , sliderProps: {
bounds: Range.Closed { min: rangeMin, max: rangeMax } bounds: Range.Closed { min, max }
, initialValue: state , initialValue: state
, epsilon: 0.1 , epsilon: 0.1
, step: 1.0 , step: 1.0
, width: 10.0 , width: 10.0
, height: 5.0 , height: 5.0
, onChange: \range@(Range.Closed {min, max}) -> do , onChange: setState <<< const
-- let sigma = R.readRef sigmaRef
-- Sigmax.dependOnSigma sigma "[nodeSizeControl] sigma: Nothing" $ \s -> do
-- Sigma.setSettings s {
-- minNodeSize: min
-- , maxNodeSize: max
-- }
setState $ const range
} }
} }
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