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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
3a403771
Commit
3a403771
authored
Sep 10, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Chart] TreeMap added (need to fixe rest of Echarts functions for axis for instance).
parent
f0ce010f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
38 deletions
+95
-38
ECharts.purs
src/Gargantext/Components/Charts/Options/ECharts.purs
+31
-1
Series.purs
src/Gargantext/Components/Charts/Options/Series.purs
+43
-37
Dashboard.purs
src/Gargantext/Pages/Corpus/Doc/Facets/Dashboard.purs
+21
-0
No files found.
src/Gargantext/Components/Charts/Options/ECharts.purs
View file @
3a403771
...
...
@@ -23,6 +23,10 @@ foreign import eChartsClass :: R.ReactClass Echarts
chart :: Options -> R.ReactElement
chart = echarts <<< chartWith <<< opts
chart' :: Options -> R.ReactElement
chart' = echarts <<< chartWith <<< opts'
chartWith :: Option -> Echarts
chartWith opts = { className : Nothing
, style : Nothing
...
...
@@ -115,7 +119,7 @@ data3 = {name: "Test", icon: icon $ Shape Diamond, textStyle: textStyle'}
xAxis :: Array String -> XAxis
--
xAxis [] = unsafeCoerce {}
xAxis [] = unsafeCoerce {}
xAxis xs = { "data": xData xs
, "type": "category"
, axisTick: {alignWithLabel: true}
...
...
@@ -211,6 +215,32 @@ opts (Options { mainTitle : mainTitle
}
opts' :: Options -> Option
opts' (Options { mainTitle : mainTitle
, subTitle : subTitle
, xAxis : xs
, yAxis : ss
, yAxisFormat : (YAxisFormat { position : position
, visible : visible
})
, addZoom : addZoom}) =
{ title: title mainTitle subTitle
, legend : legend
, tooltip: { trigger: "axis"
, formatter: Nothing
}
, grid : {containLabel: false}
, xAxis : unsafeCoerce {}
, series : map toSeries $ ss
, yAxis : unsafeCoerce {}
, dataZoom: if addZoom then [zoom Slider, zoom Inside] else []
, children : unsafeCoerce []
}
data Zoom = Slider | Inside
instance showZoom :: Show Zoom where
...
...
src/Gargantext/Components/Charts/Options/Series.purs
View file @
3a403771
...
...
@@ -38,6 +38,7 @@ instance showSeriesShape :: Show SeriesShape where
show Line = "line"
show Pie = "pie"
show Sankey = "sankey"
show TreeMap = "treemap"
show Scatter = "scatter" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-simple
show Sunburst = "sunburst"
show _ = "not implemented yet: should throw error here"
...
...
@@ -47,7 +48,7 @@ seriesType = SeriesType <<< show
type Series = {}
data Serie = SeriesD1 D1 | SeriesD2 D2 | Serie
sSankey Sankey
data Serie = SeriesD1 D1 | SeriesD2 D2 | Serie
Sankey Sankey | SerieTreeMap TreeMap
type D1 =
{ name :: String
...
...
@@ -65,7 +66,8 @@ type D2 =
toSeries :: Serie -> Series
toSeries (SeriesD1 a) = unsafeCoerce a
toSeries (SeriesD2 a) = unsafeCoerce a
toSeries (SeriesSankey a) = unsafeCoerce a
toSeries (SerieSankey a) = unsafeCoerce a
toSeries (SerieTreeMap a) = unsafeCoerce a
-- | Sankey Chart
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=sankey-simple
...
...
@@ -82,45 +84,49 @@ type Link = { source :: String
}
mkSankey :: Array Node -> Array Link -> Serie
mkSankey ns ls = Serie
s
Sankey {"type" : seriesType Sankey
mkSankey ns ls = SerieSankey {"type" : seriesType Sankey
, layout : "none"
, "data" : ns
, "links" : ls
}
-- | TreeMap Chart
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-simple
--
--https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-simple
--
--option = {
-- series: [{
-- type: 'treemap',
-- data: [{
-- name: 'nodeA', // First tree
-- value: 10,
-- children: [{
-- name: 'nodeAa', // First leaf of first tree
-- value: 4
-- }, {
-- name: 'nodeAb', // Second leaf of first tree
-- value: 6
-- }]
-- }, {
-- name: 'nodeB', // Second tree
-- value: 20,
-- children: [{
-- name: 'nodeBa', // Son of first tree
-- value: 20,
-- children: [{
-- name: 'nodeBa1', // Granson of first tree
-- value: 20
-- }]
-- }]
-- }]
-- }]
--};
--
--
mkTreeMap :: Array TreeMapTree -> Serie
mkTreeMap ts = SerieTreeMap { "type" : seriesType TreeMap
, "data" : map toTreeMap ts
}
type TreeMap = { "type" :: SeriesType
, "data" :: Array TreeMapTree
}
data TreeMapTree = TreeMapLeaf TreeMapLeaf
| TreeMapNode TreeMapNode
toTreeMap :: TreeMapTree -> TreeMapTree
toTreeMap (TreeMapLeaf x) = unsafeCoerce x
toTreeMap (TreeMapNode x) = unsafeCoerce { name : x.name
, value : x.value
, children : (map toTreeMap x.children)
}
type TreeMapNode = { name :: String
, value :: Number
, children :: Array TreeMapTree
}
type TreeMapLeaf = { name :: String
, value :: Number
}
treeMapNode :: String -> Number -> Array TreeMapTree -> TreeMapTree
treeMapNode n v ts = TreeMapNode {name : n, value:v, children:ts}
treeMapLeaf :: String -> Number -> TreeMapTree
treeMapLeaf n v = TreeMapLeaf { name : n, value : v}
-- https://ecomfe.github.io/echarts-examples/public/data/asset/data/flare.json
...
...
src/Gargantext/Pages/Corpus/Doc/Facets/Dashboard.purs
View file @
3a403771
...
...
@@ -35,6 +35,7 @@ render dispatch _ state _ = [
)
, chart scatterEx
, chart sankeyEx
, chart' treeMapEx
]
where
myData = [SeriesD1 $ series Bar "Bar Data" [ {name: "val1", value: 50.0}
...
...
@@ -139,6 +140,26 @@ sankeyEx = Options { mainTitle : ""
}
treeMapData = [ mkTreeMap [ treeMapNode "nodeA" 10.0 [ treeMapLeaf "nodeAa" 4.0
, treeMapLeaf "nodeAb" 5.0
, treeMapLeaf "nodeAc" 1.0
]
, treeMapNode "nodeB" 20.0 [ treeMapNode "nodeBb" 20.0 [treeMapLeaf "nodeBb1" 20.0]
]
]
]
treeMapEx :: Options
treeMapEx = Options { mainTitle : ""
, subTitle : ""
, xAxis : xAxis []
, yAxis : treeMapData
, yAxisFormat : (YAxisFormat { position : ""
, visible : false
})
, addZoom : false
}
layoutDashboard :: forall props. Spec State props Action
...
...
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