Version 13 (modified by rjollos, 4 years ago) (diff)

Added links to related plugins

Display ticket statistics charts


Make various types of charts regarding the number of tickets using Open Flash Charts. Chart types:

  • Pie charts.
  • Bar charts.
  • Stacked bar charts.

The charts are created by the parameters that you give to the macro. See the examples below.

All charts are clickable (see requirements) and will link to the query page of the graph.

See also TracTicketStatsPlugin, TracMetrixPlugin, TicketStatsMacro.

Bugs/Feature Requests

Existing bugs and feature requests for TicketChartsMacro are here.

If you have any issues, create a new ticket.


Download the zipped source from here.


You can check out TicketChartsMacro from here using Subversion, or browse the source with Trac.


  • Python 2.5 or above. For Python 2.4, see the instructions in #5225.
  • Open Flash Charts installed on your server
    • OFCDZ has more experimental features which get merged back to the main OFC project once in a while. For example clickable charts come from here.
    • "Installing" in this case means:
      • making accessible to web clients OFC's js and js/json as well as the top-level Flash file (open-flash-chart.swf or OFCDZ.swf)
      • Deploying python-ofc-library-2/openFlashChart*.py somewhere Python will find them
  • Advanced Argument Parser for Trac Macros (AdvParseArgsPlugin).
  • Tested only on Trac 0.11.3.
  • Tested only on Apache configuration, but with proper configuration (see configuration section) this should work with any http server (including tracd).


  • Download the source.
  • Copy the file to your project's plugins directory or to the global plugins directory, which is usually in:
  • Enable TicketCharts plugin via the WebAdmin interface or by adding the following lines to the [components] section of trac.ini:
    ticketcharts.* = enabled
  • Install Open Flash Charts 2 and its version 2 python bindings (everything can be downloaded from Open Flash Charts).


  • The following configuration should appear in trac.ini:
    height = 300
    width = 500
    js_dir = /js
    json_dir = /js/json
    ofc_file = /OFCDZ.swf
  • If this does not appear, default values will be used.
  • js_dir, jsor_dir and ofc_file are the location on the http server of the Open Flash Charts files.
  • As you can see, the default ofc_file value is OFCDZ.swf, which is another implementation of Open Flash Charts, that make the bar charts clickable. You can download it from OFCDZ.

Some notes on installation

  • I tried all kinds of configurations to get the charts to appear (ver 11.5) - followed the information on this ticket
  • Answer for me was to copy all the OFC2 files to my Apache web server http://mywebserver/trac/reports/
  • Then I changed the paths to:
js_dir = http://mywebserver/trac/reports/js
json_dir = http://mywebserver/trac/reports/js/json
ofc_file = http://mywebserver/trac/reports/OFCDZ.swf

and it worked.

Macro arguments

Although I believe the examples show it all, I'll write here the arguments:

  • Arguments for all types of graphs:
    • type - The type of the graph. Can be pie, bars or stacked_bars.
    • height, width - The height and width of the graph, in pixels. Percents will not work. If not specified, the values from trac.ini are taken (and if those aren't specified, then other default values are used).
    • title - Text that will be displayed on the top of the chart.
    • query - A Trac Query. All the stats will be taken from this query. It is important that everything in the query's parmeters will be under quotes. Examples:
      query = milestone="my_milestone"&owner="aviram"|"danny"
    • ofc_file, js_dir, json_dir - Same as the variables in the macro's configuration. If these are specified, the configuration is ignored.
  • Arguments for pie graphs:
    • factor - The name of the field by which the stats will be formed.
  • Arguments for bar graphs:
    • x_axis - The name of the field by which the stats will be formed (The X Axis values).
  • Arguments for stacked bars graphs:
    • x_axis - The name of the field by which the stats will be formed (The X Axis values).
    • key - The name of the field by which the chart's columns are divided.

Examples with Snapshots

Number of tickets per milestone:

[[TicketChart(type = pie, factor = milestone)]]

Number of tickets per status for milestone4:

[[TicketChart(type = pie, factor = status, query = milestone="milestone4")]]

Number of tickets by status and owners:

[[TicketChart(type = stacked_bars, key = owner, x_axis = status, height = 400, width = 600)]]

Number of tickets by status and owner for milestone1:

[[TicketChart(type = stacked_bars, key = owner, x_axis = status, query = milestone="milestone1", title = Tickets by status and owner for milestone1)]]

Number of tickets by owner and type:

[[TicketChart(type = stacked_bars, key = type, x_axis = owner)]]

Number of tickets by status for milestone4:

[[TicketChart(type = bars, x_axis = status, query = milestone="milestone4", title = Tickets by status for milestone4)]]

Recent Changes

[13335] by jun66j5 on 2013-07-17 18:26:41
refs #6904: fixed UnicodeDecodeError, _get_random_string generates a 8-bit string if non en-US locale
[13250] by rjollos on 2013-05-27 16:50:34
Refs #6904, #11072: Refactoring and improved backward compatibility for changes in [13247] and [13248], suggested by Jun Omae (jun66j5).
[13248] by rjollos on 2013-05-27 14:12:16
Refs #11072: Avoid values of 'None' in query string for "clickable link" when value should be an empty string.


Author: aviram

Attachments (6)

Download all attachments as: .zip