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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
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
...
@@ -23,6 +23,10 @@ foreign import eChartsClass :: R.ReactClass Echarts
chart :: Options -> R.ReactElement
chart :: Options -> R.ReactElement
chart = echarts <<< chartWith <<< opts
chart = echarts <<< chartWith <<< opts
chart' :: Options -> R.ReactElement
chart' = echarts <<< chartWith <<< opts'
chartWith :: Option -> Echarts
chartWith :: Option -> Echarts
chartWith opts = { className : Nothing
chartWith opts = { className : Nothing
, style : Nothing
, style : Nothing
...
@@ -115,7 +119,7 @@ data3 = {name: "Test", icon: icon $ Shape Diamond, textStyle: textStyle'}
...
@@ -115,7 +119,7 @@ data3 = {name: "Test", icon: icon $ Shape Diamond, textStyle: textStyle'}
xAxis :: Array String -> XAxis
xAxis :: Array String -> XAxis
--
xAxis [] = unsafeCoerce {}
xAxis [] = unsafeCoerce {}
xAxis xs = { "data": xData xs
xAxis xs = { "data": xData xs
, "type": "category"
, "type": "category"
, axisTick: {alignWithLabel: true}
, axisTick: {alignWithLabel: true}
...
@@ -211,6 +215,32 @@ opts (Options { mainTitle : mainTitle
...
@@ -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
data Zoom = Slider | Inside
instance showZoom :: Show Zoom where
instance showZoom :: Show Zoom where
...
...
src/Gargantext/Components/Charts/Options/Series.purs
View file @
3a403771
...
@@ -38,6 +38,7 @@ instance showSeriesShape :: Show SeriesShape where
...
@@ -38,6 +38,7 @@ instance showSeriesShape :: Show SeriesShape where
show Line = "line"
show Line = "line"
show Pie = "pie"
show Pie = "pie"
show Sankey = "sankey"
show Sankey = "sankey"
show TreeMap = "treemap"
show Scatter = "scatter" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-simple
show Scatter = "scatter" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-simple
show Sunburst = "sunburst"
show Sunburst = "sunburst"
show _ = "not implemented yet: should throw error here"
show _ = "not implemented yet: should throw error here"
...
@@ -47,7 +48,7 @@ seriesType = SeriesType <<< show
...
@@ -47,7 +48,7 @@ seriesType = SeriesType <<< show
type Series = {}
type Series = {}
data Serie = SeriesD1 D1 | SeriesD2 D2 | Serie
sSankey Sankey
data Serie = SeriesD1 D1 | SeriesD2 D2 | Serie
Sankey Sankey | SerieTreeMap TreeMap
type D1 =
type D1 =
{ name :: String
{ name :: String
...
@@ -65,7 +66,8 @@ type D2 =
...
@@ -65,7 +66,8 @@ type D2 =
toSeries :: Serie -> Series
toSeries :: Serie -> Series
toSeries (SeriesD1 a) = unsafeCoerce a
toSeries (SeriesD1 a) = unsafeCoerce a
toSeries (SeriesD2 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
-- | Sankey Chart
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=sankey-simple
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=sankey-simple
...
@@ -82,45 +84,49 @@ type Link = { source :: String
...
@@ -82,45 +84,49 @@ type Link = { source :: String
}
}
mkSankey :: Array Node -> Array Link -> Serie
mkSankey :: Array Node -> Array Link -> Serie
mkSankey ns ls = Serie
s
Sankey {"type" : seriesType Sankey
mkSankey ns ls = SerieSankey {"type" : seriesType Sankey
, layout : "none"
, layout : "none"
, "data" : ns
, "data" : ns
, "links" : ls
, "links" : ls
}
}
-- | TreeMap Chart
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-simple
--
mkTreeMap :: Array TreeMapTree -> Serie
--https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-simple
mkTreeMap ts = SerieTreeMap { "type" : seriesType TreeMap
--
, "data" : map toTreeMap ts
--option = {
}
-- series: [{
-- type: 'treemap',
type TreeMap = { "type" :: SeriesType
-- data: [{
, "data" :: Array TreeMapTree
-- name: 'nodeA', // First tree
}
-- value: 10,
-- children: [{
data TreeMapTree = TreeMapLeaf TreeMapLeaf
-- name: 'nodeAa', // First leaf of first tree
| TreeMapNode TreeMapNode
-- value: 4
-- }, {
toTreeMap :: TreeMapTree -> TreeMapTree
-- name: 'nodeAb', // Second leaf of first tree
toTreeMap (TreeMapLeaf x) = unsafeCoerce x
-- value: 6
toTreeMap (TreeMapNode x) = unsafeCoerce { name : x.name
-- }]
, value : x.value
-- }, {
, children : (map toTreeMap x.children)
-- name: 'nodeB', // Second tree
}
-- value: 20,
-- children: [{
-- name: 'nodeBa', // Son of first tree
type TreeMapNode = { name :: String
-- value: 20,
, value :: Number
-- children: [{
, children :: Array TreeMapTree
-- name: 'nodeBa1', // Granson of first tree
}
-- value: 20
-- }]
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
-- 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 _ = [
...
@@ -35,6 +35,7 @@ render dispatch _ state _ = [
)
)
, chart scatterEx
, chart scatterEx
, chart sankeyEx
, chart sankeyEx
, chart' treeMapEx
]
]
where
where
myData = [SeriesD1 $ series Bar "Bar Data" [ {name: "val1", value: 50.0}
myData = [SeriesD1 $ series Bar "Bar Data" [ {name: "val1", value: 50.0}
...
@@ -139,6 +140,26 @@ sankeyEx = Options { mainTitle : ""
...
@@ -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
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