Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Przemyslaw Kaminski
purescript-gargantext
Commits
ea829efa
Commit
ea829efa
authored
Nov 16, 2021
by
arturo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
>>> continue
parent
869711eb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20205 additions
and
108 deletions
+20205
-108
vaccines_countries_06_2021.json
dist/js/vaccines_countries_06_2021.json
+20152
-0
Phylo.purs
src/Gargantext/Components/Nodes/Corpus/Phylo.purs
+4
-2
Draw.js
src/Gargantext/Components/PhyloExplorer/Draw.js
+1
-34
Draw.purs
src/Gargantext/Components/PhyloExplorer/Draw.purs
+46
-70
Layout.purs
src/Gargantext/Components/PhyloExplorer/Layout.purs
+2
-2
No files found.
dist/js/vaccines_countries_06_2021.json
0 → 100644
View file @
ea829efa
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/Gargantext/Components/Nodes/Corpus/Phylo.purs
View file @
ea829efa
...
@@ -54,9 +54,11 @@ phyloLayoutCpt = here.component "phyloLayout" cpt where
...
@@ -54,9 +54,11 @@ phyloLayoutCpt = here.component "phyloLayout" cpt where
fetchPhyloJSON :: Aff (Either String PhyloDataSet)
fetchPhyloJSON :: Aff (Either String PhyloDataSet)
fetchPhyloJSON =
fetchPhyloJSON =
let
let
-- @WIP remove dumb data
url = "http://localhost:5000/js/knowledge-phylomemy.json"
-- url = "http://localhost:5000/js/vaccines_countries_06_2021.json"
request = AX.defaultRequest
request = AX.defaultRequest
-- @WIP remove dumb data
{ url = url
{ url = "http://localhost:5000/js/knowledge-phylomemy.json"
, method = Left GET
, method = Left GET
, responseFormat = ResponseFormat.string
, responseFormat = ResponseFormat.string
}
}
...
...
src/Gargantext/Components/PhyloExplorer/Draw.js
View file @
ea829efa
exports
.
_drawPhylo
=
drawPhylo
;
exports
.
_drawPhylo
=
drawPhylo
;
exports
.
_
highlightSource
=
highlightSource
;
exports
.
_
drawWordCloud
=
drawWordCloud
;
// set javascript date from a string year
// set javascript date from a string year
function
yearToDate
(
year
)
{
function
yearToDate
(
year
)
{
...
@@ -236,39 +236,6 @@ function findValueByPrefix(prefix) {
...
@@ -236,39 +236,6 @@ function findValueByPrefix(prefix) {
return
null
;
return
null
;
}
}
function
highlightSource
()
{
let
checkSource
=
document
.
getElementById
(
"checkSource"
);
let
value
=
checkSource
.
options
[
checkSource
.
selectedIndex
].
value
;
let
groups
=
d3
.
selectAll
(
".group-inner"
);
if
(
window
.
highlighted
==
true
)
{
(
groups
.
filter
(
".source-focus"
).
nodes
()).
map
(
g
=>
g
.
classList
.
add
(
"group-unfocus"
))
}
// unselected all the groups
(
groups
.
nodes
()).
map
(
g
=>
g
.
classList
.
remove
(
"source-focus"
));
if
(
window
.
ldView
==
true
)
{
(
groups
.
nodes
()).
map
(
function
(
g
){
return
g
.
style
.
fill
=
"#f5eee6"
;});
}
else
{
(
groups
.
nodes
()).
map
(
function
(
g
){
return
g
.
style
.
fill
=
"#fff"
;});
}
d3
.
selectAll
(
".peak"
).
classed
(
"peak-focus-source"
,
false
);
// select the relevant ones
if
(
value
!=
"unselect"
)
{
let
selected
=
groups
.
filter
(
".source-"
+
value
).
nodes
();
drawWordCloud
(
selected
)
selected
.
map
(
function
(
g
){
g
.
classList
.
remove
(
"group-unfocus"
);
g
.
classList
.
add
(
"source-focus"
);
g
.
style
.
fill
=
"#a6bddb"
;
let
bid
=
g
.
getAttribute
(
"bId"
)
d3
.
select
(
"#peak-"
+
bid
)
.
classed
(
"peak-focus-source"
,
true
);
})
}
}
function
drawWordCloud
(
groups
)
{
function
drawWordCloud
(
groups
)
{
let
labels
=
{},
let
labels
=
{},
...
...
src/Gargantext/Components/PhyloExplorer/Draw.purs
View file @
ea829efa
module Gargantext.Components.PhyloExplorer.Draw
module Gargantext.Components.PhyloExplorer.Draw
( drawPhylo
( drawPhylo
, highlightSource
, highlightSource
, highlightSource'
, unhide
, unhide
, setGlobalDependencies, setGlobalD3Reference
, setGlobalDependencies, setGlobalD3Reference
) where
) where
import Gargantext.Prelude
import Gargantext.Prelude
import Control.Monad.Except (runExcept)
import DOM.Simple (Window)
import DOM.Simple (Window)
import DOM.Simple.Console (log, log2)
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Foldable (for_)
import Data.Foldable (for_)
import Data.FoldableWithIndex (forWithIndex_)
import Data.FoldableWithIndex (forWithIndex_)
import Data.Maybe (Maybe(..), maybe)
import Data.Maybe (Maybe(..), maybe)
import Effect (Effect)
import Effect (Effect)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Effect.Ref as Ref
import Effect.Uncurried (EffectFn1, EffectFn7, runEffectFn1, runEffectFn7)
import Effect.Uncurried (EffectFn7, runEffectFn7)
import FFI.Simple (applyTo, getProperty, (..), (.=), (.?))
import FFI.Simple (applyTo, getProperty, getProperty', setProperty, setProperty', (..), (...), (.=), (.?))
import Gargantext.Components.PhyloExplorer.Types (AncestorLink, Branch, BranchLink, GlobalTerm(..), Group(..), Link, Period, PhyloDataSet(..))
import Gargantext.Components.PhyloExplorer.Types (AncestorLink, Branch, BranchLink, GlobalTerm(..), Group(..), Link, Period, PhyloDataSet(..))
import Gargantext.Utils.Reactix (getElementById)
import Gargantext.Utils.Reactix (getElementById)
import Graphics.D3.Base (D3, D3Eff)
import Graphics.D3.Base (D3, D3Eff)
import Graphics.D3.Selection as D3S
import Graphics.D3.Selection as D3S
import Graphics.D3.Util (ffi)
import Graphics.D3.Util (ffi)
import Unsafe.Coerce (unsafeCoerce)
foreign import _drawPhylo :: EffectFn7
foreign import _drawPhylo :: EffectFn7
(Array Branch)
(Array Branch)
...
@@ -48,8 +43,17 @@ drawPhylo ::
...
@@ -48,8 +43,17 @@ drawPhylo ::
-> Effect Unit
-> Effect Unit
drawPhylo = runEffectFn7 _drawPhylo
drawPhylo = runEffectFn7 _drawPhylo
foreign import _drawWordCloud :: forall a. EffectFn1 (Array a) Unit
drawWordCloud :: forall a. Array a -> Effect Unit
drawWordCloud = runEffectFn1 _drawWordCloud
-----------------------------------------------------------
-----------------------------------------------------------
orDie :: forall err a. Maybe a -> err -> Either err a
orDie (Just a) _ = Right a
orDie Nothing err = Left err
-- @XXX: FFI.Simple `(...)` throws error (JavaScript issue)
-- @XXX: FFI.Simple `(...)` throws error (JavaScript issue)
-- need to decompose computation
-- need to decompose computation
--
--
...
@@ -59,20 +63,22 @@ applyTo_ src name args =
...
@@ -59,20 +63,22 @@ applyTo_ src name args =
let fn = getProperty name src
let fn = getProperty name src
in applyTo fn src args
in applyTo fn src args
infixl 4 applyTo_ as ~~
-- @WIP: DOM.Simple lack of "ClassList" module
-- @WIP: DOM.Simple lack of "ClassList" module
addClass :: forall el. el -> Array String -> Effect Unit
addClass :: forall el. el -> Array String -> Effect Unit
addClass el args = pure $
applyTo_ (el .. "classList") "add"
args
addClass el args = pure $
(el .. "classList") ~~ "add" $
args
removeClass :: forall el. el -> Array String -> Effect Unit
removeClass :: forall el. el -> Array String -> Effect Unit
removeClass el args = pure $ applyTo_ (el .. "classList") "remove" args
removeClass el args = pure $ (el .. "classList") ~~ "remove" $ args
-----------------------------------------------------------
foreign import _highlightSource :: Effect Unit
-- @WIP: "Graphics.D3.Selection" lack of "filter" function
-- @WIP: "Graphics.D3.Selection" lack of "nodes" function
selectionFilter :: forall d. String -> D3S.Selection d -> D3Eff (D3S.Selection D3S.Void)
selectionFilter = ffi ["query", "selection", ""] "selection.filter(query)"
highlightSource :: Effect Unit
selectionNodes :: forall d el. D3S.Selection d -> D3Eff (Array el)
highlightSource = _highlightSource
selectionNodes = ffi ["selection", ""] "selection.nodes()"
-----------------------------------------------------------
-----------------------------------------------------------
...
@@ -104,26 +110,24 @@ setGlobalDependencies w (PhyloDataSet o)
...
@@ -104,26 +110,24 @@ setGlobalDependencies w (PhyloDataSet o)
let
let
idx' = show idx
idx' = show idx
val' = show val
val' = show val
-- For each entries in group.foundation array,
in
-- increment consequently the global window.keys array
-- For each entries in group.foundation array,
in case (freq .? val') of
-- increment consequently the global window.keys array
Nothing -> pure $ (freq .= val') 0
case (freq .? val') of
Just v -> pure $ (freq .= val') (v +1)
Nothing -> pure $ (freq .= val') 0
-- For each entries in group.foundation array,
Just v -> pure $ (freq .= val') (v +1)
-- if the global window.terms does not have it in property,
*>
-- append an item to the global window.terms
-- For each entries in group.foundation array,
*> case (terms .? val') of
-- if the global window.terms does not have it in property,
Just _ -> pure unit
-- append an item to the global window.terms
Nothing -> void <<< pure $ (terms .= val') $ GlobalTerm
case (terms .? val') of
{ label: l .. idx'
Just _ -> pure unit
, fdt : val'
Nothing -> void <<< pure $ (terms .= val') $ GlobalTerm
}
{ label: l .. idx'
, fdt : val'
-- @XXX: FFI.Simple `(...)` throws error (JavaScript issue)
}
-- need to decompose computation
void do
pure $ terms ~~ "flat" $ []
new <- pure $ applyTo (terms .. "flat") terms []
pure $ (w .= "terms") new
-- @XXX: prevent PureScript from not injecting D3
-- @XXX: prevent PureScript from not injecting D3
setGlobalD3Reference :: Window -> D3 -> Effect Unit
setGlobalD3Reference :: Window -> D3 -> Effect Unit
...
@@ -146,35 +150,15 @@ unhide name = pure unit
...
@@ -146,35 +150,15 @@ unhide name = pure unit
-----------------------------------------------------------
-----------------------------------------------------------
highlightSource :: Window -> String -> Effect Unit
highlightSource window value =
orDie :: forall err a. Maybe a -> err -> Either err a
orDie (Just a) _ = Right a
orDie Nothing err = Left err
-- @WIP: "Graphics.D3.Selection" lack of "filter" function
-- @WIP: "Graphics.D3.Selection" lack of "nodes" function
selectionFilter :: forall d. String -> D3S.Selection d -> D3Eff (D3S.Selection D3S.Void)
selectionFilter = ffi ["query", "selection", ""] "selection.filter(query)"
selectionNodes :: forall d el. D3S.Selection d -> D3Eff (Array el)
selectionNodes = ffi ["selection", ""] "selection.nodes()"
highlightSource' :: Window -> Effect Unit
highlightSource' window =
let
let
hasHighlight = maybe false identity (window .? "highlighted")
hasHighlight = maybe false identity (window .? "highlighted")
hasLdView = maybe false identity (window .? "ldView")
hasLdView = maybe false identity (window .? "ldView")
-- @WIP
value = "string"
in do
in do
groups <- D3S.rootSelectAll ".group-inner"
groups <- D3S.rootSelectAll ".group-inner"
if hasHighlight
if hasHighlight
then
then
selectionFilter ".source-focus" groups
selectionFilter ".source-focus" groups
...
@@ -204,16 +188,12 @@ highlightSource' window =
...
@@ -204,16 +188,12 @@ highlightSource' window =
if (value == "unselect")
if (value == "unselect")
then
then
pure unit
pure unit
else
else do
selectionFilter (".source-" <> value) groups
arr <- selectionFilter (".source-" <> value) groups
>>= selectionNodes
>>= selectionNodes
>>= flip for_ (selectNodeGroup)
-- @WIP drawWordCloud
pure unit
drawWordCloud arr
for_ arr selectNodeGroup
where
where
...
@@ -223,7 +203,7 @@ highlightSource' window =
...
@@ -223,7 +203,7 @@ highlightSource' window =
pure $ (style .= "fill") hex
pure $ (style .= "fill") hex
selectNodeGroup :: forall el. el ->
D3Eff
Unit
selectNodeGroup :: forall el. el ->
Effect
Unit
selectNodeGroup el = do
selectNodeGroup el = do
removeClass el [ "group-unfocus" ]
removeClass el [ "group-unfocus" ]
addClass el [ "source-focus" ]
addClass el [ "source-focus" ]
...
@@ -234,7 +214,3 @@ highlightSource' window =
...
@@ -234,7 +214,3 @@ highlightSource' window =
void $
void $
D3S.rootSelect ("#peak-" <> bid)
D3S.rootSelect ("#peak-" <> bid)
>>= D3S.classed "peak-focus-source" true
>>= D3S.classed "peak-focus-source" true
drawWordCloud groups = do
labels <- Ref.new ()
src/Gargantext/Components/PhyloExplorer/Layout.purs
View file @
ea829efa
...
@@ -6,7 +6,7 @@ import Gargantext.Prelude
...
@@ -6,7 +6,7 @@ import Gargantext.Prelude
import DOM.Simple (window)
import DOM.Simple (window)
import Data.Array as Array
import Data.Array as Array
import Gargantext.Components.PhyloExplorer.Draw (drawPhylo, highlightSource,
highlightSource',
setGlobalD3Reference, setGlobalDependencies, unhide)
import Gargantext.Components.PhyloExplorer.Draw (drawPhylo, highlightSource, setGlobalD3Reference, setGlobalDependencies, unhide)
import Gargantext.Components.PhyloExplorer.Types (PhyloDataSet(..))
import Gargantext.Components.PhyloExplorer.Types (PhyloDataSet(..))
import Gargantext.Utils (nbsp)
import Gargantext.Utils (nbsp)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
...
@@ -94,7 +94,7 @@ layoutCpt = here.component "layout" cpt where
...
@@ -94,7 +94,7 @@ layoutCpt = here.component "layout" cpt where
{ id: "checkSource"
{ id: "checkSource"
, className: "select-source"
, className: "select-source"
, defaultValue: ""
, defaultValue: ""
, on: { change: \
_ -> highlightSource' window
}
, on: { change: \
e -> highlightSource window e.target.value
}
} $
} $
[
[
H.option
H.option
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment