is there a way to plot a pie chart with graphviz?

Hi everybody,

i am currently trying to plot a energy flow chart with graphviz.
A pie chart should be proper to describe the energy flow amount, but unfortunately i cannot find this node shape in the built-in liberay, so comes this question.

i've also considered using Record-shaped node to do the job, but is there anyway to define the size of the boxes in the node?

Thanks for your answer in advance!

Regards,
sildea

The question is, Are you

The question is, Are you trying to draw a graph with pie charts as nodes, or just pie charts? If the latter, you probably want to use a different software package, one aimed at statistical visualizations, such as R. If the former, you can use style=wedged with a color list for the fillcolor. See  http://www.graphviz.org/content/attrs#kstyle.

Thanks for your help

Thanks for your help erg.

Yes i want to draw a graph with pie charts as nodes. Each node should describe a unit for energy procession, such as the drivetrain of a vehicle. A node should consist of several ports to describe the power flows (for example, the drivetrain should have the ports to describe power input from combusion engine and from electric engine, it should also have the ports for the power outputs). And the power flows can be drawed as edges pointing to the ports.

 

So comes the question: If i want to use a cell to describe a port, is it possible to control the cell size and direction? Or, how can i make a flow point direct to a relevant port, if i use a elliptically-shaped node and wedged style?

 

Thanks in advance.

You'll need to be a bit more

You'll need to be a bit more specific, or provide a sketch of what you want. What is a cell, and what do you mean by a cell's direction? (I assume once you explain what a cell is, I will understand its size.) More importantly, what is the relation of a cell to a pie chart?

hi erg, thanks for your

hi erg, thanks for your reply.

By "cell" i meant: A pie chart is divided in several parts, and each part is a "cell". This is similar to the relationship between a element and a array.

For example, a hydraulic pump can be imagined as a energy source, it has basically several energy outputs: to work hydraulic component, to traction hydraulic component and energy loss based on leckage. Now i want to draw the pump as a pie chart (node), this pie chart should be divided in 3 parts (correspondent to the energy outputs). When i already have the data about the amount of the 3 energy outputs, i can calculate their percentage in the whole pie chart. What i want to do is to draw a pie chart with the proper division, which means the size of the pie-parts should be correspondent to the percentage of the energy amount.

Specifying the size of the

Specifying the size of the wedges in a pie chart node is straightforward. Suppose you have decided that, for a given node, the three parts have 50%, 10% and 40%, using colors red, green and blue, respectively. Then you would use the attributes:

shape=circle
style=wedged
fillcolor="red;0.5:green;0.1:blue;0.4"

See http://www.graphviz.org/content/attrs#kstyle and http://www.graphviz.org/content/attrs#kcolorList for more details.

You can use the width attribute to specify the diameter. Unfortunately, there is at present no mechanism to attach edges to the cells (wedges) as ports. The simplest approximation would be trying to use compass point ports. It would also be easy to fix this as a post-processing step.

hi erg, thank you for your

hi erg, thank you for your help!

I've thought about drawing a record-shaped node instead of using the pie chart, because it should be easy to attatch edges to the ports. But to describe the energy division (percentage) i have to adjust the size of the ports, and till now i still have no idea how to do that.

Assuming you want vertically

Assuming you want vertically stacked rectangles, give the cells a fixed width and a height proportional to the percentage of energy. For example,

  a [shape=box margin=0 label=
    <<table border="0" cellborder="0" cellpadding="0" cellspacing="0">
      <tr><td bgcolor="red" width="100" height="50"></td></tr>
      <tr><td bgcolor="green" width="100" height="10"></td></tr>
      <tr><td bgcolor="blue" width="100" height="40"></td></tr>
    </table>>]

to represent 50%, 10% and 40%. Of course, you can scale the numbers to whatever you want. Also, this has the width as the sum of the heights, so the final shape is a square. You can have a rectangle instead. Or you can stack the rectangles horizontally, switching the roles of width and height. Or, if you feel there is a natural division of inputs and outputs, you could have a stack of input rectangles on the left and output rectangles on the right.

Each cell can have a port attribute. In addition, you can give each cell text (though be careful the text size isn't too big, or use the fixedsize attribute), or use the tooltip attribute.

hi erg, thanks for your help!

hi erg, thanks for your help! I think i can use the method you gave me to do the job.

Recent comments