Commit da689190 authored by Abinaya Sudhir's avatar Abinaya Sudhir

Default imtbgraph set and legend added

parent 7c145829
...@@ -8,7 +8,7 @@ import Control.Monad.Eff.Console (CONSOLE, log) ...@@ -8,7 +8,7 @@ import Control.Monad.Eff.Console (CONSOLE, log)
import Control.Monad.Eff.Unsafe (unsafePerformEff) import Control.Monad.Eff.Unsafe (unsafePerformEff)
import DOM (DOM) import DOM (DOM)
import Data.Argonaut (decodeJson) import Data.Argonaut (decodeJson)
import Data.Array (length, mapWithIndex, (!!)) import Data.Array (length, mapWithIndex, take, (!!))
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.HTTP.Method (Method(..)) import Data.HTTP.Method (Method(..))
import Data.Int (toNumber) import Data.Int (toNumber)
...@@ -69,9 +69,9 @@ performAction _ _ _ = void do ...@@ -69,9 +69,9 @@ performAction _ _ _ = void do
convert :: GraphData -> SigmaGraphData convert :: GraphData -> SigmaGraphData
convert (GraphData r) = SigmaGraphData { nodes : nodes', edges : edges'} convert (GraphData r) = SigmaGraphData { nodes, edges}
where where
nodes' = mapWithIndex nodeFn r.nodes nodes = mapWithIndex nodeFn r.nodes
nodeFn i (Node n) = nodeFn i (Node n) =
sigmaNode sigmaNode
{ id : n.id_ { id : n.id_
...@@ -83,7 +83,7 @@ convert (GraphData r) = SigmaGraphData { nodes : nodes', edges : edges'} ...@@ -83,7 +83,7 @@ convert (GraphData r) = SigmaGraphData { nodes : nodes', edges : edges'}
} }
where where
cDef (Cluster {clustDefault}) = clustDefault cDef (Cluster {clustDefault}) = clustDefault
edges' = map edgeFn r.edges edges = map edgeFn r.edges
edgeFn (Edge e) = sigmaEdge {id : e.id_, source : e.source, target : e.target} edgeFn (Edge e) = sigmaEdge {id : e.id_, source : e.source, target : e.target}
render :: forall props. Render State props Action render :: forall props. Render State props Action
...@@ -283,7 +283,7 @@ dispLegend :: Array Legend -> ReactElement ...@@ -283,7 +283,7 @@ dispLegend :: Array Legend -> ReactElement
dispLegend ary = div [] $ map dl ary dispLegend ary = div [] $ map dl ary
where where
dl (Legend {id_, label}) = dl (Legend {id_, label}) =
div [] p []
[ span [style {width : 10, height : 10, backgroundColor : intColor id_, display: "inline-block"}] [] [ span [style {width : 10, height : 10, backgroundColor : intColor id_, display: "inline-block"}] []
, text $ " " <> label , text $ " " <> label
] ]
...@@ -400,7 +400,8 @@ specOld = simpleSpec performAction render ...@@ -400,7 +400,8 @@ specOld = simpleSpec performAction render
, edgeShapes {"default" : edgeShape.curve} , edgeShapes {"default" : edgeShape.curve}
] ]
] ]
<>
if length st.legendData > 0 then [div [style {position : "absolute", bottom : "10px", border: "1px solid black", boxShadow : "rgb(0, 0, 0) 0px 2px 6px", marginLeft : "10px", padding: "16px"}] [dispLegend st.legendData]] else []
] ]
, div [className "col-md-3", style {border : "1px black solid", backgroundColor : "beige"}] , div [className "col-md-3", style {border : "1px black solid", backgroundColor : "beige"}]
[ div [className "row"] [ div [className "row"]
...@@ -440,7 +441,7 @@ specOld = simpleSpec performAction render ...@@ -440,7 +441,7 @@ specOld = simpleSpec performAction render
, a [ className "badge badge-light"][text "software engineering"] , a [ className "badge badge-light"][text "software engineering"]
, a [ className "badge badge-light"][text "complex systems"] , a [ className "badge badge-light"][text "complex systems"]
, a [ className "badge badge-light"][text "wireless communications"] , a [ className "badge badge-light"][text "wireless communications"]
, dispLegend st.legendData
] ]
] ]
] ]
......
...@@ -3,7 +3,7 @@ module GraphExplorer.Types where ...@@ -3,7 +3,7 @@ module GraphExplorer.Types where
import Prelude import Prelude
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Array (concat, group, head, length, sort) import Data.Array (concat, group, head, length, sort, take)
import Data.Maybe (fromJust) import Data.Maybe (fromJust)
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.NonEmpty (NonEmpty(..)) import Data.NonEmpty (NonEmpty(..))
...@@ -85,7 +85,7 @@ getLegendData (GraphData {nodes, edges}) = nn ...@@ -85,7 +85,7 @@ getLegendData (GraphData {nodes, edges}) = nn
mp (NonEmpty a ary) = [a] <> (if length ary > 0 then [unsafePartial $ fromJust $ head ary] else []) mp (NonEmpty a ary) = [a] <> (if length ary > 0 then [unsafePartial $ fromJust $ head ary] else [])
n = sort $ map t' nodes n = sort $ map t' nodes
g = group n g = group n
nn = concat $ map mp g nn = take 5 $ concat $ map mp g
t' :: Node -> Legend t' :: Node -> Legend
t' (Node r) = Legend { id_ : clustDefault, label : r.label} t' (Node r) = Legend { id_ : clustDefault, label : r.label}
......
...@@ -646,7 +646,7 @@ dispatchAction dispatcher _ CorpusAnalysis = do ...@@ -646,7 +646,7 @@ dispatchAction dispatcher _ CorpusAnalysis = do
dispatchAction dispatcher _ PGraphExplorer = do dispatchAction dispatcher _ PGraphExplorer = do
_ <- dispatcher $ SetRoute $ PGraphExplorer _ <- dispatcher $ SetRoute $ PGraphExplorer
--_ <- dispatcher $ GraphExplorerA $ GE.NoOp _ <- dispatcher $ GraphExplorerA $ GE.LoadGraph "imtNew.json"
pure unit pure unit
dispatchAction dispatcher _ NGramsTable = do dispatchAction dispatcher _ NGramsTable = do
......
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