Quantcast

Three questions to graphviz

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Three questions to graphviz

kaffeepause73
First of all - thanks a lot for this package, graphviz is an awesome tool and having this interface library is really convenient. There a three point where I could use some help:

1. when I try to create a label with e.g.:     textLabelValue "Hallo"  -
the compiler complains he can't match string with data.text.lazy.internal

-- I have idea how to create lazy internal text !

2. I know how to rotate the whole diagram (with landscape or rotate 90), but not how to keep
all the text in unrotated position -- is there a command to do this ?

3. When I create a symmetric tree with two directions on the two sides. The tree gets completely messed up when I enter the right directions. (left graph ok but wrong edge dirs, right graph with correct dirs but gemetry scambled). - It has todo with ranking order which is based on the direction of the edges. I can fake it with reversing the arrows in the diagram, but my original graph data is coming directed ...

Cheers Phil

   
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Three questions to graphviz

David Barbour


On Mon, Oct 10, 2011 at 9:44 AM, kaffeepause73 <[hidden email]> wrote:
First of all - thanks a lot for this package, graphviz is an awesome tool and
having this interface library is really convenient. There a three point
where I could use some help:

1. when I try to create a label with e.g.:     textLabelValue "Hallo"  -
the compiler complains he can't match string with data.text.lazy.internal

-- I have idea how to create lazy internal text !

import qualified Data.Text.Lazy as L
textLabelValue $ L.pack "Hallo"

That's the only question I know how to answer.

Regards,

Dave

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Three questions to graphviz

kaffeepause73
Hi Dave,

Thanks for the quick reply - it works now. - I wasted quite a bit time on this.
I guess the "internal" bit in the compiler message confused me.

Cheers Phil
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Three questions to graphviz

Ketil Malde-5
kaffeepause73 <[hidden email]> writes:

> Thanks for the quick reply - it works now. - I wasted quite a bit time on
> this.

Alternatively, you can turn on overloaded strings, which allows constructing
text values (along with other types that are instances of IsString) from
string constants.  Add

{-# Language OverloadedStrings #-}

at the top of your source file to enable it.

> I guess the "internal" bit in the compiler message confused me.

It is a common idiom to put "internals" -- e.g. data type definitions --
in a module called "Internal".

-k
--
If I haven't seen further, it is by standing in the footprints of giants

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Three questions to graphviz

Ivan Lazar Miljenovic
In reply to this post by kaffeepause73
On 11 October 2011 03:44, kaffeepause73 <[hidden email]> wrote:
> First of all - thanks a lot for this package, graphviz is an awesome tool and
> having this interface library is really convenient. There a three point
> where I could use some help:
>
> 2. I know how to rotate the whole diagram (with landscape or rotate 90), but
> not how to keep
> all the text in unrotated position -- is there a command to do this ?

I don't think this is possible: the rotation seems to be a
post-processing feature done by GraphViz.  If you just want the graph
laid out Left-to-Right rather than Top-to-Bottom, try setting the
RankDir attribute:
http://hackage.haskell.org/packages/archive/graphviz/2999.12.0.3/doc/html/Data-GraphViz-Attributes-Complete.html#v:RankDir

(though I've just noticed that the Ordering attribute should take in a
specific type rather than just Text... *goes off to fix*)

> 3. When I create a symmetric tree with two directions on the two sides. The
> tree gets completely messed up when I enter the right directions. (left
> graph ok but wrong edge dirs, right graph with correct dirs but gemetry
> scambled). - It has todo with ranking order which is based on the direction
> of the edges. I can fake it with reversing the arrows in the diagram, but my
> original graph data is coming directed ...

This means you need to tweak and play around with the settings more.

My approach (and I'm the maintainer of the graphviz library!) for
stuff like this is:

* Get some sample Dot code (either write it by hand or use graphviz to
generate it from your data).

* Look through all the available attributes for ones that might deal
with layout of nodes, edges, etc. at:
http://www.graphviz.org/doc/info/attrs.html

* Try setting them into your Dot code, then use the appropriate
Graphviz command (dot, neato, circo, etc. depending on which layout
you want); consider something like "dot -Txlib test.dot" to get a
preview window up, or "dot -Tpng test.dot > test.png" to get a png
image.

* Once you've found attributes that seem to do what you want, use the
graphviz versions of them in your Haskell code.

Note also that because Graphviz uses automatic layout algorithms, you
can't always get it to output in the way that would make sense if you
drew it by hand.  I've been told that things like phantom nodes
(invisible nodes that you insert with extra edges to force spaces,
alignment, etc.) can help, but I've never looked into using them
enough to work out approaches of how/when to do so.

--
Ivan Lazar Miljenovic
[hidden email]
IvanMiljenovic.wordpress.com

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Three questions to graphviz

kaffeepause73
Hi Ivan,

I already played around a fair bit with options in both cases, but
there are quite a few so it gets quite worky with try and error.

Going to graphviz directly doesn't seem a bad idea.

Thanks Phil
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Three questions to graphviz

Ivan Lazar Miljenovic
On 11 October 2011 17:00, kaffeepause73 <[hidden email]> wrote:
> Hi Ivan,
>
> I already played around a fair bit with options in both cases, but
> there are quite a few so it gets quite worky with try and error.

Definitely.  I've never bothered fully documenting
Data.GraphViz.Attributes.Complete fully solely because there are so
many attributes, and at best I'd just be copy/pasting stuff from the
upstream docs.

As I add more "user-friendly" options to Data.GraphViz.Attributes, I'm
starting to provide more specific comments regarding usage, etc.

Basically: if I find a specific attribute to be useful with some
corner cases or usage tricks where it's useful, I add documentation.
I welcome anyone sending me patches (or even a chunk of text via
email) about specific attributes to help flesh it out.

> Going to graphviz directly doesn't seem a bad idea.

Well, it just takes the middle-man out of the loop.  The upstream
documentation is sometimes a little scarce about what all the
attributes do, and playing around with them usually ends up being more
informative.

--
Ivan Lazar Miljenovic
[hidden email]
IvanMiljenovic.wordpress.com

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Loading...