Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
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
gargantext
gargantext-ihaskell
Commits
34c36d5e
Commit
34c36d5e
authored
Sep 15, 2018
by
Lucas DiCioccio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ihaskell-graphviz to display graphs.
Requires 'Graphviz' installed.
parent
496fbd16
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
165 additions
and
0 deletions
+165
-0
Graphviz.hs
...ll-display/ihaskell-graphviz/IHaskell/Display/Graphviz.hs
+70
-0
LICENSE
ihaskell-display/ihaskell-graphviz/LICENSE
+20
-0
Setup.hs
ihaskell-display/ihaskell-graphviz/Setup.hs
+3
-0
ihaskell-graphviz.cabal
ihaskell-display/ihaskell-graphviz/ihaskell-graphviz.cabal
+66
-0
stack.yaml
ihaskell-display/ihaskell-graphviz/stack.yaml
+5
-0
stack.yaml
stack.yaml
+1
-0
No files found.
ihaskell-display/ihaskell-graphviz/IHaskell/Display/Graphviz.hs
0 → 100644
View file @
34c36d5e
-- | A module to help displaying information using the amazing Graphviz
-- (https://www.graphviz.org/) graph layouts.
--
-- You need to install and have graphviz tools available in your environment.
--
-- Currently only 'dot' is provided as a proof-of-concept. This module may be
-- split in two (a package as an helper to Graphviz command line and this
-- package to provide 'IHaskellDisplay' instances.
--
-- Minimal notebook example:
--
-- @ :extension OverloadedStrings @
-- @ import IHaskell.Display.Graphviz @
-- @ dot LeftToRight "digraph { l -> o; o -> v; v -> e; h -> a ; a -> s; s -> k ; k -> e ; e -> l ; l -> l}" @
module
IHaskell.Display.Graphviz
(
dot
,
RankDir
(
..
)
,
Graphviz
)
where
import
Data.ByteString
(
ByteString
)
import
qualified
Data.ByteString.Char8
as
Char
import
System.Process
(
readProcess
)
import
IHaskell.Display
-- | The body of a Graphviz program.
--
-- e.g. @ graph { a -- b } @
type
GraphvizProgramBody
=
ByteString
-- | Plot direction when laying out with Dot.
data
RankDir
=
LeftToRight
|
TopToBottom
deriving
(
Show
,
Eq
,
Ord
)
-- | Main Graphviz object.
data
Graphviz
=
Dot
!
RankDir
!
ByteString
-- ^ A Graphviz plotted using Dot (only available currently).
-- | Create a 'Graphviz' using 'dot'.
dot
::
RankDir
->
GraphvizProgramBody
->
Graphviz
dot
=
Dot
instance
IHaskellDisplay
Graphviz
where
display
fig
=
do
pngDisp
<-
graphDataPNG
fig
return
$
Display
[
pngDisp
]
rankdirOpt
::
RankDir
->
String
rankdirOpt
LeftToRight
=
"-Grankdir=LR"
rankdirOpt
TopToBottom
=
"-Grankdir=TB"
name
=
"ihaskell-graphviz."
-- Width and height
w
=
300
h
=
300
graphDataPNG
::
Graphviz
->
IO
DisplayData
graphDataPNG
(
Dot
rankdir
dotBody
)
=
do
switchToTmpDir
let
fname
=
name
++
"png"
-- Write the image.
ret
<-
readProcess
"dot"
[
"-Tpng"
,
"-o"
,
fname
,
rankdirOpt
rankdir
]
(
Char
.
unpack
dotBody
)
-- Force strictness on readProcess, read file, and convert to base64.
imgData
<-
seq
(
length
ret
)
$
Char
.
readFile
fname
return
$
png
w
h
$
base64
imgData
ihaskell-display/ihaskell-graphviz/LICENSE
0 → 100644
View file @
34c36d5e
The MIT License (MIT)
Copyright (c) 2013 Lucas DiCioccio
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ihaskell-display/ihaskell-graphviz/Setup.hs
0 → 100644
View file @
34c36d5e
import
Distribution.Simple
main
=
defaultMain
ihaskell-display/ihaskell-graphviz/ihaskell-graphviz.cabal
0 → 100644
View file @
34c36d5e
-- The name of the package.
name: ihaskell-graphviz
-- The package version. See the Haskell package versioning policy (PVP)
-- for standards guiding when and how versions should be incremented.
-- http://www.haskell.org/haskellwiki/Package_versioning_policy
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
version: 0.1.0.0
-- A short (one-line) description of the package.
synopsis: IHaskell display instance for GraphViz (external binary)
-- A longer description of the package.
-- description:
-- URL for the project homepage or repository.
homepage: http://www.github.com/gibiansky/ihaskell
-- The license under which the package is released.
license: MIT
-- The file containing the license text.
license-file: LICENSE
-- The package author(s).
author: Lucas DiCioccio <lucas@dicioccio.fr>
-- An email address to which users can send suggestions, bug reports, and
-- patches.
maintainer: Lucas DiCioccio <lucas@dicioccio.fr>,
Andrew Gibiansky <andrew.gibiansky@gmail.com>
-- A copyright notice.
-- copyright:
category: Development
build-type: Simple
-- Extra files to be distributed with the package, such as examples or a
-- README.
-- extra-source-files:
-- Constraint on the version of Cabal needed to build this package.
cabal-version: >=1.16
library
-- Modules exported by the library.
exposed-modules: IHaskell.Display.Graphviz
-- Modules included in this library but not exported.
-- other-modules:
-- Other library packages from which modules are imported.
build-depends: base >=4.9 && <5,
bytestring,
process,
ihaskell >= 0.6.2
-- Directories containing source files.
-- hs-source-dirs:
-- Base language which the package is written in.
default-language: Haskell2010
ihaskell-display/ihaskell-graphviz/stack.yaml
0 → 100644
View file @
34c36d5e
flags
:
{}
packages
:
-
'
.'
resolver
:
lts-9.21
extra-deps
:
[]
stack.yaml
View file @
34c36d5e
...
...
@@ -10,6 +10,7 @@ packages:
-
./ihaskell-display/ihaskell-charts
-
./ihaskell-display/ihaskell-diagrams
-
./ihaskell-display/ihaskell-gnuplot
-
./ihaskell-display/ihaskell-graphviz
-
./ihaskell-display/ihaskell-hatex
-
./ihaskell-display/ihaskell-juicypixels
-
./ihaskell-display/ihaskell-magic
...
...
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