Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Prawn::Graph adds straightforward native graph drawing to Prawn without the need to depend on anything else. All generated graphs are pure PDF Vector Images. It results in smaller document sizes and less complication.
Pull request Compare This branch is 22 commits ahead, 6 commits behind HHRy:master.
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Prawn::Graph - Easy Graphing for Prawn

Prawn::Graph copyrighted free software by Ryan Stenhouse with contributions form the community.

It extends Prawn::Core to add the ability for people to natively draw graphs and charts in their PDFs.

Because Prawn::Graph only uses the native PDF drawing functions exposed by Prawn, it removes the need to depend on projects like Gruff to insert graphs in your documents. The results may not be as pretty (yet), but the file-size differences are dramatic.

By default, graphs are drawn in monochrome, as that's likely how they will be printed. You can pass an option to each of the graph methods which will draw them in colour.

Notice! Much like Prawn, this software should be considered to be in early alpha state at best. It's not recommended for use in a production environment unless you're happy to put up with bugs and are willing to help fix them!

Installing & Using through RubyGems

Installing and running prawn-graph is very easy:

  • gem install prawn-graph

Gem version 0.3 is compatible with the latest 0.8 stable release of prawn. If you're still using 0.7, then install version 0.2 of prawn-graph.

Using graphs in your PDF is as straightforward as:

  require 'rubygems'
  require 'prawn/core'
  require 'prawn/graph'

  data = [ ['A', 10], ['B', 11], ['C' 12] ]

  Prawn::Document.generate('test.pdf') do
    test 'Graph Example'
    bar_graph data at => [10,10]


Documentation for Prawn::Graph is available in available at its project page on my website and also on the project's wiki on github.

Using Themes

At the moment, work is underway on implementing 'Themes' within Prawn::Graph, which are hugely inspired by (and are indeed based on the actual themes from) Gruff.

To find the list of available themes, use:


The default theme which will be used for rendering is:


This in-line with the design decision of Prawn::Graph to render in monochrome by default, since most of our users are likely to be printing these documents!

Something went wrong with that request. Please try again.