Commit 50b23c48 authored by arturo's avatar arturo

[Docs] Node Docs : blank page

* Issue #312
parent 3293f38a
Pipeline #1627 failed with stage
...@@ -21,8 +21,7 @@ import Unsafe.Coerce (unsafeCoerce) ...@@ -21,8 +21,7 @@ import Unsafe.Coerce (unsafeCoerce)
foreign import eChartsClass :: ReactClass Echarts foreign import eChartsClass :: ReactClass Echarts
foreign import listenerFn1 :: forall evt. (evt -> Effect Unit) -> Effect Unit foreign import listenerFn1 :: forall evt. (evt -> Effect Unit) -> Effect Unit
-- | @XXX some eCharts "actions" not working ("select", ...) -- | https://echarts.apache.org/v4/en/api.html#echartsInstance.dispatchAction
-- | https://echarts.apache.org/en/api.html#echartsInstance.dispatchAction
foreign import dispatchAction :: forall payload. EChartsInstance -> payload -> Effect Unit foreign import dispatchAction :: forall payload. EChartsInstance -> payload -> Effect Unit
chart :: Options -> R.Element chart :: Options -> R.Element
...@@ -59,7 +58,11 @@ chartWith options = ...@@ -59,7 +58,11 @@ chartWith options =
execOnInit fn = toMaybe >>> case _ of execOnInit fn = toMaybe >>> case _ of
Nothing -> pure unit Nothing -> pure unit
Just (ref :: Record EChartRef) -> pure unit -- fn =<< ref.getEchartsInstance -- Just (ref :: Record EChartRef) -> fn =<< ref.getEchartsInstance
-- ^ this line can break for some reasons... (see Issue #312)
Just (ref :: Record EChartRef) -> do
i <- ref.getEchartsInstance
fn i
echarts :: Echarts -> R.Element echarts :: Echarts -> R.Element
echarts c = R2.buff $ unsafeCreateElementDynamic (unsafeCoerce eChartsClass) c [] echarts c = R2.buff $ unsafeCreateElementDynamic (unsafeCoerce eChartsClass) c []
...@@ -190,7 +193,7 @@ data Options = Options ...@@ -190,7 +193,7 @@ data Options = Options
-- it intends to return the `eChartsInstance` used for every -- it intends to return the `eChartsInstance` used for every
-- library actions -- library actions
-- --
-- [1] https://echarts.apache.org/en/api.html#echarts.init -- [1] https://echarts.apache.org/v4/en/api.html#echarts.init
, onInit :: Maybe (EChartsInstance -> Effect Unit) , onInit :: Maybe (EChartsInstance -> Effect Unit)
} }
......
...@@ -216,3 +216,19 @@ type EChartRef = ...@@ -216,3 +216,19 @@ type EChartRef =
( getEchartsInstance :: Effect EChartsInstance ( getEchartsInstance :: Effect EChartsInstance
-- ... -- ...
) )
----
-- | As "dispatchAction" call has a variadic arity, we can dissociate a type
-- | where the cliked item (bar, pie section, etc.) need this dispatchAction
-- | To do so, we have to trimmed its given properties to match this example [1]
-- |
-- | [1] https://echarts.apache.org/en/api.html#action.highlight
type EChartActionData =
( dataIndex :: Int
, name :: String
, seriesId :: Nullable String
, seriesIndex :: Int
, seriesName :: String
, type :: String
)
...@@ -67,7 +67,7 @@ chartOptions { onClick, onInit } (HistoMetrics { dates: dates', count: count'}) ...@@ -67,7 +67,7 @@ chartOptions { onClick, onInit } (HistoMetrics { dates: dates', count: count'})
, emphasis: { itemStyle: itemStyle { color: blue } } , emphasis: { itemStyle: itemStyle { color: blue } }
-- @XXX "select" action not working -- @XXX "select" action not working
-- , selectedMode: selectedMode Single -- , selectedMode: selectedMode Single
, select: { itemStyle: itemStyle { color: green }} -- , select: { itemStyle: itemStyle { color: green }}
} }
series = series =
......
module Gargantext.Components.Nodes.Texts where module Gargantext.Components.Nodes.Texts where
import DOM.Simple.Console (log2) import Gargantext.Prelude
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Data.Symbol (SProxy(..))
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
import Gargantext.Components.Charts.Options.ECharts (dispatchAction) import Gargantext.Components.Charts.Options.ECharts (dispatchAction)
import Gargantext.Components.Charts.Options.Type (EChartsInstance) import Gargantext.Components.Charts.Options.Type (EChartsInstance, EChartActionData)
import Gargantext.Components.DocsTable as DT import Gargantext.Components.DocsTable as DT
import Gargantext.Components.DocsTable.Types (Year) import Gargantext.Components.DocsTable.Types (Year)
import Gargantext.Components.NgramsTable.Loader (clearCache) import Gargantext.Components.NgramsTable.Loader (clearCache)
...@@ -23,13 +23,11 @@ import Gargantext.Components.Tab as Tab ...@@ -23,13 +23,11 @@ import Gargantext.Components.Tab as Tab
import Gargantext.Components.Table as Table import Gargantext.Components.Table as Table
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Sessions (WithSession, Session, getCacheState) import Gargantext.Sessions (WithSession, Session, getCacheState)
import Gargantext.Types (CTabNgramType(..), ListId, NodeID, SidePanelState(..), TabSubType(..), TabType(..)) import Gargantext.Types (CTabNgramType(..), ListId, NodeID, SidePanelState(..), TabSubType(..), TabType(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Record (set)
import Toestand as T import Toestand as T
here :: R2.Here here :: R2.Here
...@@ -170,8 +168,18 @@ tabsCpt = here.component "tabs" cpt ...@@ -170,8 +168,18 @@ tabsCpt = here.component "tabs" cpt
-- @XXX due to lack of support for "echart.select" action, -- @XXX due to lack of support for "echart.select" action,
-- have to manually rely on a set/unset selection -- have to manually rely on a set/unset selection
-- targeting the "echart.emphasis" action -- targeting the "echart.emphasis" action
let
opts' :: Record EChartActionData
opts' =
{ dataIndex : opts.dataIndex
, name : opts.name
, seriesId : opts.seriesId
, seriesIndex : opts.seriesIndex
, seriesName : opts.seriesName
, type : "highlight"
}
dispatchAction i { type: "downplay" } dispatchAction i { type: "downplay" }
dispatchAction i $ set (SProxy :: SProxy "type") "highlight" opts dispatchAction i opts'
activeTab <- T.useBox 0 activeTab <- T.useBox 0
......
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