wiki:TracYetAnotherChartMacro

Version 4 (modified by Theodor Norup, 6 years ago) (diff)

--

Creare bar/line/pie charts of query results

Description

Create a bar/line/pie chart of an SQL query using the plotly.js JavaScript plotting engine.

The plugin egg contains plotly.js, ie. there are no external web references.

A given wiki page can contain any number of plots.

The plugin is at its very infancy (May 2018) so only a fraction of plotly's functionality is supported, parameter syntax may change a bit and error checking is very likely to be improveable.

Bugs/Feature Requests

Existing bugs and feature requests for TracYetAnotherChartMacro are here.

If you have any issues, create a new ticket.

defect

1 / 1

Download

Download the zipped source from here.

Source

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

Installation

General instructions on installing Trac plugins can be found on the TracPlugins page.

Usage

[[yachart(id=first; title=Action statuses; query=SELECT status, COUNT(status) FROM ticket WHERE type = 'Action' GROUP BY status)]]

...will result in something like this:

Bar chart example

Parameters

Note the unusual use of semicolon as delimiter character - this is chosen in order to avoid escaping commas in the SQL query

id         = dom-name     # The name of the HTML DOM carrying the chart. Mandatory. Must be unique for each macro call on a wiki page
title      = title-text   # The headline shown above the chart. Default: blank.
chart_type = bar|line|pie # Optional; default: bar
query      = sql-query    # Mandatory
width      = pixel-width  # Optional; default: 600 pixels
height     = pixel-height # Optional: default: 400 pixels

The query must return two columns. In line and bar charts, the first column will be used as x-axis data and the second column as y-axis data. In pie charts, the columns will be used as labels and values, respectively.

In the query, the macro will replace the string $USER with the id of the user logged in. This can be used to display "my tickets":

WikiProcessor syntax is supported which may make queries easier to read (and write):

   {{{#!yachart
   id=something;
   title=something else;
   query=SELECT 
            status, 
            COUNT(status) 
         FROM ticket 
         WHERE type = 'Action' 
         GROUP BY status;
   }}}

Recent Changes

17240 by rjollos on 2018-07-17 02:12:33
Add installation requirements

Fixes #13449.

17196 by thenor on 2018-06-06 19:34:02
fix incorrect read of utf-8 data and remove possible newlines in text data (makes plotly fail with a browser console message)
17183 by thenor on 2018-05-23 19:33:38
Add margin control, fix plot size control, add admin panel
(more)

Author/Contributors

Author: thenor
Maintainer: Theodor Norup
Contributors:

Attachments (2)

Download all attachments as: .zip