Commit be8634fa authored by Karen Konou's avatar Karen Konou

[Charts] Change event type

parent 368428a1
Pipeline #3399 failed with stage
in 0 seconds
......@@ -13,7 +13,7 @@ import Gargantext.Components.Charts.Options.Font (IconOptions(..), Shape(..), Te
import Gargantext.Components.Charts.Options.Legend (legendType, LegendMode(..), PlainOrScroll(..), selectedMode, Orientation(..), orient)
import Gargantext.Components.Charts.Options.Position (Align(..), LeftRelativePosition(..), TopRelativePosition(..), numberPosition, percentPosition, relativePosition)
import Gargantext.Components.Charts.Options.Series (Series, seriesPieD1)
import Gargantext.Components.Charts.Options.Type (DataZoom, EChartRef, EChartsInstance, Echarts, Legend, MouseEvent, Option, Title, XAxis, YAxis, LegendSelectChangedEvent, xAxis, yAxis)
import Gargantext.Components.Charts.Options.Type (DataZoom, EChartRef, EChartsInstance, Echarts, Legend, MouseEvent, Option, Title, XAxis, YAxis, DataZoomEvent, xAxis, yAxis)
import Gargantext.Utils.Reactix as R2
import React (ReactClass, unsafeCreateElementDynamic)
import Reactix as R
......@@ -46,14 +46,14 @@ chartWith options =
, ref : refListener options
}
where
getEvents (Options { onClick, onLegendChanged }) =
getEvents (Options { onClick, onDataZoom }) =
{ click: listenerFn1 \e -> case onClick of
-- sanitize parsing (see MouseEvent comment)
Just fn -> RX.pick (e :: MouseEvent) # fn
Nothing -> pure unit
, legendselectchanged: listenerFn1 \e -> case onLegendChanged of
Just fn -> fn e
Nothing -> pure unit
, datazoom: listenerFn1 \e -> case onDataZoom of
Just fn -> do fn e
Nothing -> do pure unit
}
refListener (Options { onInit }) = case onInit of
......@@ -186,7 +186,7 @@ data Options = Options
, addZoom :: Boolean
, tooltip :: Tooltip
, onClick :: Maybe (MouseEvent -> Effect Unit)
, onLegendChanged :: Maybe (LegendSelectChangedEvent -> Effect Unit)
, onDataZoom :: Maybe (DataZoomEvent -> Effect Unit)
-- (?) `onInit` custom listener
--
-- * in addition of the already existing `onReady` native listener
......
......@@ -176,7 +176,7 @@ type Rich = {}
-- | https://echarts.apache.org/en/api.html#events
type OnEvents =
{ click :: Effect Unit
, legendselectchanged :: Effect Unit
, datazoom :: Effect Unit
-- ...
}
......@@ -209,10 +209,9 @@ type MouseEvent =
-- | https://echarts.apache.org/en/api.html#events.legendselectchanged
type LegendSelectChangedEvent =
{ type :: String
, name :: String
, selected :: Array String -- ??
type DataZoomEvent =
{ start :: Number
, end :: Number
}
----
......
......@@ -44,12 +44,12 @@ metricsLoadViewCpt = here.component "metricsLoadView" cpt
, session } _ = do
reload' <- T.useLive T.unequal reload
let onLegendChanged = Nothing
let onDataZoom = Nothing
useLoader { errorHandler
, loader: getMetrics session
, path: reload' /\ path
, render: \l -> loaded { boxes, path, reload, session, onClick, onLegendChanged, onInit } l }
, render: \l -> loaded { boxes, path, reload, session, onClick, onDataZoom, onInit } l }
where
errorHandler error = do
T.modify_ (A.cons $ FRESTError { error }) errors
......@@ -81,7 +81,7 @@ metricsWithCacheLoadViewCpt = here.component "metricsWithCacheLoadView" cpt
, reload
, session
, onClick
, onLegendChanged
, onDataZoom
, onInit } _ = do
reload' <- T.useLive T.unequal reload
......@@ -90,5 +90,5 @@ metricsWithCacheLoadViewCpt = here.component "metricsWithCacheLoadView" cpt
, handleResponse
, mkRequest
, path: (reload' /\ path)
, renderer: loaded { boxes, path, reload, session, onClick, onLegendChanged, onInit }
, renderer: loaded { boxes, path, reload, session, onClick, onDataZoom, onInit }
, spinnerClass: Just "echarts-for-react-spinner" }
......@@ -47,7 +47,7 @@ derive newtype instance JSON.WriteForeign HistoMetrics
type Loaded = HistoMetrics
chartOptions :: Record MetricsProps -> HistoMetrics -> Options
chartOptions { onClick, onLegendChanged, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
chartOptions { onClick, onDataZoom, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
{ mainTitle : "Histogram"
, subTitle : "Distribution of publications over time"
, xAxis : xAxis' dates'
......@@ -56,7 +56,7 @@ chartOptions { onClick, onLegendChanged, onInit } (HistoMetrics { dates: dates',
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
, series
, onClick
, onLegendChanged
, onDataZoom
, onInit
}
where
......@@ -96,7 +96,7 @@ histo props = R.createElement histoCpt props []
histoCpt :: R.Component Props
histoCpt = here.component "histo" cpt
where
cpt { boxes, path, session, onClick, onLegendChanged, onInit } _ = do
cpt { boxes, path, session, onClick, onDataZoom, onInit } _ = do
reload <- T.useBox T2.newReload
pure $ metricsWithCacheLoadView
......@@ -109,7 +109,7 @@ histoCpt = here.component "histo" cpt
, reload
, session
, onClick
, onLegendChanged
, onDataZoom
, onInit
}
......
......@@ -55,7 +55,7 @@ derive newtype instance JSON.ReadForeign Metrics
type Loaded = Array Metric
scatterOptions :: Record MetricsProps -> Array Metric -> Options
scatterOptions { onClick, onLegendChanged, onInit } metrics' = Options
scatterOptions { onClick, onDataZoom, onInit } metrics' = Options
{ mainTitle : "Ngrams Selection Metrics"
, subTitle : "Local metrics (Inc/Exc, Spe/Gen), Global metrics (TFICF maillage)"
, xAxis : xAxis { min: -1 }
......@@ -64,7 +64,7 @@ scatterOptions { onClick, onLegendChanged, onInit } metrics' = Options
, addZoom : false
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
, onClick
, onLegendChanged
, onDataZoom
, onInit
}
where
......@@ -109,7 +109,7 @@ metrics props = R.createElement metricsCpt props []
metricsCpt :: R.Component Props
metricsCpt = here.component "etrics" cpt
where
cpt { boxes, onClick, onLegendChanged, onInit, path, session } _ = do
cpt { boxes, onClick, onDataZoom, onInit, path, session } _ = do
reload <- T.useBox T2.newReload
pure $ metricsWithCacheLoadView {
......@@ -122,7 +122,7 @@ metricsCpt = here.component "etrics" cpt
, reload
, session
, onClick
, onLegendChanged
, onDataZoom
, onInit
}
......
......@@ -53,7 +53,7 @@ derive newtype instance JSON.WriteForeign HistoMetrics
type Loaded = HistoMetrics
chartOptionsBar :: Record MetricsProps -> HistoMetrics -> Options
chartOptionsBar { onClick, onLegendChanged, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
chartOptionsBar { onClick, onDataZoom, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
{ mainTitle : "Bar"
, subTitle : "Count of MapTerm"
, xAxis : xAxis' $ map (\t -> joinWith " " $ map (take 3) $ A.take 3 $ filter (\s -> length s > 3) $ split (Pattern " ") t) dates'
......@@ -62,12 +62,12 @@ chartOptionsBar { onClick, onLegendChanged, onInit } (HistoMetrics { dates: date
, addZoom : false
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
, onClick
, onLegendChanged
, onDataZoom
, onInit
}
chartOptionsPie :: Record MetricsProps -> HistoMetrics -> Options
chartOptionsPie { onClick, onLegendChanged, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
chartOptionsPie { onClick, onDataZoom, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
{ mainTitle : "Pie"
, subTitle : "Distribution by MapTerm"
, xAxis : xAxis' []
......@@ -77,7 +77,7 @@ chartOptionsPie { onClick, onLegendChanged, onInit } (HistoMetrics { dates: date
, addZoom : false
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
, onClick
, onLegendChanged
, onDataZoom
, onInit
}
......@@ -103,7 +103,7 @@ pie = R2.leafComponent pieCpt
pieCpt :: R.Component Props
pieCpt = here.component "pie" cpt
where
cpt { boxes, path, session, onClick, onLegendChanged, onInit } _ = do
cpt { boxes, path, session, onClick, onDataZoom, onInit } _ = do
reload <- T.useBox T2.newReload
pure $ metricsWithCacheLoadView
......@@ -116,7 +116,7 @@ pieCpt = here.component "pie" cpt
, reload
, session
, onClick
, onLegendChanged
, onDataZoom
, onInit
}
......@@ -134,7 +134,7 @@ bar props = R.createElement barCpt props []
barCpt :: R.Component Props
barCpt = here.component "bar" cpt
where
cpt { boxes, path, session, onClick, onLegendChanged, onInit} _ = do
cpt { boxes, path, session, onClick, onDataZoom, onInit} _ = do
reload <- T.useBox T2.newReload
pure $ metricsWithCacheLoadView {
......@@ -147,7 +147,7 @@ barCpt = here.component "bar" cpt
, reload
, session
, onClick
, onLegendChanged
, onDataZoom
, onInit
}
......
......@@ -8,7 +8,7 @@ import Data.Ord.Generic (genericCompare)
import Data.Show.Generic (genericShow)
import Effect (Effect)
import Gargantext.Components.App.Store (Boxes)
import Gargantext.Components.Charts.Options.Type (EChartsInstance, MouseEvent, LegendSelectChangedEvent)
import Gargantext.Components.Charts.Options.Type (EChartsInstance, MouseEvent, DataZoomEvent)
import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
import Gargantext.Components.Nodes.Corpus.Chart.Metrics (metrics)
import Gargantext.Components.Nodes.Corpus.Chart.Pie (bar, pie)
......@@ -61,46 +61,46 @@ type Params =
, limit :: Maybe Int
, listId :: Maybe Int
, onClick :: Maybe (MouseEvent -> Effect Unit)
, onLegendChanged :: Maybe (LegendSelectChangedEvent -> Effect Unit)
, onDataZoom :: Maybe (DataZoomEvent -> Effect Unit)
, onInit :: Maybe (EChartsInstance -> Effect Unit)
, session :: Session
)
render :: PredefinedChart -> Record Params -> R.Element
render CDocsHistogram { boxes, corpusId, listId, session, onClick, onLegendChanged, onInit } =
histo { boxes, path, session, onClick, onLegendChanged, onInit }
render CDocsHistogram { boxes, corpusId, listId, session, onClick, onDataZoom, onInit } =
histo { boxes, path, session, onClick, onDataZoom, onInit }
where
path = { corpusId
, listId: fromMaybe 0 listId
, limit: Nothing
, tabType: TabCorpus TabDocs
}
render CAuthorsPie { boxes, corpusId, listId, session, onClick, onLegendChanged, onInit } =
pie { boxes, path, session, onClick, onLegendChanged, onInit }
render CAuthorsPie { boxes, corpusId, listId, session, onClick, onDataZoom, onInit } =
pie { boxes, path, session, onClick, onDataZoom, onInit }
where
path = { corpusId
, listId: fromMaybe 0 listId
, limit: Nothing
, tabType: TabCorpus (TabNgramType $ modeTabType Authors)
}
render CInstitutesTree { boxes, corpusId, limit, listId, session, onClick, onLegendChanged, onInit } =
tree { boxes, path, session, onClick, onLegendChanged, onInit }
render CInstitutesTree { boxes, corpusId, limit, listId, session, onClick, onDataZoom, onInit } =
tree { boxes, path, session, onClick, onDataZoom, onInit }
where
path = { corpusId
, limit
, listId: fromMaybe 0 listId
, tabType: TabCorpus (TabNgramType $ modeTabType Institutes)
}
render CTermsMetrics { boxes, corpusId, limit, listId, session, onClick, onLegendChanged, onInit } =
metrics { boxes, path, session, onClick, onLegendChanged, onInit }
render CTermsMetrics { boxes, corpusId, limit, listId, session, onClick, onDataZoom, onInit } =
metrics { boxes, path, session, onClick, onDataZoom, onInit }
where
path = { corpusId
, limit
, listId: fromMaybe 0 listId
, tabType: TabCorpus (TabNgramType $ modeTabType Terms)
}
render CSourcesBar { boxes, corpusId, limit, listId, session, onClick, onLegendChanged, onInit } =
bar { boxes, path, session, onClick, onLegendChanged, onInit }
render CSourcesBar { boxes, corpusId, limit, listId, session, onClick, onDataZoom, onInit } =
bar { boxes, path, session, onClick, onDataZoom, onInit }
where
path = { corpusId
, limit
......
......@@ -50,7 +50,7 @@ derive newtype instance JSON.WriteForeign Metrics
type Loaded = Array TreeNode
scatterOptions :: Record MetricsProps -> Array TreeNode -> Options
scatterOptions { onClick, onLegendChanged, onInit } nodes = Options
scatterOptions { onClick, onDataZoom, onInit } nodes = Options
{ mainTitle : "Tree"
, subTitle : "Tree Sub Title"
, xAxis : xAxis' []
......@@ -58,7 +58,7 @@ scatterOptions { onClick, onLegendChanged, onInit } nodes = Options
, series : [ mkTree TreeMap nodes]
, addZoom : false
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
, onLegendChanged
, onDataZoom
, onClick
, onInit
-- TODO improve the formatter:
......@@ -88,7 +88,7 @@ tree props = R.createElement treeCpt props []
treeCpt :: R.Component Props
treeCpt = here.component "tree" cpt
where
cpt { boxes, path, session, onClick, onLegendChanged, onInit } _ = do
cpt { boxes, path, session, onClick, onDataZoom, onInit } _ = do
reload <- T.useBox T2.newReload
pure $ metricsWithCacheLoadView
......@@ -101,7 +101,7 @@ treeCpt = here.component "tree" cpt
, reload
, session
, onClick
, onLegendChanged
, onDataZoom
, onInit
}
......
......@@ -4,7 +4,7 @@ import Data.Maybe (Maybe)
import Data.Tuple (Tuple)
import Effect (Effect)
import Gargantext.Components.App.Store (Boxes)
import Gargantext.Components.Charts.Options.Type (EChartsInstance, MouseEvent, LegendSelectChangedEvent)
import Gargantext.Components.Charts.Options.Type (EChartsInstance, MouseEvent, DataZoomEvent)
import Gargantext.Prelude (Unit)
import Gargantext.Sessions (Session)
import Gargantext.Types (TabType)
......@@ -22,7 +22,7 @@ type Props = (
, path :: Record Path
, session :: Session
, onClick :: Maybe (MouseEvent -> Effect Unit)
, onLegendChanged :: Maybe (LegendSelectChangedEvent -> Effect Unit)
, onDataZoom :: Maybe (DataZoomEvent -> Effect Unit)
, onInit :: Maybe (EChartsInstance -> Effect Unit)
)
......
......@@ -264,7 +264,7 @@ renderChartCpt = here.component "renderChart" cpt
, limit: Just 1000
, listId: Just defaultListId
, onClick: Nothing
, onLegendChanged: Nothing
, onDataZoom: Nothing
, onInit: Nothing
, session
}
......
......@@ -226,10 +226,10 @@ ngramsViewCpt' = here.component "ngramsView_clone" cpt where
]
charts params' _ = [ chart params' mode ]
chart path Authors = pie { boxes, path, session, onClick: Nothing, onLegendChanged: Nothing, onInit: Nothing }
chart path Institutes = tree { boxes, path, session, onClick: Nothing, onLegendChanged: Nothing, onInit: Nothing }
chart path Sources = bar { boxes, path, session, onClick: Nothing, onLegendChanged: Nothing, onInit: Nothing }
chart path Terms = metrics { boxes, path, session, onClick: Nothing, onLegendChanged: Nothing, onInit: Nothing }
chart path Authors = pie { boxes, path, session, onClick: Nothing, onDataZoom: Nothing, onInit: Nothing }
chart path Institutes = tree { boxes, path, session, onClick: Nothing, onDataZoom: Nothing, onInit: Nothing }
chart path Sources = bar { boxes, path, session, onClick: Nothing, onDataZoom: Nothing, onInit: Nothing }
chart path Terms = metrics { boxes, path, session, onClick: Nothing, onDataZoom: Nothing, onInit: Nothing }
tabType = TabCorpus (TabNgramType tabNgramType)
......
......@@ -205,7 +205,7 @@ tabsCpt = here.component "tabs" cpt
dispatchAction i { type: "downplay" }
dispatchAction i opts'
onLegendChanged = Just \opts -> do
onDataZoom = Just \opts -> do
log opts
activeTab <- T.useBox 0
......@@ -218,7 +218,7 @@ tabsCpt = here.component "tabs" cpt
, activeTab
, tabs: [
"Documents" /\ R.fragment [
histoRender { boxes, path, onClick, onLegendChanged, onInit, reload: chartReload, session } []
histoRender { boxes, path, onClick, onDataZoom, onInit, reload: chartReload, session } []
, docView' path chartReload TabDocs
]
, "Trash" /\ docView' path chartReload TabTrash
......@@ -255,10 +255,10 @@ histoRender :: R2.Component HistoProps
histoRender = R.createElement histoRenderCpt
histoRenderCpt :: R.Component HistoProps
histoRenderCpt = here.component "histoRender" cpt where
cpt { boxes, path, onClick, onLegendChanged, onInit, reload, session } _ = do
cpt { boxes, path, onClick, onDataZoom, onInit, reload, session } _ = do
_ <- T.useLive T.unequal reload
pure $ histo { boxes, path, onClick, onLegendChanged, onInit, session }
pure $ histo { boxes, path, onClick, onDataZoom, onInit, session }
type DocViewProps a =
( boxes :: Boxes
......
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