needpie

New in version 0.5.0.

needpie adds a pie-chart to your documentation.

Example

.. needpie:: My pie chart

   type == 'req'
   type == 'spec'
   10

Result

../_images/need_pie_76ebe.png

If you provide an argument for the needpie, we use it as the title.

Each content line gets interpreted either as static float/int value or as a Filter string. The amount of found needs by the filter string is then used as value.

You can use Filter function with Python codes to define custom filters for needpie.

Options

Example with all options used:

.. needpie:: Requirement status
   :labels: Open, In progress, Closed
   :legend:
   :shadow:
   :explode: 0, 0.3, 0
   :colors: #ffcc00, #444444, limegreen
   :text_color: crimson
   :style: dark_background

   type == 'req' and status == 'open'
   type == 'req' and status == 'in progress'
   type == 'req' and status == 'closed'

Result

../_images/need_pie_1bc0e.png

labels

Use :labels: to set labels for each value.

:labels: must get a comma separated string and the amount of labels must match the amount of values/lines from content.

Example

.. needpie:: Requirement status
   :labels: Open, In progress, Closed

   type == 'req' and status == 'open'
   type == 'req' and status == 'in progress'
   type == 'req' and status == 'closed'

Result

../_images/need_pie_dbfaf.png

legend

You can place a legend on the right side of the pie chart by setting the :legend: flag.

The :legend: flag does not support any values.

Example

.. needpie:: Requirement status
   :labels: Open, In progress, Closed
   :legend:

   type == 'req' and status == 'open'
   type == 'req' and status == 'in progress'
   type == 'req' and status == 'closed'

Result

../_images/need_pie_2c3ed.png

explode

:explode: takes a comma-separated list of floats and defines how much space a specific pie-part moves of from center.

The amount of values for :explode: must match the amount of values / content lines.

Useful values for :explode: are between 0 and 0.3

Example

.. needpie:: Requirement status
   :explode: 0,0.2,0

   type == 'req' and status == 'open'
   type == 'req' and status == 'in progress'
   type == 'req' and status == 'closed'

Result

../_images/need_pie_132a2.png

shadow

:shadow: activates a shadow in the pie chart. It does not support any further values.

Example

.. needpie:: Requirement status
   :explode: 0,0.2,0
   :shadow:

   type == 'req' and status == 'open'
   type == 'req' and status == 'in progress'
   type == 'req' and status == 'closed'

Result

../_images/need_pie_873ef.png

colors

:color: takes a comma separated list of color names and uses them for the pie pieces.

See Matplotlib documentation of supported colors for a complete list of color names.

But besides names, the :colors: option also supports hex-values like #ffcc00.

Example

.. needpie:: Requirement status
   :colors: lightcoral, gold, #555555

   type == 'req' and status == 'open'
   type == 'req' and status == 'in progress'
   type == 'req' and status == 'closed'

Result

../_images/need_pie_88777.png

text_color

:text_color: defines the color for text inside the pie pieces and the labels.

Note

Setting the :text_color: option does not change the legend and title color.

Example

.. needpie:: Requirement status
   :text_color: w

   type == 'req' and status == 'open'
   type == 'req' and status == 'in progress'
   type == 'req' and status == 'closed'

Result

../_images/need_pie_47238.png

style

:style: activates a complete style (colors, font, sizes) for a pie chart. It takes a string, which must match the supported Matplotlib style names.

Useful styles are for example:

  • default

  • classic

  • Solarize_Light2

  • dark_background

  • grayscale

Example

.. needpie:: Requirement status
   :style: Solarize_Light2

   type == 'req' and status == 'open'
   type == 'req' and status == 'in progress'
   type == 'req' and status == 'closed'

Result

../_images/need_pie_df9e6.png

overlapping labels

In the past we had overlapping labels. See following diagram.

Example of a needpie with overlapping labels

Now overlapping labels are removed, and we automatically add a legend with removed information.

Example

.. needpie:: Requirement status
   :labels: New, Open, In progress, Closed, Outdated, Removed

   90
   7
   6
   5
   0
   0

Result

../_images/need_pie_2a651.png