Commit 955cf506 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[CLEAN] Chart Issue (Sources/Authors) // (Bar/Pie)

parent e4968d06
...@@ -116,11 +116,10 @@ pieCpt = R.hooksComponent "G.C.N.C.C.P.pie" cpt ...@@ -116,11 +116,10 @@ pieCpt = R.hooksComponent "G.C.N.C.C.P.pie" cpt
loadedPie :: Record MetricsProps -> HistoMetrics -> R.Element loadedPie :: Record MetricsProps -> HistoMetrics -> R.Element
loadedPie { path, reload, session } loaded = loadedPie { path, reload, session } loaded =
H.div {} [ H.div {} [ U.reloadButton reload
U.reloadButton reload , U.chartUpdateButton { chartType: ChartPie, path, reload, session }
, U.chartUpdateButton { chartType: ChartPie, path, reload, session } , chart $ chartOptionsPie loaded
, chart $ chartOptionsPie loaded ]
]
bar :: Record Props -> R.Element bar :: Record Props -> R.Element
...@@ -132,15 +131,15 @@ barCpt = R.hooksComponent "LoadedMetricsBar" cpt ...@@ -132,15 +131,15 @@ barCpt = R.hooksComponent "LoadedMetricsBar" cpt
cpt {path, session} _ = do cpt {path, session} _ = do
reload <- R.useState' 0 reload <- R.useState' 0
--pure $ metricsLoadView {getMetrics, loaded: loadedBar, path, reload, session} --pure $ metricsLoadView {getMetrics, loaded: loadedBar, path, reload, session}
pure $ metricsWithCacheLoadView { pure $ metricsWithCacheLoadView
getMetricsHash { getMetricsHash
, handleResponse , handleResponse
, loaded: loadedPie , loaded: loadedPie
, mkRequest: mkRequest session , mkRequest: mkRequest session
, path , path
, reload , reload
, session , session
} }
loadedBar :: Record MetricsProps -> Loaded -> R.Element loadedBar :: Record MetricsProps -> Loaded -> R.Element
loadedBar { path, reload, session } loaded = loadedBar { path, reload, session } loaded =
......
...@@ -8,10 +8,10 @@ import Data.Maybe (Maybe(..), fromMaybe) ...@@ -8,10 +8,10 @@ import Data.Maybe (Maybe(..), fromMaybe)
import Reactix as R import Reactix as R
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo) import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
import Gargantext.Components.Nodes.Corpus.Chart.Metrics (metrics) import Gargantext.Components.Nodes.Corpus.Chart.Metrics (metrics)
import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie) import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie)
import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree) import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (NodeID, Mode(..), TabSubType(..), TabType(..), modeTabType) import Gargantext.Types (NodeID, Mode(..), TabSubType(..), TabType(..), modeTabType)
...@@ -19,8 +19,10 @@ import Gargantext.Types (NodeID, Mode(..), TabSubType(..), TabType(..), modeTabT ...@@ -19,8 +19,10 @@ import Gargantext.Types (NodeID, Mode(..), TabSubType(..), TabType(..), modeTabT
data PredefinedChart = data PredefinedChart =
CDocsHistogram CDocsHistogram
| CAuthorsPie | CAuthorsPie
| CSourcesBar
| CInstitutesTree | CInstitutesTree
| CTermsMetrics | CTermsMetrics
derive instance genericPredefinedChart :: Generic PredefinedChart _ derive instance genericPredefinedChart :: Generic PredefinedChart _
instance showPredefinedChart :: Show PredefinedChart where instance showPredefinedChart :: Show PredefinedChart where
...@@ -42,30 +44,30 @@ instance encodePredefinedChart :: EncodeJson PredefinedChart where ...@@ -42,30 +44,30 @@ instance encodePredefinedChart :: EncodeJson PredefinedChart where
instance readPredefinedChart :: Read PredefinedChart where instance readPredefinedChart :: Read PredefinedChart where
read "CDocsHistogram" = Just CDocsHistogram read "CDocsHistogram" = Just CDocsHistogram
read "CAuthorsPie" = Just CAuthorsPie read "CAuthorsPie" = Just CAuthorsPie
read "CSourcesBar" = Just CSourcesBar
read "CInstitutesTree" = Just CInstitutesTree read "CInstitutesTree" = Just CInstitutesTree
read "CTermsMetrics" = Just CTermsMetrics read "CTermsMetrics" = Just CTermsMetrics
read _ = Nothing read _ = Nothing
allPredefinedCharts :: Array PredefinedChart allPredefinedCharts :: Array PredefinedChart
allPredefinedCharts = [ allPredefinedCharts =
CDocsHistogram [ CDocsHistogram
, CAuthorsPie , CAuthorsPie
, CTermsMetrics , CTermsMetrics
, CInstitutesTree , CInstitutesTree
, CSourcesBar
] ]
type Params = type Params =
( ( corpusId :: NodeID
corpusId :: NodeID , session :: Session
, session :: Session
-- optinal params -- optinal params
, limit :: Maybe Int , limit :: Maybe Int
, listId :: Maybe Int , listId :: Maybe Int
) )
render :: PredefinedChart -> Record Params -> R.Element render :: PredefinedChart -> Record Params -> R.Element
render CDocsHistogram { corpusId, listId, session } = histo { path, session } render CDocsHistogram { corpusId, listId, session } = histo { path, session }
where where
...@@ -93,5 +95,16 @@ render CTermsMetrics { corpusId, limit, listId, session } = metrics { path, sess ...@@ -93,5 +95,16 @@ render CTermsMetrics { corpusId, limit, listId, session } = metrics { path, sess
path = { corpusId path = { corpusId
, limit , limit
, listId: fromMaybe 0 listId , listId: fromMaybe 0 listId
, tabType: TabCorpus (TabNgramType $ modeTabType Authors) , tabType: TabCorpus (TabNgramType $ modeTabType Terms)
} }
render CSourcesBar { corpusId, limit, listId, session } = metrics { path, session }
where
path = { corpusId
, limit
, listId: fromMaybe 0 listId
, tabType: TabCorpus (TabNgramType $ modeTabType Sources)
}
...@@ -18,10 +18,10 @@ import Gargantext.Sessions (Session) ...@@ -18,10 +18,10 @@ import Gargantext.Sessions (Session)
import Gargantext.Types (ChartType(..), CTabNgramType(..), Mode(..), TabSubType(..), TabType(..), chartTypeFromString, modeTabType) import Gargantext.Types (ChartType(..), CTabNgramType(..), Mode(..), TabSubType(..), TabType(..), chartTypeFromString, modeTabType)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
type Props = type Props = ( session :: Session
( session :: Session , corpusId :: Int
, corpusId :: Int , corpusData :: CorpusData
, corpusData :: CorpusData ) )
tabs :: Record Props -> R.Element tabs :: Record Props -> R.Element
tabs props = R.createElement tabsCpt props [] tabs props = R.createElement tabsCpt props []
...@@ -55,27 +55,40 @@ ngramsViewCpt = R.hooksComponent "G.C.N.L.T.ngramsView" cpt ...@@ -55,27 +55,40 @@ ngramsViewCpt = R.hooksComponent "G.C.N.L.T.ngramsView" cpt
pure $ R.fragment pure $ R.fragment
( charts tabNgramType chartType ( charts tabNgramType chartType
<> [ <> [ NT.mainNgramsTable { session
NT.mainNgramsTable , defaultListId
{session, defaultListId, nodeId: corpusId, tabType, tabNgramType, withAutoUpdate: false} , nodeId: corpusId
] , tabType
, tabNgramType
, withAutoUpdate: false
}
]
) )
where where
tabNgramType = modeTabType mode tabNgramType = modeTabType mode
tabType = TabCorpus (TabNgramType tabNgramType) tabType = TabCorpus (TabNgramType tabNgramType)
listId = defaultListId listId = defaultListId
path = {corpusId, listId, tabType, limit: (Just 1000)} path = { corpusId
, listId
, tabType
, limit: Just 1000
}
charts CTabTerms (chartType /\ setChartType) = [ charts CTabTerms (chartType /\ setChartType) = [
H.div { className: "row chart-type-selector" } [ H.div { className: "row chart-type-selector" } [
H.div { className: "col-md-3" } [ H.div { className: "col-md-3" } [
R2.select { className: "form-control" R2.select { className: "form-control"
, on: { change: \e -> setChartType $ const $ fromMaybe Histo $ chartTypeFromString $ R2.unsafeEventValue e } , on: { change: \e -> setChartType
$ const
$ fromMaybe Histo
$ chartTypeFromString
$ R2.unsafeEventValue e
}
, defaultValue: show chartType } [ , defaultValue: show chartType } [
H.option { value: show Histo } [ H.text $ show Histo ] H.option { value: show Histo } [ H.text $ show Histo ]
, H.option { value: show Scatter } [ H.text $ show Scatter ] , H.option { value: show Scatter } [ H.text $ show Scatter ]
, H.option { value: show ChartBar } [ H.text $ show ChartBar ] , H.option { value: show ChartBar } [ H.text $ show ChartBar ]
, H.option { value: show ChartPie } [ H.text $ show ChartPie ]
, H.option { value: show ChartTree } [ H.text $ show ChartTree ] , H.option { value: show ChartTree } [ H.text $ show ChartTree ]
] ]
] ]
...@@ -84,7 +97,7 @@ ngramsViewCpt = R.hooksComponent "G.C.N.L.T.ngramsView" cpt ...@@ -84,7 +97,7 @@ ngramsViewCpt = R.hooksComponent "G.C.N.L.T.ngramsView" cpt
] ]
charts _ _ = [ chart mode ] charts _ _ = [ chart mode ]
chart Authors = pie { session, path } chart Authors = pie { session, path }
chart Sources = bar { session, path } chart Sources = bar { session, path }
chart Institutes = tree { session, path } chart Institutes = tree { session, path }
chart Terms = metrics { session, path } chart Terms = metrics { session, path }
...@@ -119,7 +119,7 @@ sessionPath (R.Tab t i) = sessionPath (R.NodeAPI Node i (showTabType ...@@ -119,7 +119,7 @@ sessionPath (R.Tab t i) = sessionPath (R.NodeAPI Node i (showTabType
sessionPath (R.Children n o l s i) = sessionPath (R.NodeAPI Node i ("children?type=" <> show n <> offsetUrl o <> limitUrl l <> orderUrl s)) sessionPath (R.Children n o l s i) = sessionPath (R.NodeAPI Node i ("children?type=" <> show n <> offsetUrl o <> limitUrl l <> orderUrl s))
sessionPath (R.NodeAPI Phylo pId p) = "phyloscape?nodeId=" <> (show $ fromMaybe 0 pId) <> p sessionPath (R.NodeAPI Phylo pId p) = "phyloscape?nodeId=" <> (show $ fromMaybe 0 pId) <> p
sessionPath (R.RecomputeNgrams nt nId lId) = "node/" <> (show nId) <> "/ngrams/recompute?" <> (defaultList lId) <> "&ngramsType=" <> (show nt) sessionPath (R.RecomputeNgrams nt nId lId) = "node/" <> (show nId) <> "/ngrams/recompute?" <> (defaultList lId) <> "&ngramsType=" <> (show nt)
sessionPath (R.RecomputeListChart ChartBar nt nId lId) = "node/" <> (show nId) <> "/pie?" <> (defaultList lId) <> "&ngramsType=" <> (show nt) sessionPath (R.RecomputeListChart ChartBar nt nId lId) = "node/" <> (show nId) <> "/chart?" <> (defaultList lId) <> "&ngramsType=" <> (show nt)
sessionPath (R.RecomputeListChart ChartPie nt nId lId) = "node/" <> (show nId) <> "/pie?" <> (defaultList lId) <> "&ngramsType=" <> (show nt) sessionPath (R.RecomputeListChart ChartPie nt nId lId) = "node/" <> (show nId) <> "/pie?" <> (defaultList lId) <> "&ngramsType=" <> (show nt)
sessionPath (R.RecomputeListChart ChartTree nt nId lId) = "node/" <> (show nId) <> "/tree?" <> (defaultList lId) <> "&ngramsType=" <> (show nt) <> "&listType=" <> show MapTerm sessionPath (R.RecomputeListChart ChartTree nt nId lId) = "node/" <> (show nId) <> "/tree?" <> (defaultList lId) <> "&ngramsType=" <> (show nt) <> "&listType=" <> show MapTerm
sessionPath (R.RecomputeListChart Histo nt nId lId) = "node/" <> (show nId) <> "/chart?" <> (defaultList lId) <> "&ngramsType=" <> (show nt) sessionPath (R.RecomputeListChart Histo nt nId lId) = "node/" <> (show nId) <> "/chart?" <> (defaultList lId) <> "&ngramsType=" <> (show nt)
......
...@@ -15,8 +15,6 @@ import Prelude ...@@ -15,8 +15,6 @@ import Prelude
import Prim.Row (class Union) import Prim.Row (class Union)
import URI.Query (Query) import URI.Query (Query)
data Handed = LeftHanded | RightHanded data Handed = LeftHanded | RightHanded
derive instance genericHanded :: Generic Handed _ derive instance genericHanded :: Generic Handed _
...@@ -392,10 +390,10 @@ data ChartType = Histo | Scatter | ChartPie | ChartBar | ChartTree ...@@ -392,10 +390,10 @@ data ChartType = Histo | Scatter | ChartPie | ChartBar | ChartTree
instance showChartType :: Show ChartType instance showChartType :: Show ChartType
where where
show Histo = "chart" show Histo = "chart"
show Scatter = "scatter" show Scatter = "scatter"
show ChartBar = "bar" show ChartBar = "bar"
show ChartPie = "pie" show ChartPie = "pie"
show ChartTree = "tree" show ChartTree = "tree"
chartTypeFromString :: String -> Maybe ChartType chartTypeFromString :: String -> Maybe ChartType
...@@ -517,7 +515,7 @@ instance showTabSubType :: Show a => Show (TabSubType a) where ...@@ -517,7 +515,7 @@ instance showTabSubType :: Show a => Show (TabSubType a) where
data TabType data TabType
= TabCorpus (TabSubType CTabNgramType) = TabCorpus (TabSubType CTabNgramType)
| TabPairing (TabSubType PTabNgramType) | TabPairing (TabSubType PTabNgramType)
| TabDocument (TabSubType CTabNgramType) | TabDocument (TabSubType CTabNgramType)
derive instance genericTabType :: Generic TabType _ derive instance genericTabType :: Generic TabType _
derive instance eqTabType :: Eq TabType derive instance eqTabType :: Eq TabType
...@@ -572,11 +570,11 @@ modeTabType Institutes = CTabInstitutes ...@@ -572,11 +570,11 @@ modeTabType Institutes = CTabInstitutes
modeTabType Terms = CTabTerms modeTabType Terms = CTabTerms
modeFromString :: String -> Maybe Mode modeFromString :: String -> Maybe Mode
modeFromString "Authors" = Just Authors modeFromString "Authors" = Just Authors
modeFromString "Sources" = Just Sources modeFromString "Sources" = Just Sources
modeFromString "Institutes" = Just Institutes modeFromString "Institutes" = Just Institutes
modeFromString "Terms" = Just Terms modeFromString "Terms" = Just Terms
modeFromString _ = Nothing modeFromString _ = Nothing
-- Async tasks -- Async tasks
......
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