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
15ca83bf
Commit
15ca83bf
authored
Sep 10, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Chart] Simple Sankey.
parent
59f17f4b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
107 deletions
+59
-107
ECharts.purs
src/Gargantext/Components/Charts/Options/ECharts.purs
+2
-0
Series.purs
src/Gargantext/Components/Charts/Options/Series.purs
+31
-104
Type.purs
src/Gargantext/Components/Charts/Options/Type.purs
+2
-2
Dashboard.purs
src/Gargantext/Pages/Corpus/Doc/Facets/Dashboard.purs
+24
-1
No files found.
src/Gargantext/Components/Charts/Options/ECharts.purs
View file @
15ca83bf
...
@@ -113,7 +113,9 @@ data2 = {name: "Favorites", icon: icon $ Shape Circle, textStyle: textStyle'}
...
@@ -113,7 +113,9 @@ data2 = {name: "Favorites", icon: icon $ Shape Circle, textStyle: textStyle'}
data3 :: DataN
data3 :: DataN
data3 = {name: "Test", icon: icon $ Shape Diamond, textStyle: textStyle'}
data3 = {name: "Test", icon: icon $ Shape Diamond, textStyle: textStyle'}
xAxis :: Array String -> XAxis
xAxis :: Array String -> XAxis
xAxis [] = unsafeCoerce {}
xAxis xs = { "data": xData xs
xAxis xs = { "data": xData xs
, "type": "category"
, "type": "category"
, axisTick: {alignWithLabel: true}
, axisTick: {alignWithLabel: true}
...
...
src/Gargantext/Components/Charts/Options/Series.purs
View file @
15ca83bf
module Gargantext.Components.Charts.Options.Series where
module Gargantext.Components.Charts.Options.Series where
import Effect.Exception (error, Error(..))
import Unsafe.Coerce (unsafeCoerce)
import Unsafe.Coerce (unsafeCoerce)
import Prelude
import Prelude
...
@@ -30,22 +31,23 @@ data SeriesShape = Line
...
@@ -30,22 +31,23 @@ data SeriesShape = Line
| ThemeRiver
| ThemeRiver
instance showSeriesShape :: Show SeriesShape where
instance showSeriesShape :: Show SeriesShape where
show Line = "line"
show Bar = "bar"
show Bar = "bar"
show Pie = "pie"
show EffectScatter = "effectScatter" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-effect
show Sunburst = "sunburst"
show Funnel = "funnel"
show Funnel = "funnel"
show Heatmap = "heatmap"
show Heatmap = "heatmap"
show EffectScatter = "effectScatter" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-effect
show Line = "line"
show Pie = "pie"
show Sankey = "sankey"
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 _ = ""
show Sunburst = "sunburst"
show _ = "not implemented yet: should throw error here"
seriesType :: SeriesShape -> SeriesType
seriesType :: SeriesShape -> SeriesType
seriesType = SeriesType <<< show
seriesType = SeriesType <<< show
type Series = {}
type Series = {}
data Serie = SeriesD1 D1 | SeriesD2 D2
data Serie = SeriesD1 D1 | SeriesD2 D2
| SeriesSankey Sankey
type D1 =
type D1 =
{ name :: String
{ name :: String
...
@@ -60,62 +62,32 @@ type D2 =
...
@@ -60,62 +62,32 @@ type D2 =
, "type" :: SeriesType
, "type" :: SeriesType
}
}
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
-- | 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
-- type Sankey = { "type" :: SeriesType
type Sankey = { "type" :: SeriesType
-- , "layout" :: String
, layout :: String
-- ,
, "data" :: Array Node
-- option = {
, "links" :: Array Link
-- series: {
}
-- type: 'sankey',
-- layout:'none',
type Node = { name :: String}
-- data: [{
type Link = { source :: String
-- name: 'a'
, target :: String
-- }, {
, value :: Number
-- name: 'b'
}
-- }, {
-- name: 'a1'
mkSankey :: Array Node -> Array Link -> Sankey
-- }, {
mkSankey ns ls = {"type" : seriesType Sankey
-- name: 'a2'
, layout : "none"
-- }, {
, "data" : ns
-- name: 'b1'
, "links" : ls
-- }, {
}
-- name: 'c'
-- }],
-- links: [{
-- source: 'a',
-- target: 'a1',
-- value: 5
-- }, {
-- source: 'a',
-- target: 'a2',
-- value: 3
-- }, {
-- source: 'b',
-- target: 'b1',
-- value: 8
-- }, {
-- source: 'a',
-- target: 'b1',
-- value: 3
-- }, {
-- source: 'b1',
-- target: 'a1',
-- value: 1
-- }, {
-- source: 'b1',
-- target: 'c',
-- value: 2
-- }]
-- }
-- };
--
--
--https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-simple
--https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-simple
...
@@ -160,48 +132,3 @@ toSeries (SeriesD2 a) = unsafeCoerce a
...
@@ -160,48 +132,3 @@ toSeries (SeriesD2 a) = unsafeCoerce a
src/Gargantext/Components/Charts/Options/Type.purs
View file @
15ca83bf
...
@@ -15,8 +15,8 @@ newtype ChartAlign = ChartAlign String
...
@@ -15,8 +15,8 @@ newtype ChartAlign = ChartAlign String
type Echarts =
type Echarts =
{ className :: Maybe String
{ className :: Maybe String
,
style :: Maybe String -- objealect-black-altdarkmincnaquadahherry-blossomect,
, style :: Maybe String -- objealect-black-altdarkmincnaquadahherry-blossomect,
,
theme :: Maybe String
, theme :: Maybe String
, group :: Maybe String
, group :: Maybe String
, option :: Option -- PropTypes.object.isRequired,
, option :: Option -- PropTypes.object.isRequired,
, initOpts :: Maybe String -- PropTypes.object,
, initOpts :: Maybe String -- PropTypes.object,
...
...
src/Gargantext/Pages/Corpus/Doc/Facets/Dashboard.purs
View file @
15ca83bf
...
@@ -34,6 +34,7 @@ render dispatch _ state _ = [
...
@@ -34,6 +34,7 @@ render dispatch _ state _ = [
[ "Télécom Bretagne", "Mines Nantes", "Eurecom"]
[ "Télécom Bretagne", "Mines Nantes", "Eurecom"]
)
)
, chart scatterEx
, chart scatterEx
, chart sankeyEx
]
]
where
where
myData = [SeriesD1 $ series Bar "Bar Data" [ {name: "val1", value: 50.0}
myData = [SeriesD1 $ series Bar "Bar Data" [ {name: "val1", value: 50.0}
...
@@ -109,7 +110,10 @@ scatterEx :: Options
...
@@ -109,7 +110,10 @@ scatterEx :: Options
scatterEx = Options { mainTitle : "Scatter test"
scatterEx = Options { mainTitle : "Scatter test"
, subTitle : "Scatter subtitle"
, subTitle : "Scatter subtitle"
, xAxis : xAxis []
, xAxis : xAxis []
, yAxis : [ SeriesD2 $ seriesD2 Scatter 20.0 [[2.0,3.0],[3.0,4.0]]]
, yAxis : [ SeriesD2 $ seriesD2 Scatter 10.0 [[2.0,3.0],[3.0,4.0]]
, SeriesD2 $ seriesD2 Scatter 5.0 [[1.0,3.0],[5.0,4.0]]
, SeriesD2 $ seriesD2 Scatter 10.0 [[10.0,3.0],[8.0,4.0]]
]
, yAxisFormat : (YAxisFormat { position : ""
, yAxisFormat : (YAxisFormat { position : ""
, visible : true
, visible : true
})
})
...
@@ -117,5 +121,24 @@ scatterEx = Options { mainTitle : "Scatter test"
...
@@ -117,5 +121,24 @@ scatterEx = Options { mainTitle : "Scatter test"
}
}
sankeyEx :: Options
sankeyEx = Options { mainTitle : "Sankey"
, subTitle : "Sankey subtitle"
, xAxis : xAxis []
, yAxis : [ SeriesSankey $ mkSankey [{name : "a"}, {name : "b"}, {name:"c"}]
[{source : "a", target : "b", value :2.0}
, {source : "a", target : "c", value :1.0}
]
]
, yAxisFormat : (YAxisFormat { position : ""
, visible : true
})
, addZoom : false
}
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