jirafs-matplotlib

Render matplotlib charts in your JIRA issues


License
MIT
Install
pip install jirafs-matplotlib==1.0.0

Documentation

Jirafs matplotlib Macro

This Jirafs plugin adds a macro allowing you to easily embed charts generated with Python's Matplotlib chart generation library.

http://coddingtonbear-public.s3.amazonaws.com/github/jirafs-matplotlib/demo_v1.gif

and the comment posted will appear in Jira as:

http://coddingtonbear-public.s3.amazonaws.com/github/jirafs-matplotlib/demo_v1_jira.png

Quickstart

You can enter a digraph into your document by using the matplotlib macro:

<jirafs:matpotlib>
import matplotlib.pyplot as plt
import sys

labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
explode = (0, 0.1, 0, 0)

fig1, ax1 = plt.subplots()
ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
        shadow=True, startangle=90)
ax1.axis('equal')

# Save the figure to stdout instead of just plotting it directly
# for Jirafs
plt.savefig(sys.stdout.buffer)
</jirafs:matplotlib>

or:

<jirafs:matplotlib src="name-of-matplotlib-source.py" />

Upon submission to Jira, a file will automatically be generated, and your markup will be replaced with an embedded image showing your rendered graph.

Options

You can control the type and characteristics of the graph generated by specifying any of the following attributes:

  • src: Use the referenced file for your graph's contents. Note that this cannot be specified if graph contents are specified directly in your tag's contents.
  • python: (Default: python) Path to the Python binary to use for rendering your graph content. Note that you can set a path to the Python binary to use on the global or issue level by setting the configuration key matplotlib.python_bin.

Tips

If you're using the src option and would like to detect when to render a graph into the GUI versus when to render it to sys.stdout.buffer, you can use the presence of the JIRAFS_RENDER environment variable in a manner such as this:

import sys
import os
...
if 'JIRAFS_RENDER' in os.environ:
    pyplot.savefig(sys.stdout.buffer)
else:
    pyplot.plot()

Installation

  1. Install from PIP:

    pip install jirafs-matplotlib
    
  2. Enable for a ticket folder:

    jirafs plugins --enable=matplotlib
    

Note that you can globally enable this (or any) plugin by adding the --global flag to the above command:

jirafs plugins --global --enable=matplotlib

Requirements

  • Matplotlib