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
f962c84b
Commit
f962c84b
authored
Sep 11, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Charts] factoring Trees.
parent
69858567
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
71 deletions
+80
-71
ECharts.purs
src/Gargantext/Components/Charts/Options/ECharts.purs
+3
-3
Series.purs
src/Gargantext/Components/Charts/Options/Series.purs
+73
-63
Dashboard.purs
src/Gargantext/Pages/Corpus/Doc/Facets/Dashboard.purs
+4
-5
No files found.
src/Gargantext/Components/Charts/Options/ECharts.purs
View file @
f962c84b
...
@@ -11,7 +11,7 @@ import Gargantext.Components.Charts.Options.Data (DataN, DataS, DataV)
...
@@ -11,7 +11,7 @@ import Gargantext.Components.Charts.Options.Data (DataN, DataS, DataV)
import Gargantext.Components.Charts.Options.Font (IconOptions(..), Shape(..), TextStyle, chartFontStyle, chartFontWeight, icon)
import Gargantext.Components.Charts.Options.Font (IconOptions(..), Shape(..), TextStyle, chartFontStyle, chartFontWeight, icon)
import Gargantext.Components.Charts.Options.Legend (legendType, LegendMode(..), PlainOrScroll(..), selectedMode, Orientation(..), orient)
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.Position (Align(..), LeftRelativePosition(..), TopRelativePosition(..), numberPosition, percentPosition, relativePosition)
import Gargantext.Components.Charts.Options.Series (Serie(..), Series(..), toSeries, SeriesName,
SeriesShape
(..), seriesType, D1, D2)
import Gargantext.Components.Charts.Options.Series (Serie(..), Series(..), toSeries, SeriesName,
Chart
(..), seriesType, D1, D2)
import Gargantext.Components.Charts.Options.Type (DataZoom, Echarts, Legend, Option, Title, Tooltip, XAxis, YAxis)
import Gargantext.Components.Charts.Options.Type (DataZoom, Echarts, Legend, Option, Title, Tooltip, XAxis, YAxis)
import React (unsafeCreateElementDynamic)
import React (unsafeCreateElementDynamic)
import React as R
import React as R
...
@@ -157,13 +157,13 @@ tooltip' =
...
@@ -157,13 +157,13 @@ tooltip' =
}
}
series ::
SeriesShape
-> SeriesName -> Array DataS -> D1
series ::
Chart
-> SeriesName -> Array DataS -> D1
series sh name ss = { name: name
series sh name ss = { name: name
, "type": seriesType sh
, "type": seriesType sh
, "data": ss
, "data": ss
}
}
seriesD2 ::
SeriesShape
-> Number -> Array (Array Number) -> D2
seriesD2 ::
Chart
-> Number -> Array (Array Number) -> D2
seriesD2 sh size ds = { "symbolSize" : size
seriesD2 sh size ds = { "symbolSize" : size
, "data" : ds
, "data" : ds
, "type" : seriesType sh
, "type" : seriesType sh
...
...
src/Gargantext/Components/Charts/Options/Series.purs
View file @
f962c84b
...
@@ -11,12 +11,13 @@ newtype SeriesType = SeriesType String
...
@@ -11,12 +11,13 @@ newtype SeriesType = SeriesType String
type SeriesName = String
type SeriesName = String
data SeriesShape = Line
data Chart = Line
| Bar | PictorialBar
| Bar | PictorialBar
| Pie
| Pie
| Scatter | EffectScatter
| Scatter | EffectScatter
| Radar
| Radar
| Tree | Radial | TreeMap
| Trees
| Sunburst
| Sunburst
| Boxplot
| Boxplot
| Candlestick
| Candlestick
...
@@ -29,27 +30,26 @@ data SeriesShape = Line
...
@@ -29,27 +30,26 @@ data SeriesShape = Line
| Funnel
| Funnel
| Gauge
| Gauge
| ThemeRiver
| ThemeRiver
-- Trees
instance show
SeriesShape :: Show SeriesShape
where
instance show
Chart :: Show Chart
where
show Bar = "bar"
show Bar = "bar"
show EffectScatter = "effectScatter" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-effect
show EffectScatter = "effectScatter" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-effect
show Funnel = "funnel"
show Funnel = "funnel"
show Heatmap = "heatmap"
show Heatmap = "heatmap"
show Line = "line"
show Line = "line"
show Pie = "pie"
show Pie = "pie"
show Tree = "tree" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=tree-radial
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"
seriesType ::
SeriesShape
-> SeriesType
seriesType ::
Chart
-> SeriesType
seriesType = SeriesType <<< show
seriesType = SeriesType <<< show
type Series = {}
type Series = {}
data Serie = SeriesD1 D1 | SeriesD2 D2 | SerieSankey Sankey | SerieTree
Map TreeMap | SerieTree
Tree
data Serie = SeriesD1 D1 | SeriesD2 D2 | SerieSankey Sankey | SerieTree Tree
type D1 =
type D1 =
{ name :: String
{ name :: String
...
@@ -68,7 +68,6 @@ toSeries :: Serie -> Series
...
@@ -68,7 +68,6 @@ toSeries :: Serie -> Series
toSeries (SeriesD1 a) = unsafeCoerce a
toSeries (SeriesD1 a) = unsafeCoerce a
toSeries (SeriesD2 a) = unsafeCoerce a
toSeries (SeriesD2 a) = unsafeCoerce a
toSeries (SerieSankey a) = unsafeCoerce a
toSeries (SerieSankey a) = unsafeCoerce a
toSeries (SerieTreeMap a) = unsafeCoerce a
toSeries (SerieTree a) = unsafeCoerce a
toSeries (SerieTree a) = unsafeCoerce a
-- | Sankey Chart
-- | Sankey Chart
...
@@ -86,35 +85,61 @@ type Link = { source :: String
...
@@ -86,35 +85,61 @@ type Link = { source :: String
}
}
mkSankey :: Array Node -> Array Link -> Serie
mkSankey :: Array Node -> Array Link -> Serie
mkSankey ns ls = SerieSankey {
"type"
: seriesType Sankey
mkSankey ns ls = SerieSankey {
"type"
: seriesType Sankey
, layout : "none"
, layout : "none"
, "data" : ns
, "data" : ns
, "links" : ls
, "links" : ls
}
}
-- | TreeMap Chart
-- | * Trees Chart
-- All these Trees are hierarchical Trees structure (or diagram)
-- https://en.wikipedia.org/wiki/Tree_structure
-- Tree types
data Trees = TreeLine | TreeRadial | TreeMap
instance showTrees :: Show Trees where
show TreeLine = "tree" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=tree-radial
show TreeRadial = "tree" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-simple
show TreeMap = "treemap" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-simple
-- TreeLine is a 1-Dimension horizontal hierchical Tree
-- TreeRadial is 1-Dimension radial (as circle) Tree with no surface meaning
-- https://en.wikipedia.org/wiki/Radial_tree
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=tree-radial
-- TreeMap is a is 2-Dimension Tree with surface meaning
-- TreeMap example implementation:
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-simple
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-simple
mkTreeMap :: Array TreeData -> Seri
e
type Tree = { "type" :: SeriesTyp
e
mkTreeMap ts = SerieTreeMap { "type" : seriesType TreeMap
, "data" :: Array TreeData
, "data" : map toTree ts
, layout :: String
}
}
type TreeMap = { "type" :: SeriesType
mkTree :: Trees -> Array TreeData -> Serie
, "data" :: Array TreeData
mkTree t ts = SerieTree { "type" : SeriesType (show t)
, "data" : map toJsTree ts
, layout : layout
}
}
where
layout = case t of
TreeRadial -> "radial"
_ -> "none"
-- ** Data Structure of the Trees
data TreeData = TreeLeaf TreeLeaf
data TreeData = TreeLeaf TreeLeaf
| TreeNode TreeNode
| TreeNode TreeNode
toTree :: TreeData -> TreeData
to
Js
Tree :: TreeData -> TreeData
toTree (TreeLeaf x) = unsafeCoerce x
to
Js
Tree (TreeLeaf x) = unsafeCoerce x
toTree (TreeNode x) = unsafeCoerce { name : x.name
to
Js
Tree (TreeNode x) = unsafeCoerce { name : x.name
, value : x.value
, value : x.value
, children : (map to
Tree x.children)
, children : (map toJs
Tree x.children)
}
}
type TreeNode = { name :: String
type TreeNode = { name :: String
, value :: Number
, value :: Number
, children :: Array TreeData
, children :: Array TreeData
...
@@ -131,21 +156,6 @@ treeLeaf :: String -> Number -> TreeData
...
@@ -131,21 +156,6 @@ treeLeaf :: String -> Number -> TreeData
treeLeaf n v = TreeLeaf { name : n, value : v}
treeLeaf n v = TreeLeaf { name : n, value : v}
-- | Tree
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=tree-radial
type Tree = { "type" :: SeriesType
, "data" :: Array TreeData
, layout :: String
}
mkTree :: Array TreeData -> Serie
mkTree ts = SerieTree { "type" : seriesType Tree
, "data" : map toTree ts
, layout : "radial"
}
-- | TODO
-- | TODO
-- https://ecomfe.github.io/echarts-examples/public/data/asset/data/life-expectancy-table.json
-- https://ecomfe.github.io/echarts-examples/public/data/asset/data/life-expectancy-table.json
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter3D-dataset&gl=1
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter3D-dataset&gl=1
...
...
src/Gargantext/Pages/Corpus/Doc/Facets/Dashboard.purs
View file @
f962c84b
...
@@ -190,7 +190,7 @@ treeMapEx :: Options
...
@@ -190,7 +190,7 @@ treeMapEx :: Options
treeMapEx = Options { mainTitle : ""
treeMapEx = Options { mainTitle : ""
, subTitle : ""
, subTitle : ""
, xAxis : xAxis []
, xAxis : xAxis []
, yAxis : [mkTreeMap treeData]
, yAxis : [mkTree
Tree
Map treeData]
, yAxisFormat : (YAxisFormat { position : ""
, yAxisFormat : (YAxisFormat { position : ""
, visible : false
, visible : false
})
})
...
@@ -199,10 +199,10 @@ treeMapEx = Options { mainTitle : ""
...
@@ -199,10 +199,10 @@ treeMapEx = Options { mainTitle : ""
treeEx :: Options
treeEx :: Options
treeEx = Options { mainTitle : ""
treeEx = Options { mainTitle : "
Tree
"
, subTitle : ""
, subTitle : "
Radial
"
, xAxis : xAxis []
, xAxis : xAxis []
, yAxis : [mkTree treeData']
, yAxis : [mkTree
TreeRadial
treeData']
, yAxisFormat : (YAxisFormat { position : ""
, yAxisFormat : (YAxisFormat { position : ""
, visible : false
, visible : false
})
})
...
@@ -210,6 +210,5 @@ treeEx = Options { mainTitle : ""
...
@@ -210,6 +210,5 @@ treeEx = Options { mainTitle : ""
}
}
layoutDashboard :: forall props. Spec State props Action
layoutDashboard :: forall props. Spec State props Action
layoutDashboard = simpleSpec performAction render
layoutDashboard = simpleSpec performAction render
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