Commit 4ce9a312 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch '312-dev-merge-docs-blank-page' of...

Merge branch '312-dev-merge-docs-blank-page' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents c09d8e92 50b23c48
......@@ -21,8 +21,7 @@ import Unsafe.Coerce (unsafeCoerce)
foreign import eChartsClass :: ReactClass Echarts
foreign import listenerFn1 :: forall evt. (evt -> Effect Unit) -> Effect Unit
-- | @XXX some eCharts "actions" not working ("select", ...)
-- | https://echarts.apache.org/en/api.html#echartsInstance.dispatchAction
-- | https://echarts.apache.org/v4/en/api.html#echartsInstance.dispatchAction
foreign import dispatchAction :: forall payload. EChartsInstance -> payload -> Effect Unit
chart :: Options -> R.Element
......@@ -59,7 +58,11 @@ chartWith options =
execOnInit fn = toMaybe >>> case _ of
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 c = R2.buff $ unsafeCreateElementDynamic (unsafeCoerce eChartsClass) c []
......@@ -190,7 +193,7 @@ data Options = Options
-- it intends to return the `eChartsInstance` used for every
-- 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)
}
......
......@@ -216,3 +216,19 @@ type EChartRef =
( 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'})
, emphasis: { itemStyle: itemStyle { color: blue } }
-- @XXX "select" action not working
-- , selectedMode: selectedMode Single
, select: { itemStyle: itemStyle { color: green }}
-- , select: { itemStyle: itemStyle { color: green }}
}
series =
......
module Gargantext.Components.Nodes.Texts where
import DOM.Simple.Console (log2)
import Gargantext.Prelude
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow)
import Data.Symbol (SProxy(..))
import Data.Tuple.Nested ((/\))
import Effect.Aff (launchAff_)
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.Types (Year)
import Gargantext.Components.NgramsTable.Loader (clearCache)
......@@ -23,13 +23,11 @@ import Gargantext.Components.Tab as Tab
import Gargantext.Components.Table as Table
import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Sessions (WithSession, Session, getCacheState)
import Gargantext.Types (CTabNgramType(..), ListId, NodeID, SidePanelState(..), TabSubType(..), TabType(..))
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Record (set)
import Toestand as T
here :: R2.Here
......@@ -170,8 +168,18 @@ tabsCpt = here.component "tabs" cpt
-- @XXX due to lack of support for "echart.select" action,
-- have to manually rely on a set/unset selection
-- 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 $ set (SProxy :: SProxy "type") "highlight" opts
dispatchAction i opts'
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