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
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
bfe80bc1
Commit
bfe80bc1
authored
Apr 10, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX+WIP] Blank + adding Charts files to work with
parent
36abf3ea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
261 additions
and
7 deletions
+261
-7
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+5
-2
Pie.purs
src/Gargantext/Pages/Corpus/Pie.purs
+122
-0
Specs.purs
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
+12
-5
Tree.purs
src/Gargantext/Pages/Corpus/Tree.purs
+122
-0
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
bfe80bc1
...
@@ -303,10 +303,13 @@ renderPage loaderDispatch { totalRecords, dispatch
...
@@ -303,10 +303,13 @@ renderPage loaderDispatch { totalRecords, dispatch
else
else
div [ ][text r.date]
div [ ][text r.date]
, if (toDelete $ DocumentsView r) then
, if (toDelete $ DocumentsView r) then
a [ href (toUrl Front Url_Document (Just r._id)), style {textDecoration : "line-through"}, target "blank"
a [ href (toUrl Front Url_Document (Just r._id))
, style {textDecoration : "line-through"}
, target "_blank"
] [ text r.title ]
] [ text r.title ]
else
else
a [ href (toUrl Front Url_Document (Just r._id)), target "blank" ] [ text r.title ]
a [ href (toUrl Front Url_Document (Just r._id))
, target "_blank" ] [ text r.title ]
, if (toDelete $ DocumentsView r) then
, if (toDelete $ DocumentsView r) then
div [style {textDecoration : "line-through"}] [ text r.source]
div [style {textDecoration : "line-through"}] [ text r.source]
else
else
...
...
src/Gargantext/Pages/Corpus/Pie.purs
0 → 100644
View file @
bfe80bc1
module Gargantext.Pages.Corpus.Pie where
import Data.Array (foldl)
import Data.Tuple (Tuple(..))
import Data.Map as Map
import Data.Map (Map)
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Maybe (Maybe(..), maybe)
import Effect.Aff (Aff)
import Gargantext.Config -- (End(..), Path(..), TabType, toUrl)
import Gargantext.Config.REST (get)
import React (ReactClass, ReactElement, createElement)
import Thermite (Spec, Render, defaultPerformAction, simpleSpec, createClass)
import Gargantext.Prelude
import Gargantext.Types (TermList(..))
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Charts.Options.ECharts
import Gargantext.Components.Charts.Options.Type
import Gargantext.Components.Charts.Options.Series
import Gargantext.Components.Charts.Options.Color
import Gargantext.Components.Charts.Options.Font
import Gargantext.Components.Charts.Options.Data
import Gargantext.Pages.Corpus.Dashboard (distriBySchool)
type Path =
{ corpusId :: Int
, listId :: Int
, tabType :: TabType
, limit :: Maybe Int
}
newtype Metric = Metric
{ label :: String
, x :: Number
, y :: Number
, cat :: TermList
}
instance decodeMetric :: DecodeJson Metric where
decodeJson json = do
obj <- decodeJson json
label <- obj .? "label"
x <- obj .? "x"
y <- obj .? "y"
cat <- obj .? "cat"
pure $ Metric { label, x, y, cat }
newtype Metrics = Metrics
{ "data" :: Array Metric
}
instance decodeMetrics :: DecodeJson Metrics where
decodeJson json = do
obj <- decodeJson json
d <- obj .? "data"
pure $ Metrics { "data": d }
type Loaded = Array Metric
loadedMetricsSpec :: Spec {} (Loader.InnerProps Path Loaded ()) Void
loadedMetricsSpec = simpleSpec defaultPerformAction render
where
render :: Render {} (Loader.InnerProps Path Loaded ()) Void
render dispatch {loaded} {} _ = [chart distriBySchool]
--render dispatch {loaded} {} _ = [chart (scatterOptions loaded)]
scatterOptions :: Array Metric -> Options
scatterOptions metrics = Options
{ mainTitle : "Ngrams Selection Metrics"
, subTitle : "Local metrics (Inc/Exc, Spe/Gen), Global metrics (TFICF maillage)"
, xAxis : xAxis { min: 0 }
, yAxis : yAxis' { position : "", show: true }
, series : map2series $ metric2map metrics
, addZoom : false
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
}
where
metric2map :: Array Metric -> Map TermList (Array Metric)
metric2map ds = Map.fromFoldableWith (<>) $ (\(Metric m) -> Tuple m.cat [Metric m]) <$> ds
--{-
map2series :: Map TermList (Array Metric) -> Array Series
map2series ms = toSeries <$> Map.toUnfoldable ms
where
-- TODO colors are not respected yet
toSeries (Tuple k ms) =
seriesScatterD2 {symbolSize: 5.0} (toSerie color <$> ms)
where
color =
case k of
StopTerm -> red
GraphTerm -> green
CandidateTerm -> grey
toSerie color (Metric {label,x,y}) =
dataSerie { name: label, itemStyle: itemStyle {color}
-- , label: {show: true}
, value: [x,y]
}
--}
getMetrics :: Path -> Aff Loaded
getMetrics {corpusId, listId, limit, tabType} = do
Metrics ms <- get $ toUrl Back (CorpusMetrics {listId, tabType, limit}) $ Just corpusId
pure ms."data"
metricsLoaderClass :: ReactClass (Loader.Props Path Loaded)
metricsLoaderClass = Loader.createLoaderClass "MetricsLoader" getMetrics
metricsLoader :: Loader.Props' Path Loaded -> ReactElement
metricsLoader props = createElement metricsLoaderClass props []
pieSpec :: Spec {} Path Void
pieSpec = simpleSpec defaultPerformAction render
where
render :: Render {} Path Void
render dispatch path {} _ =
[ metricsLoader
{ path
, component: createClass "LoadedMetrics" loadedMetricsSpec (const {})
} ]
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
View file @
bfe80bc1
...
@@ -11,7 +11,10 @@ import Data.Tuple (Tuple(..))
...
@@ -11,7 +11,10 @@ import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Config (CTabNgramType(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config (CTabNgramType(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Pages.Corpus.Tabs.Types (Props)
import Gargantext.Pages.Corpus.Tabs.Types (Props)
import Gargantext.Pages.Corpus.Metrics (metricsSpec)
import Gargantext.Pages.Corpus.Metrics (metricsSpec)
import Gargantext.Pages.Corpus.Pie (pieSpec)
import Gargantext.Pages.Corpus.Tree (treeSpec)
import Gargantext.Pages.Corpus.Dashboard (globalPublis)
import Gargantext.Pages.Corpus.Dashboard (globalPublis)
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable as NT
...
@@ -45,10 +48,10 @@ statefulTabs :: Spec Tab.State Props Tab.Action
...
@@ -45,10 +48,10 @@ statefulTabs :: Spec Tab.State Props Tab.Action
statefulTabs =
statefulTabs =
Tab.tabs identity identity $ fromFoldable
Tab.tabs identity identity $ fromFoldable
[ Tuple "Documents" $ docs
[ Tuple "Documents" $ docs
, Tuple "Authors" $ ngramsViewSpec {mode: Authors}
, Tuple "Authors" $ ngramsViewSpec {mode: Authors
}
, Tuple "Sources" $ ngramsViewSpec {mode: Sources}
, Tuple "Sources" $ ngramsViewSpec {mode: Sources
}
, Tuple "Institutes" $ ngramsViewSpec {mode: Institutes}
, Tuple "Institutes" $ ngramsViewSpec {mode: Institutes}
, Tuple "Terms" $ ngramsViewSpec {mode: Terms}
, Tuple "Terms" $ ngramsViewSpec {mode: Terms
}
, Tuple "Trash" $ trash
, Tuple "Trash" $ trash
]
]
where
where
...
@@ -56,7 +59,7 @@ statefulTabs =
...
@@ -56,7 +59,7 @@ statefulTabs =
chart = ECharts.chart globalPublis
chart = ECharts.chart globalPublis
docs = cmapProps (\{path: nodeId} ->
docs = cmapProps (\{path: nodeId} ->
{nodeId, chart, tabType: TabCorpus TabDocs, totalRecords: 4736}) $
{nodeId, chart
, tabType: TabCorpus TabDocs, totalRecords: 4736}) $
noState DT.docViewSpec
noState DT.docViewSpec
trash = cmapProps (\{path: nodeId} ->
trash = cmapProps (\{path: nodeId} ->
...
@@ -70,10 +73,14 @@ ngramsViewSpec {mode} =
...
@@ -70,10 +73,14 @@ ngramsViewSpec {mode} =
noState (
noState (
cmapProps (\{loaded: {defaultListId}, path: corpusId} ->
cmapProps (\{loaded: {defaultListId}, path: corpusId} ->
{corpusId, listId: defaultListId, tabType, limit: (Just 1000)}) -- TODO limit should be select in the chart by default it is 1000
{corpusId, listId: defaultListId, tabType, limit: (Just 1000)}) -- TODO limit should be select in the chart by default it is 1000
metricsSpec
<>
(chart mode)
<>
cmapProps (\{loaded: {defaultListId}, path, dispatch} ->
cmapProps (\{loaded: {defaultListId}, path, dispatch} ->
{loaded: {defaultListId}, path, dispatch, tabType})
{loaded: {defaultListId}, path, dispatch, tabType})
NT.mainNgramsTableSpec
NT.mainNgramsTableSpec
)
)
where
where
tabType = TabCorpus $ TabNgramType $ modeTabType mode
tabType = TabCorpus $ TabNgramType $ modeTabType mode
chart Authors = pieSpec
chart Sources = pieSpec
chart Institutes = treeSpec
chart Terms = metricsSpec
src/Gargantext/Pages/Corpus/Tree.purs
0 → 100644
View file @
bfe80bc1
module Gargantext.Pages.Corpus.Tree where
import Data.Array (foldl)
import Data.Tuple (Tuple(..))
import Data.Map as Map
import Data.Map (Map)
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Maybe (Maybe(..), maybe)
import Effect.Aff (Aff)
import Gargantext.Config -- (End(..), Path(..), TabType, toUrl)
import Gargantext.Config.REST (get)
import React (ReactClass, ReactElement, createElement)
import Thermite (Spec, Render, defaultPerformAction, simpleSpec, createClass)
import Gargantext.Prelude
import Gargantext.Types (TermList(..))
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Charts.Options.ECharts
import Gargantext.Components.Charts.Options.Type
import Gargantext.Components.Charts.Options.Series
import Gargantext.Components.Charts.Options.Color
import Gargantext.Components.Charts.Options.Font
import Gargantext.Components.Charts.Options.Data
import Gargantext.Pages.Corpus.Dashboard (treeMapEx)
type Path =
{ corpusId :: Int
, listId :: Int
, tabType :: TabType
, limit :: Maybe Int
}
newtype Metric = Metric
{ label :: String
, x :: Number
, y :: Number
, cat :: TermList
}
instance decodeMetric :: DecodeJson Metric where
decodeJson json = do
obj <- decodeJson json
label <- obj .? "label"
x <- obj .? "x"
y <- obj .? "y"
cat <- obj .? "cat"
pure $ Metric { label, x, y, cat }
newtype Metrics = Metrics
{ "data" :: Array Metric
}
instance decodeMetrics :: DecodeJson Metrics where
decodeJson json = do
obj <- decodeJson json
d <- obj .? "data"
pure $ Metrics { "data": d }
type Loaded = Array Metric
loadedMetricsSpec :: Spec {} (Loader.InnerProps Path Loaded ()) Void
loadedMetricsSpec = simpleSpec defaultPerformAction render
where
render :: Render {} (Loader.InnerProps Path Loaded ()) Void
render dispatch {loaded} {} _ = [chart treeMapEx]
--render dispatch {loaded} {} _ = [chart (scatterOptions loaded)]
scatterOptions :: Array Metric -> Options
scatterOptions metrics = Options
{ mainTitle : "Ngrams Selection Metrics"
, subTitle : "Local metrics (Inc/Exc, Spe/Gen), Global metrics (TFICF maillage)"
, xAxis : xAxis { min: 0 }
, yAxis : yAxis' { position : "", show: true }
, series : map2series $ metric2map metrics
, addZoom : false
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
}
where
metric2map :: Array Metric -> Map TermList (Array Metric)
metric2map ds = Map.fromFoldableWith (<>) $ (\(Metric m) -> Tuple m.cat [Metric m]) <$> ds
--{-
map2series :: Map TermList (Array Metric) -> Array Series
map2series ms = toSeries <$> Map.toUnfoldable ms
where
-- TODO colors are not respected yet
toSeries (Tuple k ms) =
seriesScatterD2 {symbolSize: 5.0} (toSerie color <$> ms)
where
color =
case k of
StopTerm -> red
GraphTerm -> green
CandidateTerm -> grey
toSerie color (Metric {label,x,y}) =
dataSerie { name: label, itemStyle: itemStyle {color}
-- , label: {show: true}
, value: [x,y]
}
--}
getMetrics :: Path -> Aff Loaded
getMetrics {corpusId, listId, limit, tabType} = do
Metrics ms <- get $ toUrl Back (CorpusMetrics {listId, tabType, limit}) $ Just corpusId
pure ms."data"
metricsLoaderClass :: ReactClass (Loader.Props Path Loaded)
metricsLoaderClass = Loader.createLoaderClass "MetricsLoader" getMetrics
metricsLoader :: Loader.Props' Path Loaded -> ReactElement
metricsLoader props = createElement metricsLoaderClass props []
treeSpec :: Spec {} Path Void
treeSpec = simpleSpec defaultPerformAction render
where
render :: Render {} Path Void
render dispatch path {} _ =
[ metricsLoader
{ path
, component: createClass "LoadedMetrics" loadedMetricsSpec (const {})
} ]
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